@Test
  public void testCalculateXlogPFromSMILES() throws BioclipseException {

    IMolecule mol = new SMILESMolecule("C1CNCCC1CC(COC)CCNC");

    IDescriptorResult dres1 = qsar.calculate(mol, xlogpID, CDK_REST_SHORTNAME);

    assertNotNull(dres1);
    assertNull(dres1.getErrorMessage());
    assertEquals(xlogpID, dres1.getDescriptor().getOntologyid());

    System.out.println(
        "Mol: " + mol.toSMILES() + " ; Desc: " + dres1.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres1.getValues().length; i++) {
      System.out.println("    " + dres1.getLabels()[i] + "=" + dres1.getValues()[i]);
    }

    assertEquals("XLogP", dres1.getLabels()[0]);
    assertEquals(new Float(0.184), dres1.getValues()[0]);
  }
  @Test
  public void testCalculateBpolFromSmiles() throws BioclipseException {

    IMolecule mol = new SMILESMolecule("C1CNCCC1CC(COC)CCNC");

    //        DescriptorImpl desc=qsar.getDescriptorImpl(bpolID, cdkRestProviderID);
    IDescriptorResult dres = qsar.calculate(mol, bpolID, CDK_REST_SHORTNAME);

    assertNull(dres.getErrorMessage());
    assertEquals(bpolID, dres.getDescriptor().getOntologyid());

    System.out.println(
        "Mol: " + mol.toSMILES() + " ; Desc: " + dres.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres.getValues().length; i++) {
      System.out.println("    " + dres.getLabels()[i] + "=" + dres.getValues()[i]);
    }

    assertEquals("bpol", dres.getLabels()[0]);
    assertEquals(new Float(31.659382), dres.getValues()[0]);
  }
  @Test
  public void testCalculateMolDescMap() throws BioclipseException {

    IMolecule mol1 = new SMILESMolecule("C1CCCCC1CC(CC)CC");
    IMolecule mol2 = new SMILESMolecule("C1CCCCC1CC(CC)CCCCCO");

    Descriptor desc1 = qsar.getDescriptorByID(bpolID);
    Descriptor desc2 = qsar.getDescriptorByID(xlogpID);
    DescriptorImpl impl1 = qsar.getPreferredImpl(bpolID);
    DescriptorImpl impl2 = qsar.getPreferredImpl(xlogpID);

    DescriptorType dtype1 = qsar.createDescriptorType(null, null, desc1, impl1, null);
    DescriptorType dtype2 = qsar.createDescriptorType(null, null, desc2, impl2, null);

    Map<IMolecule, List<DescriptorType>> moldescmap =
        new HashMap<IMolecule, List<DescriptorType>>();
    List<DescriptorType> list1 = new ArrayList<DescriptorType>();
    list1.add(dtype1);
    list1.add(dtype2);
    moldescmap.put(mol1, list1);
    List<DescriptorType> list2 = new ArrayList<DescriptorType>();
    list2.add(dtype2);
    moldescmap.put(mol2, list2);

    Map<? extends IMolecule, List<IDescriptorResult>> res =
        qsar.doCalculation(moldescmap, new NullProgressMonitor());
    assertNotNull("QSAR calculation returned NULL", res);

    assertNotNull(res);

    List<IDescriptorResult> res1 = res.get(mol1);
    List<IDescriptorResult> res2 = res.get(mol2);

    assertEquals(2, res1.size());
    assertEquals(1, res2.size());

    IDescriptorResult dres1 = res1.get(0);
    IDescriptorResult dres11 = res1.get(1);
    IDescriptorResult dres2 = res2.get(0);

    assertNull(dres1.getErrorMessage());
    assertNull(dres11.getErrorMessage());
    assertNull(dres2.getErrorMessage());

    System.out.println(
        "Mol: " + mol1.toSMILES() + " ; Desc: " + dres1.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres1.getValues().length; i++) {
      System.out.println("    " + dres1.getLabels()[i] + "=" + dres1.getValues()[i]);
    }

    System.out.println(
        "Mol: " + mol1.toSMILES() + " ; Desc: " + dres11.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres11.getValues().length; i++) {
      System.out.println("    " + dres11.getLabels()[i] + "=" + dres11.getValues()[i]);
    }

    System.out.println(
        "Mol: " + mol2.toSMILES() + " ; Desc: " + dres2.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres2.getValues().length; i++) {
      System.out.println("    " + dres2.getLabels()[i] + "=" + dres2.getValues()[i]);
    }

    assertEquals("bpol", dres1.getLabels()[0]);
    assertEquals(new Float(26.236967), dres1.getValues()[0]);
    assertEquals("XLogP", dres11.getLabels()[0]);
    assertEquals(new Float(6.706), dres11.getValues()[0]);

    assertEquals("XLogP", dres2.getLabels()[0]);
    assertEquals(new Float(6.648), dres2.getValues()[0]);
  }
  @Test
  public void testCalculateMultipleMolMultipleDescriptor() throws BioclipseException {

    IMolecule mol1 = new SMILESMolecule("C1CNCCC1CC(COC)CCNC");
    IMolecule mol2 = new SMILESMolecule("C1CCCCC1CC(CC)CCCCCOCCCN");

    List<IMolecule> mols = new ArrayList<IMolecule>();
    List<String> descs = new ArrayList<String>();

    mols.add(mol1);
    mols.add(mol2);
    descs.add(bpolID);
    descs.add(xlogpID);

    DescriptorCalculationResult calres = qsar.calculate(mols, descs, CDK_REST_SHORTNAME);

    Map<IMolecule, List<IDescriptorResult>> res = calres.getResultMap();

    assertNotNull(res);

    List<IDescriptorResult> res1 = res.get(mol1);
    List<IDescriptorResult> res2 = res.get(mol2);

    assertEquals(2, res1.size());
    assertEquals(2, res2.size());

    IDescriptorResult dres1 = res1.get(0);
    IDescriptorResult dres11 = res1.get(1);
    IDescriptorResult dres2 = res2.get(0);
    IDescriptorResult dres22 = res2.get(1);

    assertNull(dres1.getErrorMessage());
    assertNull(dres11.getErrorMessage());
    assertNull(dres2.getErrorMessage());
    assertNull(dres22.getErrorMessage());

    System.out.println(
        "Mol: " + mol1.toSMILES() + " ; Desc: " + dres1.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres1.getValues().length; i++) {
      System.out.println("    " + dres1.getLabels()[i] + "=" + dres1.getValues()[i]);
    }

    System.out.println(
        "Mol: " + mol1.toSMILES() + " ; Desc: " + dres11.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres11.getValues().length; i++) {
      System.out.println("    " + dres11.getLabels()[i] + "=" + dres11.getValues()[i]);
    }

    System.out.println(
        "Mol: " + mol2.toSMILES() + " ; Desc: " + dres2.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres2.getValues().length; i++) {
      System.out.println("    " + dres2.getLabels()[i] + "=" + dres2.getValues()[i]);
    }

    System.out.println(
        "Mol: " + mol2.toSMILES() + " ; Desc: " + dres22.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres22.getValues().length; i++) {
      System.out.println("    " + dres22.getLabels()[i] + "=" + dres22.getValues()[i]);
    }

    assertEquals("bpol", dres1.getLabels()[0]);
    assertEquals(new Float(31.659382), dres1.getValues()[0]);
    assertEquals("XLogP", dres11.getLabels()[0]);
    assertEquals(new Float(0.184), dres11.getValues()[0]);

    assertEquals("bpol", dres2.getLabels()[0]);
    assertEquals(new Float(41.70466), dres2.getValues()[0]);
    assertEquals("XLogP", dres22.getLabels()[0]);
    assertEquals(new Float(6.749), dres22.getValues()[0]);
  }
  @Test
  public void testCalculateBpolFromSMILES() throws BioclipseException {

    IMolecule mol = new SMILESMolecule("C1CNCCC1CC(COC)CCNC");

    IDescriptorResult dres1 = qsar.calculate(mol, bpolID, CDK_REST_SHORTNAME);

    assertNotNull(dres1);
    assertNull(dres1.getErrorMessage());
    assertEquals(bpolID, dres1.getDescriptor().getOntologyid());
    assertEquals(cdkRestProviderID, dres1.getDescriptor().getProvider());

    System.out.println(
        "Mol: " + mol.toSMILES() + " ; Desc: " + dres1.getDescriptor().getOntologyid() + ": ");
    for (int i = 0; i < dres1.getValues().length; i++) {
      System.out.println("    " + dres1.getLabels()[i] + "=" + dres1.getValues()[i]);
    }

    assertEquals(6, dres1.getValues().length);
    assertEquals(6, dres1.getLabels().length);

    assertEquals("BCUTw-1l", dres1.getLabels()[0]);
    assertEquals(new Float(11.993387), dres1.getValues()[0]);

    assertEquals("BCUTw-1h", dres1.getLabels()[1]);
    assertEquals(new Float(15.994919), dres1.getValues()[1]);
    assertEquals("BCUTc-1l", dres1.getLabels()[2]);
    assertEquals(new Float(0.89), dres1.getValues()[2]);
    assertEquals("BCUTc-1h", dres1.getLabels()[3]);
    assertEquals(new Float(1.1102645), dres1.getValues()[3]);
    assertEquals("BCUTp-1l", dres1.getLabels()[4]);
    assertEquals(new Float(4.6727624), dres1.getValues()[4]);
    assertEquals("BCUTp-1h", dres1.getLabels()[5]);
    assertEquals(new Float(9.596294), dres1.getValues()[5]);
  }
  @Test
  public void testCalculateXlogPFromCML()
      throws BioclipseException, FileNotFoundException, IOException, CoreException {

    ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();

    Bundle bun = Platform.getBundle(net.bioclipse.cdk.qsar.test.Activator.PLUGIN_ID);
    URL url = FileLocator.find(bun, new Path("src/testFiles/0037.cml"), null);
    String str = FileLocator.toFileURL(url).getFile();

    ICDKMolecule mol = cdk.loadMolecule(new MockIFile(str));

    IDescriptorResult dres1 = qsar.calculate(mol, xlogpID, CDK_REST_SHORTNAME);
    IDescriptorResult dres2 = qsar.calculate(mol, xlogpID, "CDK");

    assertNotNull(dres1);
    assertNull(dres1.getErrorMessage(), dres1.getErrorMessage());
    assertEquals(xlogpID, dres1.getDescriptor().getOntologyid());
    assertNotNull(dres2);
    assertNull(dres2.getErrorMessage(), dres1.getErrorMessage());
    assertEquals(xlogpID, dres2.getDescriptor().getOntologyid());

    assertEquals(
        "CDK and CDK REST gives different labels", dres2.getLabels()[0], dres1.getLabels()[0]);
    assertEquals(
        "CDK and CDK REST gives different values", dres2.getValues()[0], dres1.getValues()[0]);
  }