Skip to content

Commit

Permalink
Merge pull request #242 from Steinbeck-Lab/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
CS76 authored Sep 11, 2024
2 parents 0ba3726 + 50dda62 commit 8a35a45
Show file tree
Hide file tree
Showing 71 changed files with 26,447 additions and 109 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ COCONUT data curation and descriptors calculation are performed using our [micro

COCONUT infrastructure code is licensed under the MIT license - see the [LICENSE](https://GitHub.com/Steinbeck-Lab/coconut/blob/documentation/LICENSE). Every source on COCONUT comes with its own specific license. It is essential to review the license details for each dataset before using it.

## ![Citation](https://www.google.com/s2/favicons?domain=doi.org) COCONUT (Legacy) - Citation
## ![Citations](https://www.google.com/s2/favicons?domain=doi.org)Citations

Sorokina, M., Merseburger, P., Rajan, K. et al. COCONUT online: COlleCtion of Open Natural prodUcTs database. J Cheminform 13, 2 (2021). https://doi.org/10.1186/s13321-020-00478-9
### COCONUT (Legacy)
- Sorokina, M., Merseburger, P., Rajan, K. et al. (2021). COCONUT online: COlleCtion of Open Natural prodUcTs database. *Journal of Cheminformatics*, 13, 2.
https://doi.org/10.1186/s13321-020-00478-9

### COCONUT 2.0
- Nainala, V.C., Rajan, K., Kanakam, S.R.S., Sharma, N., Weißenborn, V., Schaub, J., et al. (2024). COCONUT 2.0: A comprehensive overhaul and curation of the collection of open natural products database. *ChemRxiv*.
https://doi.org/10.26434/chemrxiv-2024-fxq2s

## ![Maintained](https://www.google.com/s2/favicons?domain=uni-jena.de) Maintained by

Expand Down
18 changes: 9 additions & 9 deletions app/Console/Commands/DashWidgetsRefresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,49 @@ public function handle()
// Cache::flush();

// Create the cache for all DashboardStats widgets
Cache::rememberForever('stats.collections', function () {
Cache::remember('stats.collections', 172800, function () {
return DB::table('collections')->selectRaw('count(*)')->get()[0]->count;
});
$this->info('Cache for collections refreshed.');

Cache::rememberForever('stats.citations', function () {
Cache::remember('stats.citations', 172800, function () {
return DB::table('citations')->selectRaw('count(*)')->get()[0]->count;
});
$this->info('Cache for citations refreshed.');

Cache::rememberForever('stats.organisms', function () {
Cache::remember('stats.organisms', 172800, function () {
return DB::table('organisms')->selectRaw('count(*)')->get()[0]->count;
});
$this->info('Cache for organisms refreshed.');

Cache::rememberForever('stats.geo_locations', function () {
Cache::remember('stats.geo_locations', 172800, function () {
return DB::table('geo_locations')->selectRaw('count(*)')->get()[0]->count;
});
$this->info('Cache for geo locations refreshed.');

Cache::rememberForever('stats.reports', function () {
Cache::remember('stats.reports', 172800, function () {
return DB::table('reports')->selectRaw('count(*)')->get()[0]->count;
});
$this->info('Cache for reports refreshed.');

// Create the cache for all DashboardStatsMid widgets

Cache::rememberForever('stats.molecules.non_stereo', function () {
Cache::remember('stats.molecules.non_stereo', 172800, function () {
return DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=false and is_parent=false')->get()[0]->count;
});
$this->info('Cache for molecules non-stereo refreshed.');

Cache::rememberForever('stats.molecules.stereo', function () {
Cache::remember('stats.molecules.stereo', 172800, function () {
return DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=true')->get()[0]->count;
});
$this->info('Cache for molecules stereo refreshed.');

Cache::rememberForever('stats.molecules.parent', function () {
Cache::remember('stats.molecules.parent', 172800, function () {
return DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=false and is_parent=true')->get()[0]->count;
});
$this->info('Cache for molecules parent refreshed.');

Cache::rememberForever('stats.molecules', function () {
Cache::remember('stats.molecules', 172800, function () {
return DB::table('molecules')->selectRaw('count(*)')->whereRaw('active=true and NOT (is_parent=true AND has_variants=true)')->get()[0]->count;
});
$this->info('Cache for molecules refreshed.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function getStats(): array
return [
// Commented is the model query that we can use in case we decide not to use app level caching as the app scales up.

// Stat::make('Entries', Cache::rememberForever('stats.collections'.$this->record->id.'entries.count', function () {
// Stat::make('Entries', Cache::remember('stats.collections'.$this->record->id.'entries.count', 172800, function () {
// return DB::table('entries')->selectRaw('count(*)')->whereRaw('collection_id='.$this->record->id)->get()[0]->count;
// }))
// ->description('Total count')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class MoleculeStats extends BaseWidget
protected function getStats(): array
{
return [
Stat::make('Total Organisms', Cache::rememberForever('stats.molecules'.$this->record->id.'organisms.count', function () {
Stat::make('Total Organisms', Cache::remember('stats.molecules'.$this->record->id.'organisms.count', 172800, function () {
return DB::table('molecule_organism')->selectRaw('count(*)')->whereRaw('molecule_id='.$this->record->id)->get()[0]->count;
})),
Stat::make('Total Geo Locations', Cache::rememberForever('stats.molecules'.$this->record->id.'geo_locations.count', function () {
Stat::make('Total Geo Locations', Cache::remember('stats.molecules'.$this->record->id.'geo_locations.count', 172800, function () {
return DB::table('geo_location_molecule')->selectRaw('count(*)')->whereRaw('molecule_id='.$this->record->id)->get()[0]->count;
})),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class OrganismStats extends BaseWidget
protected function getStats(): array
{
return [
Stat::make('Total Molecules', Cache::rememberForever('stats.organisms'.$this->record->id.'molecules.count', function () {
Stat::make('Total Molecules', Cache::remember('stats.organisms'.$this->record->id.'molecules.count', 172800, function () {
return DB::table('molecule_organism')->selectRaw('count(*)')->whereRaw('organism_id='.$this->record->id)->get()[0]->count;
})),
Stat::make('Total Geo Locations', Cache::rememberForever('stats.organisms'.$this->record->id.'geo_locations.count', function () {
Stat::make('Total Geo Locations', Cache::remember('stats.organisms'.$this->record->id.'geo_locations.count', 172800, function () {
return DB::table('molecule_organism')->selectRaw('count(*)')->whereRaw('organism_id='.$this->record->id)->Join('geo_location_molecule', 'molecule_organism.molecule_id', '=', 'geo_location_molecule.molecule_id')->get()[0]->count;
})),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MolecularEntityController extends Controller
{
public function moleculeSchema(Request $request, $identifier)
{
$molecule = Cache::rememberForever('molecules.'.$identifier, function () use ($identifier) {
$molecule = Cache::remember('molecules.'.$identifier, 172800, function () use ($identifier) {
return Molecule::where('identifier', $identifier)->first();
});

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/MoleculeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __invoke(Request $request, $id)
$id .= '.0';
}

$molecule = Cache::rememberForever('molecules.'.$id, function () use ($id) {
$molecule = Cache::remember('molecules.'.$id, 172800, function () use ($id) {
return Molecule::where('identifier', $id)->first();
});

Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/DataSources.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DataSources extends Component

public function mount()
{
$this->collections = Cache::rememberForever('collections', function () {
$this->collections = Cache::remember('collections', 172800, function () {
return Collection::where('promote', true)->orderBy('sort_order')->take(10)->get(['title', 'image'])->toArray();
});
}
Expand Down
6 changes: 6 additions & 0 deletions app/Livewire/MoleculeDepict2d.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public function source()
return env('CM_API').'depict/2D?smiles='.urlencode($this->smiles).'&height='.$this->height.'&width='.$this->width;
}

#[Computed]
public function preview()
{
return env('CM_API').'depict/2D?smiles='.urlencode($this->smiles);
}

public function render()
{
return view('livewire.molecule-depict2d');
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/MoleculeDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function rendered()
$_molecule = Cache::get('molecules.'.$id);
if (! $_molecule->relationLoaded('properties')) {
Cache::forget('molecules.'.$id);
Cache::rememberForever('molecules.'.$id, function () use ($molecule) {
Cache::remember('molecules.'.$id, 172800, function () use ($molecule) {
$molecule['schema'] = $molecule->getSchema();

return $molecule;
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/RecentMolecules.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RecentMolecules extends Component
public function render()
{
return view('livewire.recent-molecules', [
'molecules' => Cache::rememberForever('molecules.recent', function () {
'molecules' => Cache::remember('molecules.recent', 172800, function () {
return Molecule::where('is_parent', false)->where('active', true)->where('name', '!=', null)->where('annotation_level', '=', 5)->orderByDesc('updated_at')->paginate($this->size);
}),
]);
Expand Down
2 changes: 1 addition & 1 deletion config/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'authorizations' => [
'enabled' => true,
'cache' => [
'enabled' => true,
'enabled' => false,
'default' => 5, // Cache minutes by default
],
],
Expand Down
Loading

0 comments on commit 8a35a45

Please sign in to comment.