Example #1
0
 @Test
 public void testLoadingOfBondDescriptors() {
   DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.BOND);
   Assert.assertNotNull(engine);
   int loadedDescriptors = engine.getDescriptorInstances().size();
   Assert.assertNotSame(0, loadedDescriptors);
   Assert.assertEquals(loadedDescriptors, engine.getDescriptorClassNames().size());
   Assert.assertEquals(loadedDescriptors, engine.getDescriptorSpecifications().size());
 }
Example #2
0
 @Test
 public void testLoadingOfMolecularDescriptors() {
   DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);
   Assert.assertNotNull(engine);
   int loadedDescriptors = engine.getDescriptorInstances().size();
   Assert.assertTrue("Could not load any descriptors", 0 != loadedDescriptors);
   Assert.assertEquals(loadedDescriptors, engine.getDescriptorClassNames().size());
   Assert.assertEquals(loadedDescriptors, engine.getDescriptorSpecifications().size());
 }
Example #3
0
  /**
   * @cdk.bug 1965254
   * @throws Exception
   */
  @Test
  public void testjunk() throws Exception {

    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer molecule = sp.parseSmiles("COC1=CC2=C(C=C1)NC3=C2CCNC3");

    TemplateHandler3D template = TemplateHandler3D.getInstance();
    ModelBuilder3D mb3d = ModelBuilder3D.getInstance(template, "mm2");
    molecule = mb3d.generate3DCoordinates(molecule, true);
    DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);

    engine.process(molecule);
  }
Example #4
0
  @Test
  public void testDictionaryType() {
    DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);

    String className = "org.openscience.cdk.qsar.descriptors.molecular.ZagrebIndexDescriptor";
    DescriptorSpecification specRef =
        new DescriptorSpecification(
            "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#zagrebIndex",
            this.getClass().getName(),
            "$Id$",
            "The Chemistry Development Kit");

    Assert.assertEquals("molecularDescriptor", engine.getDictionaryType(className));
    Assert.assertEquals("molecularDescriptor", engine.getDictionaryType(specRef));
  }
Example #5
0
  @Test
  public void checkUniqueMolecularDescriptorNames() throws Exception {
    DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);
    List<DescriptorSpecification> specs = engine.getDescriptorSpecifications();

    // we work with a simple molecule with 3D coordinates
    String filename = "data/mdl/lobtest2.sdf";
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
    ChemFile content = (ChemFile) reader.read(new ChemFile());
    List cList = ChemFileManipulator.getAllAtomContainers(content);
    IAtomContainer ac = (IAtomContainer) cList.get(0);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac);

    engine.process(ac);

    int ncalc = 0;
    List<String> descNames = new ArrayList<String>();
    for (DescriptorSpecification spec : specs) {
      DescriptorValue value = (DescriptorValue) ac.getProperty(spec);
      if (value == null) continue;
      ncalc++;
      String[] names = value.getNames();
      descNames.addAll(Arrays.asList(names));
    }

    List<String> dups = new ArrayList<String>();
    Set<String> uniqueNames = new HashSet<String>();
    for (String name : descNames) {
      if (!uniqueNames.add(name)) dups.add(name);
    }
    Assert.assertEquals(specs.size(), ncalc);
    Assert.assertEquals(descNames.size(), uniqueNames.size());
    if (dups.size() != 0) {
      System.out.println("Following names were duplicated");
      for (String dup : dups) {
        System.out.println("dup = " + dup);
      }
    }
  }
Example #6
0
  @Test
  public void testDictionaryClass() {
    DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);

    String className = "org.openscience.cdk.qsar.descriptors.molecular.TPSADescriptor";
    DescriptorSpecification specRef =
        new DescriptorSpecification(
            "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#tpsa",
            this.getClass().getName(),
            "$Id$",
            "The Chemistry Development Kit");

    String[] dictClass = engine.getDictionaryClass(className);
    Assert.assertEquals(2, dictClass.length);
    Assert.assertEquals("topologicalDescriptor", dictClass[0]);
    Assert.assertEquals("electronicDescriptor", dictClass[1]);

    dictClass = engine.getDictionaryClass(specRef);
    Assert.assertEquals(2, dictClass.length);
    Assert.assertEquals("topologicalDescriptor", dictClass[0]);
    Assert.assertEquals("electronicDescriptor", dictClass[1]);
  }
Example #7
0
 @Test
 public void testAvailableClass() {
   DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);
   String[] availClasses = engine.getAvailableDictionaryClasses();
   Assert.assertEquals(5, availClasses.length);
 }