Permalink
Browse files

Predict using predictWithModelWithLabel to also include name in prese…

…ntation.
  • Loading branch information...
1 parent c04592e commit deeb2cdf7e79a5a13121f87f085da634c1045da1 @olas olas committed Nov 12, 2010
Showing with 31 additions and 4 deletions.
  1. +31 −4 plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/OpenToxModel.java
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -58,11 +59,37 @@ public void initialize(IProgressMonitor monitor) throws DSException {
ArrayList<net.bioclipse.ds.model.result.SimpleResult> results
= new ArrayList<net.bioclipse.ds.model.result.SimpleResult>();
- List<String> res = opentox.predictWithModel(service, model, cdkmol);
- for (String r : res){
- results.add(new net.bioclipse.ds.model.result.SimpleResult(r,
- ITestResult.INFORMATIVE));
+
+ //Invoke calculation
+ logger.debug("Invoking model: " + model + " for service: " + service);
+ Map<String, String> OTres = null;
+ //retry 5 times, looks like a server issue
+ for (int i=0; i<6; i++){
+ if (i>0)
+ logger.debug(" - Model: " + model + " retry number " + i);
+
+ try{
+ OTres = opentox.predictWithModelWithLabel(service, model, cdkmol);
+
+ }catch(Exception e){
+ logger.error(" == Opentox model calculation failed for: " + model);
+ }
+
+ //End if we have results
+ if (OTres!=null) break;
+
+ }
+
+ if (OTres==null || OTres.size()<=0){
+ return returnError("No results", "No results");
+ }
+
+ for (String label : OTres.keySet()){
+ String name=label.substring(label.lastIndexOf("/")+1);
+ results.add(new net.bioclipse.ds.model.result.SimpleResult(
+ name+ " = " + OTres.get(label), ITestResult.INFORMATIVE));
}
+
return results;
}

0 comments on commit deeb2cd

Please sign in to comment.