Skip to content

Commit

Permalink
Add schema:url support
Browse files Browse the repository at this point in the history
  • Loading branch information
lszeremeta committed Apr 14, 2021
1 parent 610d0ca commit 0112757
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/main/java/pl/edu/uwb/ii/sdfeater/Molecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,15 @@ void addToJenaModel(SDFEater.Subject subject) {
List<String> 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);
Expand Down Expand Up @@ -408,7 +416,13 @@ StringBuilder constructJSONLDMolecule(SDFEater.Subject subject) {
String key = entry.getKey();
List<String> 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)) {
Expand Down Expand Up @@ -474,7 +488,13 @@ void printRDFaMolecule(SDFEater.Subject subject) {
String key = entry.getKey();
List<String> 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(" <a href='").append(htmlEscape(value, true)).append("' rel='schema:url'>").append(htmlEscape(value, false)).append("</a>\n");
} else if ("DATABASE_ID".equals(key) || "DRUGBANK_ID".equals(key)) {
String value = "https://go.drugbank.com/drugs/" + values.get(0);
output_str.append(" <a href='").append(htmlEscape(value, true)).append("' rel='schema:url'>").append(htmlEscape(value, false)).append("</a>\n");
} else if ("SMILES".equals(key)) {
String value = values.get(0);
output_str.append(" <div property='schema:smiles'>").append(htmlEscape(value, false)).append("</div>\n");
} else if ("Formulae".equals(key) || "FORMULA".equals(key)) {
Expand Down Expand Up @@ -541,7 +561,13 @@ void printMicrodataMolecule(SDFEater.Subject subject) {
String key = entry.getKey();
List<String> 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(" <a href='").append(htmlEscape(value, true)).append("' itemprop='url'>").append(htmlEscape(value, false)).append("</a>\n");
} else if ("DATABASE_ID".equals(key) || "DRUGBANK_ID".equals(key)) {
String value = "https://go.drugbank.com/drugs/" + values.get(0);
output_str.append(" <a href='").append(htmlEscape(value, true)).append("' itemprop='url'>").append(htmlEscape(value, false)).append("</a>\n");
} else if ("SMILES".equals(key)) {
String value = values.get(0);
output_str.append(" <div itemprop='smiles'>").append(htmlEscape(value, false)).append("</div>\n");
} else if ("Formulae".equals(key) || "FORMULA".equals(key)) {
Expand Down

0 comments on commit 0112757

Please sign in to comment.