diff --git a/app/Http/Controllers/API/SearchController.php b/app/Http/Controllers/API/SearchController.php index 681c9e67..f4dd4ff8 100644 --- a/app/Http/Controllers/API/SearchController.php +++ b/app/Http/Controllers/API/SearchController.php @@ -156,7 +156,7 @@ public function search(Request $request) $offset; } elseif ($queryType == 'inchi') { $statement = - "select id, COUNT(*) OVER () from molecules where standard_inchi LIKE '%". + "select id, COUNT(*) OVER () from molecules WHERE identifier NOTNULL AND standard_inchi LIKE '%". $query. "%' limit ". $limit. @@ -164,7 +164,7 @@ public function search(Request $request) $offset; } elseif ($queryType == 'inchikey') { $statement = - "select id, COUNT(*) OVER () from molecules where standard_inchi_key LIKE '%". + "select id, COUNT(*) OVER () from molecules WHERE identifier NOTNULL AND standard_inchi_key LIKE '%". $query. "%' limit ". $limit. @@ -257,7 +257,7 @@ public function search(Request $request) if ($query) { $query = str_replace("'", "''", $query); $statement = - "select id, COUNT(*) OVER () from molecules WHERE (\"name\"::TEXT ILIKE '%". + "select id, COUNT(*) OVER () from molecules WHERE identifier NOTNULL AND (\"name\"::TEXT ILIKE '%". $query. "%') OR (\"synonyms\"::TEXT ILIKE '%". $query. @@ -294,7 +294,7 @@ public function search(Request $request) if ($ids != '') { $statement = - 'SELECT * FROM molecules WHERE ID IN ('. + 'SELECT * FROM molecules WHERE identifier NOTNULL AND ID IN ('. implode( ',', collect($hits) diff --git a/resources/js/Pages/Study/About.vue b/resources/js/Pages/Study/About.vue index 83844b94..a169bf5b 100644 --- a/resources/js/Pages/Study/About.vue +++ b/resources/js/Pages/Study/About.vue @@ -284,13 +284,11 @@
- + >
@@ -607,6 +605,7 @@ import slider from "vue3-slider"; import OCL from "openchemlib/full"; import ToolTip from "@/Shared/ToolTip.vue"; import JetInputError from "@/Jetstream/InputError.vue"; +import Depictor2D from "@/Shared/Depictor2D.vue"; export default { components: { StudyContent, @@ -617,6 +616,7 @@ export default { PencilIcon, InformationCircleIcon, JetInputError, + Depictor2D, }, props: [ "study", @@ -702,7 +702,7 @@ export default { }); }, editMolecule(mol) { - this.editor.setMolFile("\n " + mol.MOL.replaceAll('"', "")); + this.editor.setSmiles(mol.canonical_smiles); this.percentage = parseInt(mol.pivot.percentage_composition); axios .delete( @@ -715,36 +715,39 @@ export default { this.study.sample.molecules = res.data; }); }, - saveMolecule() { - let mol = this.editor.getMolFile(); + saveMolecule(mol, study) { + if (!study) { + study = this.study; + } + if (!mol) { + let mol = this.editor.getMolFile(); + this.standardizeMolecules(mol).then((res) => { + this.associateMoleculeToStudy(res.data, study); + }); + } else { + this.associateMoleculeToStudy(mol, study); + } + }, + standardizeMolecules(mol) { + return axios.post( + "https://api.naturalproducts.net/latest/chem/standardize", + mol + ); + }, + associateMoleculeToStudy(mol, study) { axios - .post( - "https://www.cheminfo.org/webservices/inchi", - "molfile=" + mol - ) - .then((response) => { - let InChI = response.data.output.InChI; - let InChIKey = response.data.output.InChIKey; - let MF = this.editor - .getMolecule() - .getMolecularFormula().formula; - axios - .post( - "/dashboard/studies/" + this.study.id + "/molecule", - { - InChI: InChI, - InChIKey: InChIKey, - percentage: this.percentage, - formula: MF, - mol: mol, - } - ) - .then((res) => { - this.study.sample.molecules = res.data; - this.smiles = ""; - this.percentage = 0; - this.editor.setSmiles(""); - }); + .post("/dashboard/studies/" + study.id + "/molecule", { + InChI: mol.inchi, + InChIKey: mol.inchikey, + percentage: 0, + mol: mol.standardized_mol, + canonical_smiles: mol.canonical_smiles, + }) + .then((res) => { + study.sample.molecules = res.data; + this.smiles = ""; + this.percentage = 0; + // this.editor.setSmiles(""); }); }, }, diff --git a/resources/js/Pages/Upload.vue b/resources/js/Pages/Upload.vue index c9131258..9b5ca7d2 100644 --- a/resources/js/Pages/Upload.vue +++ b/resources/js/Pages/Upload.vue @@ -2883,12 +2883,12 @@ export default { }, standardizeMolecules(mol) { return axios.post( - "https://dev.api.naturalproducts.net/latest/chem/standardize", + "https://api.naturalproducts.net/latest/chem/standardize", mol ); }, editMolecule(mol) { - this.editor.setMolFile(mol.MOL); + this.editor.setSmiles(mol.canonical_smiles); this.percentage = parseInt(mol.pivot.percentage_composition); axios .delete(