Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
7 plugins/net.bioclipse.ds.chemspider/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
28 plugins/net.bioclipse.ds.chemspider/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.bioclipse.ds.chemspider</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
23 plugins/net.bioclipse.ds.chemspider/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Chemspider DS
+Bundle-SymbolicName: net.bioclipse.ds.chemspider;singleton:=true
+Bundle-Version: 0.2.0
+Bundle-Vendor: bioclipse.net
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.help,
+ net.bioclipse.ds,
+ net.bioclipse.cdk.ui.sdfeditor,
+ net.bioclipse.cdk.business,
+ net.bioclipse.core,
+ net.bioclipse.ds.common,
+ net.bioclipse.ds.ui,
+ org.openscience.cdk.interfaces,
+ org.openscience.cdk.standard,
+ org.openscience.cdk.io,
+ org.openscience.cdk.nonotify,
+ net.bioclipse.chemspider;bundle-version="2.5.0",
+ net.bioclipse.rdf;bundle-version="2.5.0"
+Import-Package: org.apache.log4j
View
6 plugins/net.bioclipse.ds.chemspider/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
View
BIN  plugins/net.bioclipse.ds.chemspider/icons/cs-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
26 plugins/net.bioclipse.ds.chemspider/plugin.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="net.bioclipse.decisionsupport">
+
+ <endpoint
+ id="net.bioclipse.ds.chemspider"
+ description="Chemspider lookup"
+ icon="icons/cs-icon.png"
+ name="Chemspider+ChEMBL">
+ </endpoint>
+
+ <test
+ id="chemspider.nearest"
+ name="Chemspider nearest neighbour"
+ endpoint="net.bioclipse.ds.chemspider"
+ class="net.bioclipse.ds.chemspider.SimilaritySearchModel"
+ consensus="net.bioclipse.ds.consensus.majority.emptyinconclusive">
+
+ <parameter name="distance.tanimoto" value="0.8" />
+
+ </test>
+</extension>
+
+</plugin>
View
71 plugins/net.bioclipse.ds.chemspider/src/net/bioclipse/ds/chemspider/ChemblInteraction.java
@@ -0,0 +1,71 @@
+package net.bioclipse.ds.chemspider;
+
+public class ChemblInteraction {
+
+ String title;
+ String value;
+ String unit;
+ String targetType;
+ String interactionType;
+ String relation;
+ String description;
+
+ public String getTitle() {
+ return title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public String getValue() {
+ return value;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
+ public String getUnit() {
+ return unit;
+ }
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+ public String getTargetType() {
+ return targetType;
+ }
+ public void setTargetType(String targetType) {
+ this.targetType = targetType;
+ }
+ public String getInteractionType() {
+ return interactionType;
+ }
+ public void setInteractionType(String interactionType) {
+ this.interactionType = interactionType;
+ }
+ public String getRelation() {
+ return relation;
+ }
+ public void setRelation(String relation) {
+ this.relation = relation;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public ChemblInteraction(String value, String unit, String interactionType) {
+ super();
+ this.value = value;
+ this.unit = unit;
+ this.interactionType = interactionType;
+ }
+ @Override
+ public String toString() {
+ return "ChemblInteraction [title=" + title + ", value=" + value
+ + ", unit=" + unit + ", targetType=" + targetType
+ + ", interactionType=" + interactionType + ", relation="
+ + relation + ", description=" + description + "]";
+ }
+
+
+}
View
98 plugins/net.bioclipse.ds.chemspider/src/net/bioclipse/ds/chemspider/ChemblLookup.java
@@ -0,0 +1,98 @@
+package net.bioclipse.ds.chemspider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.bioclipse.core.business.BioclipseException;
+import net.bioclipse.core.domain.IStringMatrix;
+import net.bioclipse.rdf.Activator;
+import net.bioclipse.rdf.business.IRDFManager;
+
+/**
+ * Look up interactions in ChEMBL-rdf for a given Chemspider ID
+ *
+ * @author Ola Spjuth
+ *
+ */
+public class ChemblLookup {
+
+ public static List<ChemblInteraction> lookupCSID(Integer csid) throws BioclipseException{
+
+ IRDFManager rdf = Activator.getDefault().getJavaManager();
+ String endpoint = "http://rdf.farmbio.uu.se/chembl/sparql";
+
+ //10368587 is one example
+
+ String query =
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
+ "PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
+ "PREFIX dc: <http://purl.org/dc/elements/1.1/>"+
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/>"+
+ "PREFIX chembl: <http://rdf.farmbio.uu.se/chembl/onto/#>"+
+ "PREFIX bo: <http://www.blueobelisk.org/chemistryblogs/>"+
+ "PREFIX bibo: <http://purl.org/ontology/bibo/>"+
+ "PREFIX cito: <http://purl.org/spar/cito/>"+
+ "PREFIX cheminf: <http://semanticscience.org/resource/>"+
+ "PREFIX pro: <http://purl.obolibrary.org/obo/>"+
+ "PREFIX skos: <http://www.w3.org/2004/02/skos/core#>"+
+
+ "SELECT ?val ?units ?targetType ?title ?interactionType ?relation ?description ?assay WHERE {"+
+ "?csid <http://semanticscience.org/resource/SIO_000300> " + csid + " ."+
+ "?chembl cheminf:CHEMINF_000200 ?csid ."+
+ "?mol owl:equivalentClass ?chembl ."+
+ "?act chembl:forMolecule ?mol ."+
+ "?act chembl:standardValue ?val ."+
+ "FILTER (?val < 100000)"+
+ "?act chembl:standardUnits ?units ."+
+ "?act chembl:onAssay ?assay ."+
+ "?act chembl:type ?interactionType ."+
+ "?assay chembl:hasTarget ?target ."+
+ "?assay chembl:hasDescription ?description ."+
+ "?target dc:title ?title ."+
+ "OPTIONAL { ?target chembl:classL1 ?targetType . }"+
+ "OPTIONAL { ?act chembl:relation ?relation . }"+
+ "}";
+
+ IStringMatrix res = rdf.sparqlRemote(endpoint, query);
+
+// System.out.println(res);
+
+ if (res.getColumnCount()<=0)
+ return null;
+
+ System.out.println("Got " + res.getRowCount() + " hits for CSID=" + csid);
+
+ List<ChemblInteraction> interactions = new ArrayList<ChemblInteraction>();
+ for (int i=0; i < res.getRowCount(); i++){
+ String value = res.getColumn("val").get(i);
+ String unit = res.getColumn("units").get(i);
+ String inttype = res.getColumn("interactionType").get(i);
+ String targetType = res.getColumn("targetType").get(i);
+ String title = res.getColumn("title").get(i);
+ String interactionType = res.getColumn("interactionType").get(i);
+ String relation = res.getColumn("relation").get(i);
+ String description = res.getColumn("description").get(i);
+ String assay = res.getColumn("assay").get(i);
+
+ value=value.substring(0,value.indexOf("^^"));
+ if (null==title || title.length()<=0)
+ title=assay.substring(assay.lastIndexOf("/")+1);
+
+ ChemblInteraction interaction = new ChemblInteraction(value, unit, inttype);
+
+ interaction.setTitle(title);
+ interaction.setRelation(relation);
+ interaction.setTargetType(targetType);
+ interaction.setInteractionType(interactionType);
+ interaction.setDescription(description);
+
+ interactions.add(interaction);
+// System.out.println(interaction);
+
+ }
+
+ return interactions;
+ }
+
+}
View
155 plugins/net.bioclipse.ds.chemspider/src/net/bioclipse/ds/chemspider/SimilaritySearchModel.java
@@ -0,0 +1,155 @@
+package net.bioclipse.ds.chemspider;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import net.bioclipse.cdk.business.ICDKManager;
+import net.bioclipse.cdk.domain.ICDKMolecule;
+import net.bioclipse.chemspider.Activator;
+import net.bioclipse.chemspider.business.IChemspiderManager;
+import net.bioclipse.core.business.BioclipseException;
+import net.bioclipse.ds.model.AbstractDSTest;
+import net.bioclipse.ds.model.DSException;
+import net.bioclipse.ds.model.ITestResult;
+import net.bioclipse.ds.model.result.ExternalMoleculeMatch;
+
+/**
+ * Model for DS based on ChemSpider SimilaritySearch.
+ *
+ * @author Ola Spjuth
+ *
+ */
+public class SimilaritySearchModel extends AbstractDSTest{
+
+ private static final String TANIMOTO_DISTANCE = "distance.tanimoto";
+ private static final int MAX_NEIGHBORS = 15;
+
+
+ private static final Logger logger = Logger.getLogger(SimilaritySearchModel.class);
+
+ private float tanimoto;
+ DecimalFormat formatter = new DecimalFormat( "0.00" );
+
+ @Override
+ public List<String> getRequiredParameters() {
+ List<String> ret=new ArrayList<String>();
+ ret.add( TANIMOTO_DISTANCE );
+ return ret;
+ }
+
+ @Override
+ public void initialize(IProgressMonitor monitor) throws DSException {
+ super.initialize(monitor);
+
+ tanimoto=Float.parseFloat(getParameters().get(TANIMOTO_DISTANCE));
+ logger.debug("Chemspider similaritysearch is using tanimoto: " + tanimoto);
+
+ }
+
+
+ @Override
+ protected List<? extends ITestResult> doRunTest(ICDKMolecule molecule,
+ IProgressMonitor monitor) {
+
+ //Managers we need
+ IChemspiderManager chemspider = Activator.getDefault().getJavaChemspiderManager();
+ ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();
+
+ //Hold results here
+ ArrayList<ExternalMoleculeMatch> results = new ArrayList<ExternalMoleculeMatch>();
+
+ //Do chemspider search
+ List<ICDKMolecule> resultMols=null;
+ try {
+ resultMols = chemspider.similaritySearch(molecule, tanimoto, monitor);
+ } catch (BioclipseException e1) {
+ return returnError("Service failed to complete. Incorrect security token?", e1.getMessage());
+ }
+ if (resultMols==null)
+ return returnError("Null results","");
+ logger.debug("Model " + getName() + " had " + resultMols.size() + " hits");
+
+// List<ICDKMolecule> resultMols = new ArrayList<ICDKMolecule>();
+// try {
+// resultMols.add(cdk.fromSMILES("CCC"));
+// } catch (BioclipseException e1) {
+// e1.printStackTrace();
+// }
+
+ //Set up results, reduce to max 15 results
+ logger.debug("Setting up results...");
+ for (ICDKMolecule cdkmol : resultMols.subList(0, Math.min(resultMols.size(), MAX_NEIGHBORS))){
+
+ //We calculate tanimoto locally for now
+ String distance = "N/A";
+ try {
+ distance = "" + formatter.format(cdk.calculateTanimoto(molecule, cdkmol));
+ } catch (BioclipseException e) {
+ logger.error("Could not calculate tanimoto: " + e.getMessage());
+ }
+
+ //Get name and other params from stored props on mol, set in chemspider manager
+ String molname=(String) cdkmol.getProperty("chemspider.commonname", null);
+
+ logger.debug("Hit: " + molname + " ; distance: " + distance);
+
+ ExternalMoleculeMatch match = new ExternalMoleculeMatch(molname + " (tanimoto=" + distance + ")" , cdkmol,
+ ITestResult.INFORMATIVE);
+
+ Map<String, Map<String, String>> categories = new HashMap<String, Map<String,String>>();
+ Map<String,String> props = new HashMap<String, String>();
+ Integer csid = (Integer) cdkmol.getProperty("chemspider.id", null);
+ props.put("Chemspider ID" , "" + csid);
+ props.put("InChI" , "" + cdkmol.getProperty("chemspider.inchi", null));
+ props.put("InChIkey" , "" + cdkmol.getProperty("chemspider.inchikey", null));
+ props.put("AlogP" , "" + cdkmol.getProperty("chemspider.alogp", null));
+ props.put("XlogP" , "" + cdkmol.getProperty("chemspider.xlogp", null));
+ props.put("Average mass" , "" + cdkmol.getProperty("chemspider.averagemass", null));
+ props.put("Molecular formula" , "" + cdkmol.getProperty("chemspider.mf", null));
+ props.put("Molecular wheight" , "" + cdkmol.getProperty("chemspider.mw", null));
+ props.put("Monoisotopic mass" , "" + cdkmol.getProperty("chemspider.monoisotopicmass", null));
+ props.put("Nominal mass" , "" + cdkmol.getProperty("chemspider.nominalmass", null));
+ categories.put("Chemspider", props);
+
+ //Look up interactions in ChEMBL
+ try {
+ List<ChemblInteraction> chemblInteractions = ChemblLookup.lookupCSID(csid);
+// List<ChemblInteraction> chemblInteractions = ChemblLookup.lookupCSID(10368587);
+
+ if (chemblInteractions!=null){
+ for (ChemblInteraction ci : chemblInteractions){
+ Map<String,String> ciprops = new HashMap<String, String>();
+ if (ci.getRelation()!=null)
+ ciprops.put("Value" , ci.getRelation() + ci.getValue());
+ else
+ ciprops.put("Value" , ci.getValue());
+ ciprops.put("Unit" , ci.getUnit());
+ ciprops.put("Target type" , ci.getTargetType());
+ ciprops.put("Interaction type" , ci.getInteractionType());
+ ciprops.put("Description" , ci.getDescription());
+
+ categories.put("Target: " + ci.getTitle(), ciprops);
+ }
+ }
+ else{
+ logger.debug("No ChEMBL interactions for CID=" + csid);
+ }
+
+ } catch (BioclipseException e) {
+ logger.error("Error querying chembl: " + e.getMessage());
+ }
+
+ match.setProperties(categories);
+ results.add(match);
+ }
+
+ return results;
+ }
+
+}
View
8 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/MoleculeResultPropertySource.java
@@ -27,9 +27,9 @@
private Object SimplePropertiesTable[][] =
{
- { NAME, new TextPropertyDescriptor(NAME,"Name")},
- { TEST, new TextPropertyDescriptor(TEST,"Test")},
- { CLASSIFICATION, new TextPropertyDescriptor(CLASSIFICATION,CLASSIFICATION)},
+ { NAME, new PropertyDescriptor(NAME,"Name")},
+ { TEST, new PropertyDescriptor(TEST,"Test")},
+ { CLASSIFICATION, new PropertyDescriptor(CLASSIFICATION,CLASSIFICATION)},
};
public MoleculeResultPropertySource(ExternalMoleculeMatch item) {
@@ -70,7 +70,7 @@ else if (item.getClassification()==ITestResult.ERROR)
for (String name : catprops.keySet()){
String value = catprops.get(name);
- PropertyDescriptor descriptor = new TextPropertyDescriptor(category+"_" + name, name);
+ PropertyDescriptor descriptor = new PropertyDescriptor(category+"_" + name, name);
descriptor.setCategory(category);
getProperties().add(descriptor);
addToValueMap(category+"_" + name,value);

No commit comments for this range

Something went wrong with that request. Please try again.