Skip to content

Commit

Permalink
Merge pull request #910 from NFDI4Chem/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NishaSharma14 authored Nov 20, 2023
2 parents d519228 + 23863ab commit e3fec74
Show file tree
Hide file tree
Showing 17 changed files with 1,125 additions and 169 deletions.
42 changes: 42 additions & 0 deletions app/Console/Commands/IndexMolecules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class IndexMolecules extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'nmrxiv:index-molecules';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Reindex molecules';

/**
* Execute the console command.
*/
public function handle()
{
return DB::transaction(function () {
DB::statement('DROP TABLE IF EXISTS mols, fps');
DB::statement('create extension if not exists rdkit');
DB::statement('select * into mols from (select id,mol_from_smiles(canonical_smiles::cstring) m from molecules) tmp where m is not null');
DB::statement('create index molidx on mols using gist(m)');
DB::statement('alter table mols add primary key (id)');
DB::statement('select id, torsionbv_fp(m) as torsionbv,morganbv_fp(m) as mfp2, featmorganbv_fp(m) as ffp2 into fps from mols');
DB::statement('create index fps_ttbv_idx on fps using gist(torsionbv)');
DB::statement('create index fps_mfp2_idx on fps using gist(mfp2)');
DB::statement('create index fps_ffp2_idx on fps using gist(ffp2)');
DB::statement('alter table fps add primary key (id)');
});
}
}
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected function schedule(Schedule $schedule)
{
$schedule->command('nmrxiv:publish')->daily();
$schedule->command('nmrxiv:delete-projects')->daily();
$schedule->command('nmrxiv:index-molecules')->daily();
$schedule->command('nmrxiv:delete-citations')->weekly();
$schedule->command('nmrxiv:delete-authors')->weekly();
if (App::environment('production')) {
Expand Down
22 changes: 22 additions & 0 deletions app/Http/Controllers/Admin/CurationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Dataset;
use Inertia\Inertia;

class CurationController extends Controller
{
public function spectra()
{
return Inertia::render('Console/Spectra/Index');
}

public function snapshots()
{
return Inertia::render('Console/Spectra/Snapshot', [
'datasets' => Dataset::where('has_nmrium', 1)->where('dataset_photo_path', null)->pluck('id')->all(),
]);
}
}
2 changes: 1 addition & 1 deletion app/Models/Study.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public function getStudyPreviewUrlsAttribute()
return $urls;
}


/**
* Get the experiment types performed on this sample.
*
Expand All @@ -133,6 +132,7 @@ public function getStudyPreviewUrlsAttribute()
public function getStudyExperimentTypesAttribute()
{
$experiment_types = $this->datasets->pluck('type');

return $experiment_types;
}

Expand Down
14 changes: 6 additions & 8 deletions database/scripts/initialise_molecules_index.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ create extension if not exists rdkit;
select * into mols from (select id,mol_from_smiles(canonical_smiles::cstring) m from molecules) tmp where m is not null;
create index molidx on mols using gist(m);
alter table mols add primary key (id);
select id, torsionbv_fp(m) as torsionbv,morganbv_fp(m) as mfp2, featmorganbv_fp(m) as ffp2 into fps from mols;
create index fps_ttbv_idx on fps using gist(torsionbv);
create index fps_mfp2_idx on fps using gist(mfp2);
create index fps_ffp2_idx on fps using gist(ffp2);
alter table fps add primary key (id);

-- select identifier, standard_inchi, standard_inchi_key, properties.score from molecules RIGHT JOIN properties ON properties.molecule_id = molecules.id;
-- select * from molecules where identifier = 'CNP0228556' limit 24 offset 0;
-- SELECT * from properties where molecule_id = 139702;
-- select id, COUNT(*) OVER () from molecules where name = 'Curcumin' limit 24;
-- select count(*) from molecules where smiles@>'c1cccc2c1nncc2' ;
-- select id, COUNT(*) OVER () from molecules where LOWER(synonyms) LIKE '%' || LOWER('Thein') || '%' limit 24 offset 0;
-- select id, COUNT(*) OVER () from molecules where LOWER(name) LIKE LOWER('Caffeine') OR LOWER(synonyms) LIKE '%' || LOWER('Caffeine') || '%' ORDER BY CASE WHEN (name) LIKE LOWER('Caffeine') THEN 1 WHEN LOWER(synonyms) LIKE '%' || LOWER('Caffeine') || '%' THEN 2 END;

select id, torsionbv_fp(m) as torsionbv,morganbv_fp(m) as mfp2, featmorganbv_fp(m) as ffp2 into fps from mols;
create index fps_ttbv_idx on fps using gist(torsionbv);
create index fps_mfp2_idx on fps using gist(mfp2);
create index fps_ffp2_idx on fps using gist(ffp2);
alter table fps add primary key (id);

-- select identifier, standard_inchi, standard_inchi_key, properties.score from molecules RIGHT JOIN properties ON properties.molecule_id = molecules.id;
168 changes: 61 additions & 107 deletions resources/js/App/MoleculeCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,120 +6,72 @@
class="p-4 border-b"
:molecule="molecule.canonical_smiles"
></Depictor2D>
<div
v-if="molecule.name && molecule.name != ''"
class="py-4 px-4"
>
<div class="flex items-center">
<div class="mb-1 flex items-center">
<svg
:key="index"
v-for="index in molecule.annotation_level"
class="inline text-yellow-400 h-4 w-4 flex-shrink-0"
x-state:on="Active"
x-state:off="Inactive"
x-state-description='Active: "text-yellow-400", Inactive: "text-gray-200"'
x-description="Heroicon name: mini/star"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"
clip-rule="evenodd"
></path>
</svg>
<svg
:key="index"
v-for="index in 5 - molecule.annotation_level"
class="inline text-gray-200 h-4 w-4 flex-shrink-0"
x-state-description='undefined: "text-yellow-400", undefined: "text-gray-200"'
x-description="Heroicon name: mini/star"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
<div class="py-4 px-4">
<Link :href="'/spectra?compound=' + molecule.identifier">
<div class="flex items-center">
<div class="mb-1 flex items-center">
<svg
:key="index"
v-for="index in molecule.annotation_level"
class="inline text-yellow-400 h-4 w-4 flex-shrink-0"
x-state:on="Active"
x-state:off="Inactive"
x-state-description='Active: "text-yellow-400", Inactive: "text-gray-200"'
x-description="Heroicon name: mini/star"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"
clip-rule="evenodd"
></path>
</svg>
<svg
:key="index"
v-for="index in 5 -
molecule.annotation_level"
class="inline text-gray-200 h-4 w-4 flex-shrink-0"
x-state-description='undefined: "text-yellow-400", undefined: "text-gray-200"'
x-description="Heroicon name: mini/star"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"
clip-rule="evenodd"
></path>
</svg>
</div>
</div>
<div class="font-bold text-md mb-2">
<a
class="font-semibold text-gray-600 hover:underline"
>#NMRXIV:{{ molecule.identifier }}</a
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"
clip-rule="evenodd"
></path>
</svg>
</div>
</div>
<div class="font-bold text-md mb-2">
<a
:href="'/spectra?compound=' + molecule.identifier"
class="font-semibold text-gray-600 hover:underline"
>#NMRXIV:{{ molecule.identifier }}</a
<div
class="text-gray-700 text-base break-all text-sm capitalize"
v-if="
molecule.iupac_name && molecule.iupac_name != ''
"
>
</div>
<div
class="text-gray-700 text-base break-all text-sm xs:truncate"
>
{{ molecule.name }}
</div>
</div>
<div v-else class="py-4 px-4">
<div class="flex items-center">
<div class="mb-1 flex items-center">
<svg
:key="index"
v-for="index in molecule.annotation_level"
class="inline text-yellow-400 h-4 w-4 flex-shrink-0"
x-state:on="Active"
x-state:off="Inactive"
x-state-description='Active: "text-yellow-400", Inactive: "text-gray-200"'
x-description="Heroicon name: mini/star"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"
clip-rule="evenodd"
></path>
</svg>
<svg
:key="index"
v-for="index in 5 - molecule.annotation_level"
class="inline text-gray-200 h-4 w-4 flex-shrink-0"
x-state-description='undefined: "text-yellow-400", undefined: "text-gray-200"'
x-description="Heroicon name: mini/star"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M10.868 2.884c-.321-.772-1.415-.772-1.736 0l-1.83 4.401-4.753.381c-.833.067-1.171 1.107-.536 1.651l3.62 3.102-1.106 4.637c-.194.813.691 1.456 1.405 1.02L10 15.591l4.069 2.485c.713.436 1.598-.207 1.404-1.02l-1.106-4.637 3.62-3.102c.635-.544.297-1.584-.536-1.65l-4.752-.382-1.831-4.401z"
clip-rule="evenodd"
></path>
</svg>
{{ molecule.iupac_name }}
</div>
</div>
<div class="font-bold text-md mb-2">
<a
:href="'/spectra?compound=' + molecule.identifier"
class="font-semibold text-gray-600 hover:underline"
>#NMRXIV:{{ molecule.identifier }}</a
<div
class="text-gray-700 text-base break-all text-sm"
v-else
>
</div>
<div
class="text-gray-700 text-base break-all text-xs truncate"
>
<small>
<label>SMILES</label><br />
{{ molecule.canonical_smiles }}
</small>
</div>
</div>
</Link>
</div>

<!-- <div class="px-6 pb-2">
<span
class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2"
Expand All @@ -140,9 +92,11 @@
</template>
<script>
import Depictor2D from "@/Shared/Depictor2D.vue";
import { Link } from "@inertiajs/vue3";
export default {
components: {
Depictor2D,
Link,
},
props: ["molecule"],
computed: {},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/App/StructureSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
Cancel
</button>
<button
class="ml-3 inline-flex justify-center rounded-md border border-transparent bg-secondary-dark py-2 px-4 text-sm font-medium text-white shadow-sm hover:bg-secondary-light focus:outline-none focus:ring-2 focus:ring-secondary-dark focus:ring-offset-2"
class="ml-3 inline-flex justify-center rounded-md bg-gray-700 text-white py-2 px-4 text-sm font-medium shadow-sm hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-secondary-dark focus:ring-offset-2"
@click="search"
>
Search
Expand Down
12 changes: 11 additions & 1 deletion resources/js/Pages/Console/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
</svg>
</span>
</div>
<blocks
heading="Curation"
description="Manage spectra meta-data."
name="curation"
path="console.spectra"
/>
</div>
</div>
</div>
Expand All @@ -92,14 +98,18 @@
import AppLayout from "@/Layouts/AppLayout.vue";
import { Link } from "@inertiajs/vue3";
import Blocks from "@/Shared/Blocks.vue";
import { EllipsisVerticalIcon } from "@heroicons/vue/24/solid";
import {
EllipsisVerticalIcon,
RectangleStackIcon,
} from "@heroicons/vue/24/solid";
export default {
components: {
Link,
AppLayout,
Blocks,
EllipsisVerticalIcon,
RectangleStackIcon,
},
};
</script>
Loading

0 comments on commit e3fec74

Please sign in to comment.