예제 #1
0
파일: RingPlacer.java 프로젝트: jonalv/cdk
 /**
  * Partition the bonding partners of a given atom into ring atoms and non-ring atoms
  *
  * @param atom The atom whose bonding partners are to be partitioned
  * @param ring The ring against which the bonding partners are checked
  * @param ringAtoms An AtomContainer to store the ring bonding partners
  * @param nonRingAtoms An AtomContainer to store the non-ring bonding partners
  */
 public void partitionNonRingPartners(
     IAtom atom, IRing ring, IAtomContainer ringAtoms, IAtomContainer nonRingAtoms) {
   java.util.List atoms = molecule.getConnectedAtomsList(atom);
   for (int i = 0; i < atoms.size(); i++) {
     IAtom curAtom = (IAtom) atoms.get(i);
     if (!ring.contains(curAtom)) {
       nonRingAtoms.addAtom(curAtom);
     } else {
       ringAtoms.addAtom(curAtom);
     }
   }
 }
예제 #2
0
  /**
   * Fixes Aromaticity of the molecule i.e. need to find rings and aromaticity again since added H's
   *
   * @param mol
   */
  @TestMethod("testFixAromaticity")
  public static void configure(IAtomContainer mol) {
    // need to find rings and aromaticity again since added H's

    IRingSet ringSet = null;
    try {
      AllRingsFinder arf = new AllRingsFinder();
      ringSet = arf.findAllRings(mol);
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      // figure out which atoms are in aromatic rings:
      CDKHydrogenAdder cdk = CDKHydrogenAdder.getInstance(DefaultChemObjectBuilder.getInstance());
      cdk.addImplicitHydrogens(mol);
      ExtAtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);

      CDKHueckelAromaticityDetector.detectAromaticity(mol);
      // figure out which rings are aromatic:
      RingSetManipulator.markAromaticRings(ringSet);
      // figure out which simple (non cycles) rings are aromatic:

      // only atoms in 6 membered rings are aromatic
      // determine largest ring that each atom is a part of

      for (int i = 0; i < mol.getAtomCount(); i++) {
        mol.getAtom(i).setFlag(CDKConstants.ISAROMATIC, false);
        jloop:
        for (int j = 0; j < ringSet.getAtomContainerCount(); j++) {
          // logger.debug(i+"\t"+j);
          IRing ring = (IRing) ringSet.getAtomContainer(j);
          if (!ring.getFlag(CDKConstants.ISAROMATIC)) {
            continue jloop;
          }
          boolean haveatom = ring.contains(mol.getAtom(i));
          // logger.debug("haveatom="+haveatom);
          if (haveatom && ring.getAtomCount() == 6) {
            mol.getAtom(i).setFlag(CDKConstants.ISAROMATIC, true);
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }