Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Like *Label, *ChemicalStructure is a new special, expects a SMILES and will use CDK Depict (Toolforge) to visualize the chemical structure in 2D #2309

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scholia/app/static/scholia.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -107,6 +109,13 @@ function convertDataTableData(data, columns) {
data[i][key + 'Url'] +
'">' + data[i][key + 'Label'] + '</a>';

} else if (key.slice(-17) == 'ChemicalStructure') {
convertedRow[key.slice(0, key.length - 17) + ' structure'] = '<img loading="lazy" src="' +
'https://cdkdepict.toolforge.org/depict/bow/svg?smi=' +
encodeURIComponent(data[i][key]) +
'&abbr=on&hdisp=bridgehead&showtitle=false&zoom=2&annotate=cip' +
'" />';

} else if (
key + 'Label' in data[i] &&
/^http/.test(data[i][key]) &&
Expand Down
7 changes: 5 additions & 2 deletions scholia/app/templates/taxon_metabolome.sparql
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>

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
Expand Down