Exemple #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());
 }
Exemple #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());
 }
Exemple #3
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);
      }
    }
  }