From 0112757c76be78a394ab3c069d91bd19a888ab51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Szeremeta?= Date: Wed, 14 Apr 2021 20:23:39 +0200 Subject: [PATCH] Add schema:url support --- .../java/pl/edu/uwb/ii/sdfeater/Molecule.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/pl/edu/uwb/ii/sdfeater/Molecule.java b/src/main/java/pl/edu/uwb/ii/sdfeater/Molecule.java index 6990b7d..c47ea00 100644 --- a/src/main/java/pl/edu/uwb/ii/sdfeater/Molecule.java +++ b/src/main/java/pl/edu/uwb/ii/sdfeater/Molecule.java @@ -350,7 +350,15 @@ void addToJenaModel(SDFEater.Subject subject) { List values = entry.getValue(); jenaModel.add(me, RDF.type, "http://schema.org/MolecularEntity"); - if ("SMILES".equals(key)) { + if ("ChEBI ID".equals(key)) { + String value = "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=" + values.get(0); + Property p = jenaModel.createProperty("http://schema.org/url"); + jenaModel.add(me, p, value); + } else if ("DATABASE_ID".equals(key) || "DRUGBANK_ID".equals(key)) { + String value = "https://go.drugbank.com/drugs/" + values.get(0); + Property p = jenaModel.createProperty("http://schema.org/url"); + jenaModel.add(me, p, value); + } else if ("SMILES".equals(key)) { String value = values.get(0); Property p = jenaModel.createProperty("http://schema.org/smiles"); jenaModel.add(me, p, value); @@ -408,7 +416,13 @@ StringBuilder constructJSONLDMolecule(SDFEater.Subject subject) { String key = entry.getKey(); List values = entry.getValue(); - if ("SMILES".equals(key)) { + if ("ChEBI ID".equals(key)) { + String value = "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=" + values.get(0); + output_str.append(" \"url\" : ").append(printValueAsNumberOrStringInJSONLD(value)).append(",\n"); + } else if ("DATABASE_ID".equals(key) || "DRUGBANK_ID".equals(key)) { + String value = "https://go.drugbank.com/drugs/" + values.get(0); + output_str.append(" \"url\" : ").append(printValueAsNumberOrStringInJSONLD(value)).append(",\n"); + } else if ("SMILES".equals(key)) { String value = values.get(0); output_str.append(" \"smiles\" : ").append(printValueAsNumberOrStringInJSONLD(value)).append(",\n"); } else if ("Formulae".equals(key) || "FORMULA".equals(key)) { @@ -474,7 +488,13 @@ void printRDFaMolecule(SDFEater.Subject subject) { String key = entry.getKey(); List values = entry.getValue(); - if ("SMILES".equals(key)) { + if ("ChEBI ID".equals(key)) { + String value = "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=" + values.get(0); + output_str.append(" ").append(htmlEscape(value, false)).append("\n"); + } else if ("DATABASE_ID".equals(key) || "DRUGBANK_ID".equals(key)) { + String value = "https://go.drugbank.com/drugs/" + values.get(0); + output_str.append(" ").append(htmlEscape(value, false)).append("\n"); + } else if ("SMILES".equals(key)) { String value = values.get(0); output_str.append("
").append(htmlEscape(value, false)).append("
\n"); } else if ("Formulae".equals(key) || "FORMULA".equals(key)) { @@ -541,7 +561,13 @@ void printMicrodataMolecule(SDFEater.Subject subject) { String key = entry.getKey(); List values = entry.getValue(); - if ("SMILES".equals(key)) { + if ("ChEBI ID".equals(key)) { + String value = "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=" + values.get(0); + output_str.append(" \n"); + } else if ("DATABASE_ID".equals(key) || "DRUGBANK_ID".equals(key)) { + String value = "https://go.drugbank.com/drugs/" + values.get(0); + output_str.append(" \n"); + } else if ("SMILES".equals(key)) { String value = values.get(0); output_str.append("
").append(htmlEscape(value, false)).append("
\n"); } else if ("Formulae".equals(key) || "FORMULA".equals(key)) {