Permalink
Browse files

Added more methods to get information from the ontology

  • Loading branch information...
1 parent 04811a1 commit 5214c727321b8c4133d9fd070664507d96058bd0 @egonw egonw committed with olas Nov 12, 2010
@@ -19,7 +19,31 @@
*/
package net.bioclipse.opentox.api;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.bioclipse.rdf.business.RDFManager;
+import net.bioclipse.rdf.model.IStringMatrix;
+
public abstract class Algorithm {
+ private static RDFManager rdf = new RDFManager();
+
+ public static Map<String,String> getProperties(String service, String feature) {
+ String propertiesQuery =
+ "select ?pred ?value where {" +
+ " <" + feature + "> ?pred ?value" +
+ "}";
+ Map<String,String> properties = new HashMap<String, String>();
+ IStringMatrix matrix = rdf.sparqlRemote(service, propertiesQuery , null);
+ for (int i=0; i<matrix.getRowCount(); i++) {
+ String predicate = matrix.get(i, "pred");
+ String value = matrix.get(i, "value");
+ if (predicate != null && predicate.length() > 0 &&
+ value != null && value.length() > 0)
+ properties.put(predicate, value);
+ }
+ return properties;
+ }
}
@@ -0,0 +1,49 @@
+/* Copyright (C) 2010 Egon Willighagen <egonw@users.sf.net>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version. All we ask is that proper credit is given for our work,
+ * which includes - but is not limited to - adding the above copyright notice to
+ * the beginning of your source code files, and to any copyright notice that you
+ * may distribute with programs based on this work.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package net.bioclipse.opentox.api;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.bioclipse.rdf.business.RDFManager;
+import net.bioclipse.rdf.model.IStringMatrix;
+
+public abstract class Model {
+
+ private static RDFManager rdf = new RDFManager();
+
+ public static Map<String,String> getProperties(String service, String feature) {
+ String propertiesQuery =
+ "select ?pred ?value where {" +
+ " <" + feature + "> ?pred ?value" +
+ "}";
+ Map<String,String> properties = new HashMap<String, String>();
+ IStringMatrix matrix = rdf.sparqlRemote(service, propertiesQuery , null);
+ for (int i=0; i<matrix.getRowCount(); i++) {
+ String predicate = matrix.get(i, "pred");
+ String value = matrix.get(i, "value");
+ if (predicate != null && predicate.length() > 0 &&
+ value != null && value.length() > 0)
+ properties.put(predicate, value);
+ }
+ return properties;
+ }
+
+}
@@ -11,6 +11,7 @@
package net.bioclipse.opentox.business;
import java.util.List;
+import java.util.Map;
import net.bioclipse.core.PublishedClass;
import net.bioclipse.core.PublishedMethod;
@@ -68,11 +69,59 @@
@Recorded
@PublishedMethod(
methodSummary=
+ "Lists the available information on the feature from the ontology server.",
+ params="String service, String feature"
+ )
+ public Map<String,String> getFeatureInfo(String service, String feature);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Lists the available information on the feature from the ontology server.",
+ params="String service, List<String> features"
+ )
+ public Map<String,Map<String,String>> getFeatureInfo(String service, List<String> features);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Lists the available information on the model from the ontology server.",
+ params="String service, String model"
+ )
+ public Map<String,String> getModelInfo(String service, String model);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Lists the available information on the models from the ontology server.",
+ params="String service, List<String> models"
+ )
+ public Map<String,Map<String,String>> getModelInfo(String service, List<String> models);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Lists the available information on the algorithm from the ontology server.",
+ params="String service, String algorithm"
+ )
+ public Map<String,String> getAlgorithmInfo(String service, String algorithm);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Lists the available information on the algorithm from the ontology server.",
+ params="String service, List<String> algorithms"
+ )
+ public Map<String,Map<String,String>> getAlgorithmInfo(String service, List<String> algorithms);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
"Lists the algorithms available from the given service.",
params="String service"
)
public List<String> listAlgorithms(String service);
-
+
@Recorded
@PublishedMethod(
methodSummary=
@@ -11,14 +11,19 @@
package net.bioclipse.opentox.business;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import net.bioclipse.business.BioclipsePlatformManager;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IMolecule;
import net.bioclipse.jobs.IReturner;
import net.bioclipse.managers.business.IBioclipseManager;
+import net.bioclipse.opentox.api.Algorithm;
import net.bioclipse.opentox.api.Dataset;
+import net.bioclipse.opentox.api.Feature;
+import net.bioclipse.opentox.api.Model;
import net.bioclipse.opentox.api.ModelAlgorithm;
import net.bioclipse.opentox.api.MolecularDescriptorAlgorithm;
import net.bioclipse.rdf.business.IRDFStore;
@@ -75,7 +80,76 @@
public String getManagerName() {
return "opentox";
}
-
+
+ public Map<String,String> getFeatureInfo(String service, String feature, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Downloading feature information", 1);
+ Map<String,String> properties = Feature.getProperties(service, feature);
+ monitor.done();
+
+ return properties;
+ }
+
+ public Map<String,String> getModelInfo(String service, String feature, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Downloading feature information", 1);
+ Map<String,String> properties = Model.getProperties(service, feature);
+ monitor.done();
+
+ return properties;
+ }
+
+ public Map<String,String> getAlgorithmInfo(String service, String feature, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Downloading feature information", 1);
+ Map<String,String> properties = Algorithm.getProperties(service, feature);
+ monitor.done();
+
+ return properties;
+ }
+
+ public Map<String,Map<String,String>> getFeatureInfo(String service, List<String> features, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Downloading feature information", features.size());
+ Map<String,Map<String,String>> results = new HashMap<String, Map<String,String>>();
+ for (String feature : features) {
+ results.put(feature, Feature.getProperties(service, feature));
+ monitor.worked(1);
+ }
+ monitor.done();
+ return results;
+ }
+
+ public Map<String,Map<String,String>> getAlgorithmInfo(String service, List<String> features, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Downloading algorithm information", features.size());
+ Map<String,Map<String,String>> results = new HashMap<String, Map<String,String>>();
+ for (String feature : features) {
+ results.put(feature, Algorithm.getProperties(service, feature));
+ monitor.worked(1);
+ }
+ monitor.done();
+ return results;
+ }
+
+ public Map<String,Map<String,String>> getModelInfo(String service, List<String> features, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Downloading model information", features.size());
+ Map<String,Map<String,String>> results = new HashMap<String, Map<String,String>>();
+ for (String feature : features) {
+ results.put(feature, Model.getProperties(service, feature));
+ monitor.worked(1);
+ }
+ monitor.done();
+ return results;
+ }
+
public List<Integer> listDataSets(String service, IProgressMonitor monitor)
throws BioclipseException {
List<Integer> dataSets = new ArrayList<Integer>();

0 comments on commit 5214c72

Please sign in to comment.