Skip to content

Commit

Permalink
fix: bug fixes in schema and other updates to 3d rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Aug 30, 2024
1 parent 8fa1c88 commit ce4b9f9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 47 deletions.
8 changes: 4 additions & 4 deletions app/Console/Commands/ImportCHEMBLNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ public function handle()
->where('id', $row->id)
->update([
'name' => $newName,
'synonyms' => $synonyms
'synonyms' => $synonyms,
]);
}else{
} else {
$newName = $row->iupac_name;
if($newName){
if ($newName) {
$synonyms = json_decode($row->synonyms) ?? [];
array_unshift($synonyms, $row->name);
DB::table('molecules')
->where('id', $row->id)
->update([
'name' => $newName,
'synonyms' => $synonyms
'synonyms' => $synonyms,
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/MoleculeDepict3d.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MoleculeDepict3d extends Component
#[Computed]
public function source()
{
return env('CM_API').'depict/3D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width.'&CIP='.$this->CIP.'&toolkit=rdkit';
return env('CM_API').'depict/3D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width.'&CIP='.$this->CIP.'&toolkit=openbabel';
}

public function render()
Expand Down
92 changes: 54 additions & 38 deletions app/Models/Molecule.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,92 +178,108 @@ public function getSchema($type = 'bioschemas')

if ($this->organisms) {
$organisms = $this->organisms ?? [];
$names = [];
foreach($organisms as $organism) {
$names = [];
foreach ($organisms as $organism) {
$name = $organism->name;
array_push($names, $name);
}
$moleculeSchema->taxonomicRange($names);
}

$additionalPropertysSchemas = [];
$moleculeAdditionalPropertys = array(
"annotation_level" => "Annotation level"
);
$moleculeAdditionalPropertys = [
'annotation_level' => 'Annotation level',
];

foreach($moleculeAdditionalPropertys as $key => $value) {
foreach ($moleculeAdditionalPropertys as $key => $value) {
$propertySchema = Schema::PropertyValue();
$propertySchema->name($value)
->value($this->$key);
->value($this->$key);
array_push($additionalPropertysSchemas, $propertySchema);
}

$propertyAdditionalPropertys = array(
"total_atom_count" => "Total atom count",
"aromatic_rings_count" => "Aromatic rings count",
"qed_drug_likeliness" => "QED drug likeliness",
"formal_charge" => "Formal charge",
"contains_sugar" => "Contains sugar",
"np_likeness" => "NP likeness",
"chemical_class" => "Chemical class",
"chemical_sub_class" => "Chemical sub class",
"chemical_super_class" => "Chemical super class",
);

foreach($propertyAdditionalPropertys as $key => $value) {
$propertyAdditionalPropertys = [
'total_atom_count' => 'Total atom count',
'aromatic_rings_count' => 'Aromatic rings count',
'qed_drug_likeliness' => 'QED drug likeliness',
'formal_charge' => 'Formal charge',
'contains_sugar' => 'Contains sugar',
'np_likeness' => 'NP likeness',
'chemical_class' => 'Chemical class',
'chemical_sub_class' => 'Chemical sub class',
'chemical_super_class' => 'Chemical super class',
];

foreach ($propertyAdditionalPropertys as $key => $value) {
$propertySchema = Schema::PropertyValue();
$propertySchema->name($value)
->value($this->properties->$key);
->value($this->properties->$key);
array_push($additionalPropertysSchemas, $propertySchema);
}

if ($this->geo_locations) {
$geo_locations = $this->geo_locations ?? [];
$names = [];
foreach($geo_locations as $geo_location) {
$names = [];
foreach ($geo_locations as $geo_location) {
$name = $geo_location->name;
array_push($names, $name);
}
$propertySchema = Schema::PropertyValue();
$propertySchema->name("Geographic location")
->value($names);
$propertySchema->name('Geographic location')
->value($names);
array_push($additionalPropertysSchemas, $propertySchema);
}

$moleculeSchema->additionalProperty($additionalPropertysSchemas);

$datasetSchema = Schema::Dataset();
$datasetSchema->name($this->name);
$datasetSchema->description('Natural product in the COCONUT database with details of source organisms, geolocations and citations.');
$datasetSchema->license('https://creativecommons.org/licenses/by/4.0/');

$catalogs = [];
if ($this->collections) {
$collections = $this->collections ?? [];
foreach($collections as $collection) {
foreach ($collections as $collection) {
$dataCatalogSchema = Schema::DataCatalog();
$dataCatalogSchema->name("Geographic location")
$dataCatalogSchema->name('Geographic location')
// ->license($collection->licenses->url)
->additionalType("collection")
->description($collection->description)
->identifier($collection->identifier)
->url($collection->url)
->name($collection->title);
->additionalType('collection')
->description($collection->description)
->identifier($collection->identifier)
->url($collection->url)
->name($collection->title);
array_push($catalogs, $dataCatalogSchema);
}
array_push($catalogs, $dataCatalogSchema);
}

$datasetSchema->includedInDataCatalog($catalogs)
->about($moleculeSchema);
->about($moleculeSchema);

$citationsSchemas = [];
if ($this->citations) {
$citations = $this->citations ?? [];
foreach($citations as $citation) {
foreach ($citations as $citation) {
$citationSchema = Schema::CreativeWork();
$citationSchema->identifier($citation->doi)
->headline($citation->title)
->author($citation->authors);
->headline($citation->title)
->author($citation->authors);
array_push($citationsSchemas, $citationSchema);
}
}
$datasetSchema->citation($citationsSchemas);

$contactPoint = Schema::ContactPoint();
$contactPoint->contactType('research inquiries')
->email('[email protected]');

$coconut = Schema::Organization();
$coconut->url('https://coconut.naturalproducts.net/')
->name('COCONUT - COlleCtion of Open Natural prodUcTs')
->contactPoint($contactPoint);

$datasetSchema->creator($coconut);

return $datasetSchema;
}
}
Expand Down
6 changes: 2 additions & 4 deletions resources/views/molecule.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
@section('title', $molecule['identifier'])
@section('meta')
<meta name="description"
content="Natural product identified
@if (isset($molecule->organisms) && $molecule->organisms->count() > 0) in {{ implode(', ', $molecule->organisms->take(2)->pluck('name')->toArray()) }} @endif
content="Natural product identified @if(isset($molecule->organisms) && $molecule->organisms->count() > 0) in {{ implode(', ', $molecule->organisms->take(2)->pluck('name')->toArray()) }} @endif
@if (
(!isset($molecule->organisms) || $molecule->organisms->count() === 0) &&
isset($molecule->collections) &&
Expand All @@ -12,8 +11,7 @@
@elseif(isset($molecule->organisms) &&
$molecule->organisms->count() > 0 &&
isset($molecule->collections) &&
$molecule->collections->count() > 0)
and found in the collection{{ $molecule->collections->count() > 1 ? 's' : '' }}:
$molecule->collections->count() > 0) and found in the collection{{ $molecule->collections->count() > 1 ? 's' : '' }}:
{{ implode(', ', $molecule->collections->pluck('name')->toArray()) }} @endif">
<meta name="keywords" content="{{ implode(',', $molecule->synonyms ?? []) }}">
<meta name="author" content="COCONUT">
Expand Down

0 comments on commit ce4b9f9

Please sign in to comment.