Skip to content
Browse files

Implemented predictWithModelWithLabel

Returns a map from feature title to predicted value.
Needs some bug fixing...
  • Loading branch information...
1 parent d8a9c7f commit c04592e8130548bac639b28b01378f713d0b74d1 @olas olas committed Nov 12, 2010
View
19 plugins/net.bioclipse.opentox/src/net/bioclipse/opentox/business/IOpentoxManager.java
@@ -13,6 +13,8 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+
import net.bioclipse.core.PublishedClass;
import net.bioclipse.core.PublishedMethod;
import net.bioclipse.core.Recorded;
@@ -65,6 +67,23 @@
params="String service, String model, IMolecule molecule"
)
public List<String> predictWithModel(String service, String model, IMolecule molecule);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Predicts modeled properties for the given molecule.",
+ params="String service, String model, IMolecule molecule"
+ )
+ public Map<String,String> predictWithModelWithLabel(String service, String model, List<IMolecule> molecules);
+
+ @Recorded
+ @PublishedMethod(
+ methodSummary=
+ "Predicts modeled properties for the given molecule.",
+ params="String service, String model, IMolecule molecule"
+ )
+ public Map<String,String> predictWithModelWithLabel(String service, String model, IMolecule molecule);
+
@Recorded
@PublishedMethod(
View
50 plugins/net.bioclipse.opentox/src/net/bioclipse/opentox/business/OpentoxManager.java
@@ -522,6 +522,32 @@ public void deleteDataset(String datasetURI)
return calcResults;
}
+
+ public Map<String,String> predictWithModelWithLabel(String service, String model, List<IMolecule> molecules, IProgressMonitor monitor)
+ throws Exception {
+ if (service == null) throw new BioclipseException("Service is null");
+ if (model == null) throw new BioclipseException("Model is null");
+
+ if (monitor == null) monitor = new NullProgressMonitor();
+ monitor.beginTask("Calculate model for dataset", molecules.size());
+
+ Map<String,String> calcResults = new HashMap<String, String>();
+ for (IMolecule molecule : molecules) {
+ String dataset = Dataset.createNewDataset(service, molecule);
+ String results = ModelAlgorithm.calculate(service, model, dataset);
+ StringMatrix features = Dataset.listPredictedFeatures(results);
+ List<String> fcol = removeDataType(features.getColumn("numval"));
+ List<String> lcol = features.getColumn("desc");
+ for (int i=0; i<fcol.size(); i++){
+ calcResults.put(lcol.get(i), fcol.get(i));
+ }
+
+ Dataset.deleteDataset(dataset);
+ monitor.worked(1);
+ }
+
+ return calcResults;
+ }
public List<String> predictWithModel(String service, String model, IMolecule molecule, IProgressMonitor monitor)
throws Exception {
@@ -541,6 +567,30 @@ public void deleteDataset(String datasetURI)
return calcResults;
}
+
+ public Map<String,String> predictWithModelWithLabel(String service, String model, IMolecule molecule, IProgressMonitor monitor)
+ throws Exception {
+ if (service == null) throw new BioclipseException("Service is null");
+ if (model == null) throw new BioclipseException("Model is null");
+
+ if (monitor == null) monitor = new NullProgressMonitor();
+ monitor.beginTask("Calculate model for molecule", 1);
+
+ Map<String,String> calcResults = new HashMap<String, String>();
+ String dataset = Dataset.createNewDataset(service, molecule);
+ String results = ModelAlgorithm.calculate(service, model, dataset);
+ StringMatrix features = Dataset.listPredictedFeatures(results);
+ List<String> fcol = removeDataType(features.getColumn("numval"));
+ List<String> lcol = features.getColumn("desc");
+ for (int i=0; i<lcol.size(); i++){
+ calcResults.put(lcol.get(i), fcol.get(i));
+ }
+
+ Dataset.deleteDataset(dataset);
+ monitor.worked(1);
+
+ return calcResults;
+ }
private List<String> removeDataType(List<String> column) {
List<String> cleanedData = new ArrayList<String>(column.size());

0 comments on commit c04592e

Please sign in to comment.
Something went wrong with that request. Please try again.