From dad8244909bf1556e8e7bd068bf98083fe1252e1 Mon Sep 17 00:00:00 2001 From: Egon Willighagen Date: Sun, 23 Jul 2023 16:30:26 +0200 Subject: [PATCH] Like *Label, *ChemicalStructure is a new special, expects a SMILES and will use CDK Depict (Toolforge) to visualize the chemical structure in 2D --- scholia/app/static/scholia.js | 9 +++++++++ scholia/app/templates/taxon_metabolome.sparql | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scholia/app/static/scholia.js b/scholia/app/static/scholia.js index 7e9b34fd0..0602252f0 100644 --- a/scholia/app/static/scholia.js +++ b/scholia/app/static/scholia.js @@ -85,6 +85,8 @@ function convertDataTableData(data, columns) { var column = columns[i]; if (column.slice(-11) == 'Description') { convertedColumns.push(column.slice(0, column.length - 11) + ' description'); + } else if (column.slice(-17) == 'ChemicalStructure') { + convertedColumns.push(column.slice(0, column.length - 17) + ' structure'); } else if (column.slice(-5) == 'Label') { // pass } else if (column.slice(-3) == 'Url') { @@ -107,6 +109,13 @@ function convertDataTableData(data, columns) { data[i][key + 'Url'] + '">' + data[i][key + 'Label'] + ''; + } else if (key.slice(-17) == 'ChemicalStructure') { + convertedRow[key.slice(0, key.length - 17) + ' structure'] = ''; + } else if ( key + 'Label' in data[i] && /^http/.test(data[i][key]) && diff --git a/scholia/app/templates/taxon_metabolome.sparql b/scholia/app/templates/taxon_metabolome.sparql index 165c37554..c5516e0c9 100644 --- a/scholia/app/templates/taxon_metabolome.sparql +++ b/scholia/app/templates/taxon_metabolome.sparql @@ -1,20 +1,23 @@ PREFIX target: SELECT DISTINCT - ?metabolite ?metaboliteLabel ?metaboliteDescription + ?metabolite ?metaboliteLabel ?metaboliteChemicalStructure ?metaboliteDescription WITH { SELECT DISTINCT ?children WHERE { ?children (wdt:P171*) target:. } } AS %taxa WITH { - SELECT DISTINCT ?metabolite WHERE { + SELECT DISTINCT ?metabolite ?metaboliteChemicalStructure WHERE { INCLUDE %taxa { ?metabolite wdt:P703 ?children } UNION { ?metabolite wdt:P1582 ?children } VALUES ?chemical { wd:Q11173 wd:Q59199015 wd:Q56256086 wd:Q15711994 }. ?metabolite wdt:P31|wdt:P279/wdt:P31 ?chemical . + OPTIONAL { ?metabolite wdt:P233 ?canSmiles } + OPTIONAL { ?metabolite wdt:P2017 ?isoSmiles } + BIND(COALESCE(?isoSmiles, ?canSmiles) AS ?metaboliteChemicalStructure) } } AS %results { INCLUDE %results