Esempio n. 1
0
  @TestMethod("testCalculate_IAtomContainer")
  public DescriptorValue calculate(IAtomContainer container) {

    // removeHydrogens does a deep copy, so no need to clone
    IAtomContainer localAtomContainer = AtomContainerManipulator.removeHydrogens(container);
    CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder());
    Iterator<IAtom> atoms = localAtomContainer.atoms().iterator();
    while (atoms.hasNext()) {
      IAtom atom = atoms.next();
      IAtomType type;
      try {
        type = matcher.findMatchingAtomType(localAtomContainer, atom);
        AtomTypeManipulator.configure(atom, type);
      } catch (Exception e) {
        return getDummyDescriptorValue(new CDKException("Error in atom typing: " + e.getMessage()));
      }
    }
    CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(container.getBuilder());
    try {
      hAdder.addImplicitHydrogens(localAtomContainer);
    } catch (CDKException e) {
      return getDummyDescriptorValue(
          new CDKException("Error in hydrogen addition: " + e.getMessage()));
    }

    List subgraph3 = order3(localAtomContainer);
    List subgraph4 = order4(localAtomContainer);
    List subgraph5 = order5(localAtomContainer);
    List subgraph6 = order6(localAtomContainer);

    double order3s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph3);
    double order4s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph4);
    double order5s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph5);
    double order6s = ChiIndexUtils.evalSimpleIndex(localAtomContainer, subgraph6);

    double order3v, order4v, order5v, order6v;
    try {
      order3v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph3);
      order4v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph4);
      order5v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph5);
      order6v = ChiIndexUtils.evalValenceIndex(localAtomContainer, subgraph6);
    } catch (CDKException e) {
      return getDummyDescriptorValue(
          new CDKException("Error in substructure search: " + e.getMessage()));
    }
    DoubleArrayResult retval = new DoubleArrayResult();
    retval.add(order3s);
    retval.add(order4s);
    retval.add(order5s);
    retval.add(order6s);

    retval.add(order3v);
    retval.add(order4v);
    retval.add(order5v);
    retval.add(order6v);

    return new DescriptorValue(
        getSpecification(), getParameterNames(), getParameters(), retval, getDescriptorNames());
  }
 private List order6(IAtomContainer atomContainer) {
   QueryAtomContainer[] queries = new QueryAtomContainer[5];
   try {
     queries[0] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)(C)CCC"), false);
     queries[1] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)C(C)CC"), false);
     queries[2] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)CC(C)C"), false);
     queries[3] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)CCCC"), false);
     queries[4] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CCC(C)CCC"), false);
   } catch (InvalidSmilesException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
   return ChiIndexUtils.getFragments(atomContainer, queries);
 }