示例#1
0
  /**
   * Get a list of all available tests
   *
   * @return
   * @throws BioclipseException
   */
  public List<String> getTests() throws BioclipseException {

    initialize();

    List<String> testIDS = new ArrayList<String>();
    for (IDSTest test : dsBusinessModel.getTests()) {
      testIDS.add(test.getId());
    }

    return testIDS;
  }
示例#2
0
  public IDSTest getTest(String testID) throws BioclipseException {

    if (testID == null) throw new BioclipseException("Test: " + testID + " must not be null.");

    initialize();

    for (IDSTest test : dsBusinessModel.getTests()) {
      if (testID.equals(test.getId())) return test;
    }

    logger.warn("Test: " + testID + " could not be found.");
    throw new BioclipseException("Test: " + testID + " could not be found.");
  }
示例#3
0
  /**
   * Run all tests in an EndPoint in a job.
   *
   * @param endpointID
   * @param mol
   * @param returner
   * @param monitor
   * @throws BioclipseException
   */
  public void runEndpoint(
      String endpointID,
      IMolecule mol,
      IReturner<Map<String, List<? extends ITestResult>>> returner,
      IProgressMonitor monitor)
      throws BioclipseException {

    getEndpoint(endpointID);

    // Set up result container
    Map<String, List<? extends ITestResult>> ret =
        new HashMap<String, List<? extends ITestResult>>();

    // Get manager interface, we want to use the AOP
    IDSManager ds = Activator.getDefault().getJavaManager();
    Map<String, BioclipseJob<List<ITestResult>>> jobs =
        new HashMap<String, BioclipseJob<List<ITestResult>>>();

    // This is done in abstractDSTest + ds.runTest

    //		ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();
    //		//Preprocess the molecule
    //		ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);
    //
    //		try {
    //			cdkmol = cdk.removeExplicitHydrogens(cdkmol);
    //			cdkmol=cdk.perceiveAromaticity(cdkmol);
    //			cdkmol=cdk.addImplicitHydrogens(cdkmol);
    //		} catch (InvocationTargetException e1) {
    //			throw new BioclipseException("Could not preprocess molecule: " + e1.getMessage());
    //		}

    // Loop over all tests in this endpoint and run them
    for (IDSTest test : getEndpoint(endpointID).getTests()) {

      //			//Clone the mol
      //			IAtomContainer clonedAC=null;
      //			try {
      //				clonedAC = (IAtomContainer) cdkmol.getAtomContainer().clone();
      //			} catch (CloneNotSupportedException e) {
      //				//Should not happen
      //				logger.error("Could not clone mol: " + cdkmol);
      //				continue;
      //			}
      //			ICDKMolecule clonedMol=new CDKMolecule(clonedAC);

      // Start up a job with the test
      BioclipseJob<List<ITestResult>> job =
          ds.runTest(
              test.getId(), mol, new BioclipseJobUpdateHook<List<ITestResult>>(test.getName()));
      jobs.put(test.getId(), job);
      job.schedule();
    }

    // Join all jobs, wait for them to end
    for (String testID : jobs.keySet()) {
      try {
        BioclipseJob<List<ITestResult>> job = jobs.get(testID);
        logger.debug("Waiting for test: " + testID);
        job.join();
        logger.debug("  - Test: " + testID + " finished.");
        List<ITestResult> testres = job.getReturnValue();
        ret.put(testID, testres);

      } catch (InterruptedException e) {
        throw new BioclipseException("Job interrupted");
      }
    }

    monitor.done();
    returner.completeReturn(ret);
  }