diff --git a/app/Livewire/CollectionList.php b/app/Livewire/CollectionList.php new file mode 100644 index 00000000..45ddf4ec --- /dev/null +++ b/app/Livewire/CollectionList.php @@ -0,0 +1,47 @@ +resetPage(); + } + + public function render() + { + $search = $this->query; + $collections = Collection::query() + ->where(function ($query) use ($search) { + $query->whereRaw('LOWER(title) LIKE ?', ['%'.strtolower($search).'%']) + ->orWhereRaw('LOWER(description) LIKE ?', ['%'.strtolower($search).'%']); + }) + ->orderByRaw('title LIKE ? DESC', [$search.'%']) + ->orderByRaw('description LIKE ? DESC', [$search.'%']) + ->paginate($this->size); + + return view('livewire.collection-list', ['collections' => $collections]); + } +} diff --git a/app/Livewire/CompoundClasses.php b/app/Livewire/CompoundClasses.php index eb342e94..77c8a009 100644 --- a/app/Livewire/CompoundClasses.php +++ b/app/Livewire/CompoundClasses.php @@ -6,6 +6,32 @@ class CompoundClasses extends Component { + public $superClasses = [ + 'Acetylides', + 'Alkaloids and derivatives', + 'Allenes', + 'Benzenoids', + 'Hydrocarbon derivatives', + 'Hydrocarbons', + 'Lignans, neolignans and related compounds', + 'Lipids and lipid-like molecules', + 'Nucleosides, nucleotides, and analogues', + 'Organoheterocyclic compounds', + 'Organohalogen compounds', + 'Organometallic compounds', + 'Organophosphorus compounds', + 'Organosulfur compounds', + 'Organic 1,3-dipolar compounds', + 'Organic Polymers', + 'Organic acids and derivatives', + 'Organic anions', + 'Organic cations', + 'Organic nitrogen compounds', + 'Organic oxygen compounds', + 'Organic salts', + 'Phenylpropanoids and polyketides', + ]; + public $parentClasses = [ 'Acenaphthylenes', 'Acetals', @@ -985,7 +1011,8 @@ class CompoundClasses extends Component public function mount() { - $this->parentClasses = array_slice($this->parentClasses, 0, 50); + // $this->parentClasses = array_slice($this->parentClasses, 0, 50); + $this->superClasses = $this->superClasses; } public function render() diff --git a/app/Livewire/MoleculeDetails.php b/app/Livewire/MoleculeDetails.php index a201eff4..59f754e9 100644 --- a/app/Livewire/MoleculeDetails.php +++ b/app/Livewire/MoleculeDetails.php @@ -4,7 +4,6 @@ use App\Models\Molecule; use Cache; -use Livewire\Attributes\Layout; use Livewire\Component; class MoleculeDetails extends Component @@ -18,11 +17,20 @@ public function mount($id) }); } - #[Layout('layouts.guest')] public function render() { return view('livewire.molecule-details', [ 'molecule' => $this->molecule, - ]); + ])->layout('layouts.guest') + ->layoutData([ + 'title' => $this->molecule->name ? $this->molecule->name : $this->molecule->iupac_name, + 'description' => $this->molecule->description ?? 'Molecule details for '.($this->molecule->name ? $this->molecule->name : $this->molecule->iupac_name), + 'keywords' => 'natural products, '.$this->molecule->name.', '.$this->molecule->iupac_name.', '.implode(',', $this->molecule->synonyms ?? []), + 'author' => $this->molecule->author ?? 'COCONUT Team', + 'ogTitle' => $this->molecule->name ? $this->molecule->name : $this->molecule->iupac_name, + 'ogDescription' => $this->molecule->description ?? 'Molecule details for '.($this->molecule->name ? $this->molecule->name : $this->molecule->iupac_name), + 'ogImage' => env('CM_API').'depict/2D?smiles='.urlencode($this->molecule->canonical_smiles).'&height=200&width=200&toolkit=cdk' ?? asset('img/coconut-og-image.png'), + 'ogSiteName' => 'Coconut 2.0', + ]); } } diff --git a/app/Livewire/MoleculeEditor.php b/app/Livewire/MoleculeEditor.php deleted file mode 100644 index 4483f16c..00000000 --- a/app/Livewire/MoleculeEditor.php +++ /dev/null @@ -1,15 +0,0 @@ -page = $page; } - #[Layout('layouts.guest')] + protected $listeners = ['updateSmiles' => 'setSmiles']; + + public function setSmiles($smiles, $searchType) + { + $this->query = $smiles; + $this->type = $searchType; + } + public function render() { @@ -173,7 +183,31 @@ public function render() } elseif ($queryType == 'tags') { if ($this->tagType == 'dataSource') { $this->collection = Collection::where('title', $this->query)->first(); - $results = $this->collection->molecules()->orderBy('annotation_level', 'desc')->paginate($this->size); + if ($this->collection) { + $results = $this->collection->molecules()->orderBy('annotation_level', 'desc')->paginate($this->size); + } else { + $results = new LengthAwarePaginator( + [], + 0, + $this->size, + $this->page + ); + } + } elseif ($this->tagType == 'organisms') { + $this->organisms = array_map(function ($name) { + return strtolower(trim($name)); + }, explode(',', $this->query)); + + $organismIds = Organism::where(function ($query) { + foreach ($this->organisms as $name) { + $query->orWhereRaw('LOWER(name) = ?', [$name]); + } + })->pluck('id'); + + $results = Molecule::whereHas('organisms', function ($query) use ($organismIds) { + $query->whereIn('organism_id', $organismIds); + })->orderBy('annotation_level', 'DESC')->paginate($this->size); + } else { $results = Molecule::withAnyTags([$this->query], $this->tagType)->paginate($this->size); } @@ -235,11 +269,12 @@ public function render() } $statement = $statement. - '('.$filterMap[$_filter[0]].'::TEXT ILIKE \'%'.$_filter[1].'%\')'; + '(LOWER(REGEXP_REPLACE('.$filterMap[$_filter[0]].' , \'\s+\', \'-\', \'g\'))::TEXT ILIKE \'%'.$_filter[1].'%\')'; } } $statement = $statement.')'; } + // dd($statement); $statement = $statement.' LIMIT '.$this->size; } else { if ($this->query) { @@ -335,10 +370,5 @@ public function render() 500 ); } - // return view('livewire.search', [ - // 'molecules' => MoleculeResource::collection( - // Molecule::where('active', true)->orderByDesc('updated_at')->paginate($this->size) - // ), - // ]); } } diff --git a/app/Livewire/StructureEditor.php b/app/Livewire/StructureEditor.php new file mode 100644 index 00000000..928bb71f --- /dev/null +++ b/app/Livewire/StructureEditor.php @@ -0,0 +1,30 @@ +smiles = $smiles; + $this->isOpen = true; + } + + public function closeModal() + { + $this->isOpen = false; + } + + public function render() + { + return view('livewire.structure-editor'); + } +} diff --git a/package-lock.json b/package-lock.json index 3622b4e9..e53a6ec2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "html", + "name": "coconut", "lockfileVersion": 3, "requires": true, "packages": { "": { "dependencies": { - "openchemlib": "^8.9.0" + "openchemlib": "^8.13.0" }, "devDependencies": { "@tailwindcss/forms": "^0.5.7", @@ -2336,9 +2336,9 @@ } }, "node_modules/openchemlib": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/openchemlib/-/openchemlib-8.9.0.tgz", - "integrity": "sha512-8Bb7batm6XvNHg9SWBJDYrkJj5bsq72D5dClpN5yO6BnxxNxtRP1+e6egHwoMwGhd4dyb+eBX7Kr/hdUqMN1Dw==" + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/openchemlib/-/openchemlib-8.13.0.tgz", + "integrity": "sha512-CdE9mNFdiQaZbjThvpplKC2YObyg9w4cKbuZ8nn/dRuTvk35H7+LPl2xylm84OGW3062AanU61ms4HnNZOzoXA==" }, "node_modules/path-key": { "version": "3.1.1", diff --git a/package.json b/package.json index 01a873ec..7ad773be 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,6 @@ "vitepress": "^1.2.2" }, "dependencies": { - "openchemlib": "^8.9.0" + "openchemlib": "^8.13.0" } } diff --git a/public/img/coconut-og-image.png b/public/img/coconut-og-image.png new file mode 100644 index 00000000..4b4761db Binary files /dev/null and b/public/img/coconut-og-image.png differ diff --git a/resources/css/app.css b/resources/css/app.css index bde27f8c..fdbb0ecb 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -293,4 +293,12 @@ .tooltip:hover .tooltiptext { visibility: visible; opacity: 1; +} + +.organism::first-letter { + text-transform: capitalize !important; +} + +.organism { + font-style: italic; } \ No newline at end of file diff --git a/resources/js/app.js b/resources/js/app.js index 9062e98f..51383765 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,4 +1,4 @@ import "./bootstrap"; import OCL from "openchemlib/full"; -window.OCL = OCL; \ No newline at end of file +window.OCL = OCL; diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php index b05fcc62..adff83a6 100644 --- a/resources/views/layouts/guest.blade.php +++ b/resources/views/layouts/guest.blade.php @@ -7,6 +7,19 @@ {{ config('app.name', 'Coconut') }} + + + + + + + + + + + + + diff --git a/resources/views/livewire/collection-list.blade.php b/resources/views/livewire/collection-list.blade.php new file mode 100644 index 00000000..a47a5eb1 --- /dev/null +++ b/resources/views/livewire/collection-list.blade.php @@ -0,0 +1,64 @@ +
+
+
+

Browse collections

+

Explore our database of natural products to uncover their + unique properties. Search, filter, and discover the diverse realm of chemistry. +

+
+
+
+
+
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+
+ {{ $collections->links() }} +
+ +
+ {{ $collections->links() }} +
+
+
diff --git a/resources/views/livewire/compound-classes.blade.php b/resources/views/livewire/compound-classes.blade.php index 0a63fd14..42b45404 100644 --- a/resources/views/livewire/compound-classes.blade.php +++ b/resources/views/livewire/compound-classes.blade.php @@ -1,13 +1,13 @@
-
+

Compound Classes

- @foreach ($parentClasses as $class) + @foreach ($superClasses as $class) - {{ $class }} + {{ $class }} @endforeach diff --git a/resources/views/livewire/data-sources.blade.php b/resources/views/livewire/data-sources.blade.php index 3c4846f7..98637972 100644 --- a/resources/views/livewire/data-sources.blade.php +++ b/resources/views/livewire/data-sources.blade.php @@ -1,5 +1,5 @@
-
+
{{--
@@ -13,40 +13,29 @@ class="-mb-1 block text-primary-dark bg-clip-text">Data Sources

Collections

- {{-- - Browse all collections - --}}
-
-
-
- @foreach ($collections as $collection) - - - - {{ $collection }} - - @endforeach - -
+
+
+ @foreach ($collections as $collection) + + + + {{ $collection }} + + @endforeach
-
diff --git a/resources/views/livewire/header.blade.php b/resources/views/livewire/header.blade.php index a8bedfd0..aa225353 100644 --- a/resources/views/livewire/header.blade.php +++ b/resources/views/livewire/header.blade.php @@ -1,84 +1,70 @@ - -
- - -
+
+ + +
\ No newline at end of file diff --git a/resources/views/livewire/molecule-details.blade.php b/resources/views/livewire/molecule-details.blade.php index eda66189..96efbf34 100644 --- a/resources/views/livewire/molecule-details.blade.php +++ b/resources/views/livewire/molecule-details.blade.php @@ -1,4 +1,4 @@ -
+
@@ -7,7 +7,7 @@ class="mx-auto max-w-3xl px-4 sm:px-6 md:flex md:items-center md:justify-between

{{ $molecule->identifier }}

- {{ $molecule->name ? $molecule->name : $molecule->iupac_name}} + {{ $molecule->name ? $molecule->name : $molecule->iupac_name }}

Created on · Last @@ -15,105 +15,123 @@ class="mb-2 text-2xl break-all font-bold leading-7 break-words text-gray-900 sm:

- @if($molecule->properties) -
-
-
-
NPLikeness -
- NP Likeness Score: The likelihood of the compound to be a natural - product, ranges from -5 (less likely) to 5 (very likely). + @if ($molecule->properties) +
+
+
+
NPLikeness +
+ NP Likeness Score: The likelihood of the compound to be a + natural + product, ranges from -5 (less likely) to 5 (very likely). +
+
+
+
+
+ @foreach (range(0, ceil(npScore($molecule->properties->np_likeness))) as $i) +
+ @endforeach +
+ {{ $molecule->properties->np_likeness }} +
-
-
-
-
- @foreach (range(0, ceil(npScore($molecule->properties->np_likeness))) as $i) -
- @endforeach -
- {{ $molecule->properties->np_likeness }} -
-
-
-
-
Annotation Level
-
- @for ($i = 0; $i < $molecule->annotation_level; $i++) - - @endfor - @for ($i = $molecule->annotation_level; $i < 5; $i++) - ☆ - @endfor +
+
+
Annotation Level
+
+ @for ($i = 0; $i < $molecule->annotation_level; $i++) + + @endfor + @for ($i = $molecule->annotation_level; $i < 5; $i++) + ☆ + @endfor +
-
-
-
-
Mol. Weight
-
{{ $molecule->properties->molecular_weight }}
+
+
+
Mol. Weight
+
{{ $molecule->properties->molecular_weight }}
+
-
-
-
-
Mol. Formula
-
{{ $molecule->properties->molecular_formula }}
+
+
+
Mol. Formula
+
{{ $molecule->properties->molecular_formula }}
+
-
-
-
+ +
@endif
- @if ($molecule->organisms && count($molecule->organisms) > 0) -
-
-
-

- Organisms

-
-
-
+ @if ($molecule->organisms && count($molecule->organisms) > 0) +
+
+
+

+ Organisms

+
+
+
+
-
-
+ @endif - @if ($molecule->geo_locations && count($molecule->geo_locations) > 0) -
-
-
-

- Geolocations

-
-
-
+ @if ($molecule->geo_locations && count($molecule->geo_locations) > 0) +
+
+
+

+ Geolocations

+
+
+
    @foreach ($molecule->geo_locations as $geo_location) @if ($geo_location != '') @@ -126,10 +144,10 @@ class="mx-auto mt-8 grid max-w-3xl grid-cols-1 gap-6 sm:px-6 lg:max-w-7xl lg:gri @endif @endforeach
+
-
-
+ @endif
@@ -157,7 +175,7 @@ class="text-sm font-medium text-gray-500 sm:flex sm:justify-between"> Name
- {{ $molecule->name ? $molecule->name : '-' }} + {{ $molecule->name ? $molecule->name : '-' }}
@@ -195,16 +213,17 @@ class="text-sm font-medium text-gray-500 sm:flex sm:justify-between"> {{ $molecule->canonical_smiles }}
- @if($molecule->properties) -
-
-
Murcko Framework + @if ($molecule->properties) +
+
+
Murcko + Framework +
+
+
+ {{ $molecule->properties->murko_framework }}
-
- {{ $molecule->properties->murko_framework }} -
-
@endif
@@ -259,90 +278,111 @@ class="text-sm relative mr-2 inline-flex items-center rounded-md border border-g
- @if($molecule->properties) -
-
-
-
-

Molecular Properties -

+ @if ($molecule->properties) +
+
+
+
+

Molecular + Properties +

+
+
+
+
    +
  • Total + atom number : {{ $molecule->properties->total_atom_count }} +
  • +
  • Heavy + atom number : + {{ $molecule->properties->heavy_atom_count }}
  • +
  • Aromatic Ring Count : + {{ $molecule->properties->aromatic_rings_count }}
  • +
  • Rotatable Bond count : + {{ $molecule->properties->rotatable_bond_count }}
  • +
  • Minimal number of rings + : {{ $molecule->properties->number_of_minimal_rings }}
  • +
  • Formal Charge : + {{ $molecule->properties->total_atom_count }}
  • +
  • Contains Sugar : + {{ $molecule->properties->contains_sugar ? 'True' : 'False' }} +
  • +
  • Contains Ring Sugars : + {{ $molecule->properties->contains_ring_sugars ? 'True' : 'False' }} +
  • +
  • Contains Linear Sugars + : + {{ $molecule->properties->contains_linear_sugars ? 'True' : 'False' }} +
  • +
+
+
-
-
-
    -
  • Total - atom number : {{ $molecule->properties->total_atom_count }}
  • -
  • Heavy - atom number : - {{ $molecule->properties->heavy_atom_count }}
  • +
+
+ +
+
+
+
+

Molecular + Descriptors +

+
+
+
  • Aromatic Ring Count : - {{ $molecule->properties->aromatic_rings_count }}
  • + class="ml-3 text-base text-gray-500">NP-likeness scores : + {{ $molecule->properties->np_likeness }} +
  • Alogp + : + {{ $molecule->properties->alogp }}
  • Rotatable Bond count : - {{ $molecule->properties->rotatable_bond_count }}
  • + class="ml-3 text-base text-gray-500">TopoPSA : + {{ $molecule->properties->topological_polar_surface_area }} +
  • Fsp3 + : + {{ $molecule->properties->total_atom_count }}
  • Minimal number of rings - : {{ $molecule->properties->number_of_minimal_rings }}
  • + class="ml-3 text-base text-gray-500">Hydrogen + Bond Acceptor Count + : {{ $molecule->properties->hydrogen_bond_acceptors }}
  • Formal Charge : - {{ $molecule->properties->total_atom_count }}
  • + class="ml-3 text-base text-gray-500">Hydrogen + Bond Donor Count : + {{ $molecule->properties->hydrogen_bond_donors }} +
  • Contains Sugar : - {{ $molecule->properties->contains_sugar ? "True" : "False" }}
  • + class="ml-3 text-base text-gray-500">Lipinski + Hydrogen Bond + Acceptor Count : + {{ $molecule->properties->hydrogen_bond_acceptors_lipinski }} +
  • Contains Ring Sugars : - {{ $molecule->properties->contains_ring_sugars ? "True" : "False" }}
  • + class="ml-3 text-base text-gray-500">Lipinski + Hydrogen Bond Donor + Count : + {{ $molecule->properties->hydrogen_bond_donors_lipinski }} +
  • Contains Linear Sugars - : {{ $molecule->properties->contains_linear_sugars ? "True" : "False" }}
  • + class="ml-3 text-base text-gray-500">Lipinski + RO5 Violations : + {{ $molecule->properties->lipinski_rule_of_five_violations }} +
-
-
- -
-
-
-
-

Molecular Descriptors -

-
-
-
    -
  • NP-likeness scores : - {{ $molecule->properties->np_likeness }}
  • -
  • Alogp : - {{ $molecule->properties->alogp }}
  • -
  • TopoPSA : - {{ $molecule->properties->topological_polar_surface_area }}
  • -
  • Fsp3 : - {{ $molecule->properties->total_atom_count }}
  • -
  • Hydrogen - Bond Acceptor Count - : {{ $molecule->properties->hydrogen_bond_acceptors }}
  • -
  • Hydrogen - Bond Donor Count : {{ $molecule->properties->hydrogen_bond_donors }} -
  • -
  • Lipinski - Hydrogen Bond - Acceptor Count : - {{ $molecule->properties->hydrogen_bond_acceptors_lipinski }}
  • -
  • Lipinski - Hydrogen Bond Donor - Count : {{ $molecule->properties->hydrogen_bond_donors_lipinski }} -
  • -
  • Lipinski - RO5 Violations : - {{ $molecule->properties->lipinski_rule_of_five_violations }}
  • -
-
-
-
-
+ @endif
diff --git a/resources/views/livewire/molecule-editor.blade.php b/resources/views/livewire/molecule-editor.blade.php deleted file mode 100644 index b80e6e06..00000000 --- a/resources/views/livewire/molecule-editor.blade.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/resources/views/livewire/search.blade.php b/resources/views/livewire/search.blade.php index 0cd713f0..d86101a2 100644 --- a/resources/views/livewire/search.blade.php +++ b/resources/views/livewire/search.blade.php @@ -3,66 +3,82 @@ @if ($tagType == 'dataSource') @if ($collection)
-

#COLLECTION

+

#COLLECTION

{{ $collection->title }}

-

{{ $collection->description }}

- @if($collection->license) -

License: {{ $collection->license->title }}

+

{{ $collection->description }}

+ @if ($collection->license) +

License: {{ $collection->license->title }}

@endif
@endif + @elseif ($tagType == 'organisms') +
+

#ORGANISMS

+ @foreach ($organisms as $index => $organism) + {{ ucfirst($organism) }} + @if (!$loop->last) + , + @endif + @endforeach +
@else

Browse compounds

-

Explore our database of natural products to uncover their unique properties. Search, filter, and discover the diverse realm of chemistry. +

Explore our database of natural products to uncover their + unique properties. Search, filter, and discover the diverse realm of chemistry.

@endif
-
-
-
-
-
-
-
-
+
- -
+
+
+
+
+
+
+
+
+ +
+ + +
-
-
-
-
-
- {{--
+ {{--
--}} +
+ {{--
--}} +
-
+ +
{{ $molecules->links() }} diff --git a/resources/views/livewire/structure-editor.blade.php b/resources/views/livewire/structure-editor.blade.php new file mode 100644 index 00000000..98d17449 --- /dev/null +++ b/resources/views/livewire/structure-editor.blade.php @@ -0,0 +1,81 @@ +
+ +
diff --git a/resources/views/livewire/welcome.blade.php b/resources/views/livewire/welcome.blade.php index ce003adf..1d7b82ee 100644 --- a/resources/views/livewire/welcome.blade.php +++ b/resources/views/livewire/welcome.blade.php @@ -13,7 +13,8 @@ class="block xl:inline">COCONUT: Browse - or Submit data Submit data

Report bugs: + +