Skip to content

Commit

Permalink
feat: added all the available columns from molecules and properties t…
Browse files Browse the repository at this point in the history
…ables to facilitate api search
  • Loading branch information
sriramkanakam87 committed Dec 2, 2024
1 parent 67af50d commit f93caa5
Show file tree
Hide file tree
Showing 5 changed files with 1,186 additions and 686 deletions.
15 changes: 15 additions & 0 deletions app/Rest/Controllers/PropertiesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Rest\Controllers;

use App\Rest\Controller as RestController;

class PropertiesController extends RestController
{
/**
* The resource the controller corresponds to.
*
* @var class-string<\Lomkit\Rest\Http\Resource>
*/
public static $resource = \App\Rest\Resources\PropertiesResource::class;
}
29 changes: 25 additions & 4 deletions app/Rest/Resources/MoleculeResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Rest\Resources;

use App\Rest\Resource as RestResource;
use Lomkit\Rest\Http\Requests\RestRequest;
use Lomkit\Rest\Relations\HasOne;

class MoleculeResource extends RestResource
{
Expand All @@ -21,11 +23,28 @@ class MoleculeResource extends RestResource
public function fields(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [
'identifier',
'name',
'canonical_smiles',
'standard_inchi',
'standard_inchi_key',
'canonical_smiles',
'sugar_free_smiles',
'identifier',
'name',
'cas',
'iupac_name',
'murko_framework',
'structural_comments',

'name_trust_level',
'annotation_level',
'variants_count',

'status',
'active',
'has_variants',
'has_stereo',
'is_tautomer',
'is_parent',
'is_placeholder',
];
}

Expand All @@ -36,7 +55,9 @@ public function fields(\Lomkit\Rest\Http\Requests\RestRequest $request): array
*/
public function relations(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [];
return [
HasOne::make('properties', PropertiesResource::class),
];
}

/**
Expand Down
117 changes: 117 additions & 0 deletions app/Rest/Resources/PropertiesResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

namespace App\Rest\Resources;

use App\Rest\Resource as RestResource;
use Lomkit\Rest\Relations\HasOne;

class PropertiesResource extends RestResource
{
use \Lomkit\Rest\Concerns\Resource\DisableAuthorizations;

/**
* The model the resource corresponds to.
*
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
public static $model = \App\Models\Properties::class;

/**
* The exposed fields that could be provided
*
* @param RestRequest $request
*/
public function fields(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [
'total_atom_count',
'heavy_atom_count',
'molecular_weight',
'exact_molecular_weight',
'molecular_formula',
'alogp',
'topological_polar_surface_area',
'rotatable_bond_count',
'hydrogen_bond_acceptors',
'hydrogen_bond_donors',
'hydrogen_bond_acceptors_lipinski',
'hydrogen_bond_donors_lipinski',
'lipinski_rule_of_five_violations',
'aromatic_rings_count',
'qed_drug_likeliness',
'formal_charge',
'fractioncsp3',
'number_of_minimal_rings',
'van_der_walls_volume',
'contains_sugar',
'contains_ring_sugars',
'contains_linear_sugars',
'murcko_framework',
'np_likeness',
'chemical_class',
'chemical_sub_class',
'chemical_super_class',
'direct_parent_classification',
'np_classifier_pathway',
'np_classifier_superclass',
'np_classifier_class',
'np_classifier_is_glycoside',
];
}

/**
* The exposed relations that could be provided
*
* @param RestRequest $request
*/
public function relations(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [
HasOne::make('molecule', MoleculeResource::class),
];
}

/**
* The exposed scopes that could be provided
*
* @param RestRequest $request
*/
public function scopes(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [];
}

/**
* The exposed limits that could be provided
*
* @param RestRequest $request
*/
public function limits(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [
10,
25,
50,
];
}

/**
* The actions that should be linked
*
* @param RestRequest $request
*/
public function actions(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [];
}

/**
* The instructions that should be linked
*
* @param RestRequest $request
*/
public function instructions(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return [];
}
}
Loading

0 comments on commit f93caa5

Please sign in to comment.