test_class.file: legacy/src/test/java/org/openscience/cdk/aromaticity/DoubleBondAcceptingAromaticityDetectorTest.java
test_class.identifier: DoubleBondAcceptingAromaticityDetectorTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testBenzene() throws Exception {
          IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
          AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
          DoubleBondAcceptingAromaticityDetector.detectAromaticity(molecule);
          for (int f = 0; f < molecule.getAtomCount(); f++) {
              Assert.assertTrue(molecule.getAtom(f).getFlag(CDKConstants.ISAROMATIC));
          }
      }
test_case.class_method_signature: DoubleBondAcceptingAromaticityDetectorTest.testBenzene()
test_case.full_signature: @Test public void testBenzene()
test_case.identifier: testBenzene
test_case.invocations: makeBenzene percieveAtomTypesAndConfigureAtoms detectAromaticity getAtomCount assertTrue getFlag getAtom
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testBenzene()
focal_class.declarator: factory = null
focal_class.modifier: private static
focal_class.original_string: private static AtomTypeFactory factory = null;
focal_class.type: AtomTypeFactory
focal_class.var_name: factory
focal_class.file: legacy/src/main/java/org/openscience/cdk/aromaticity/DoubleBondAcceptingAromaticityDetector.java
focal_class.identifier: DoubleBondAcceptingAromaticityDetector
focal_class.class_method_signature: DoubleBondAcceptingAromaticityDetector.detectAromaticity(IAtomContainer atomContainer)
focal_class.full_signature: public static boolean detectAromaticity(IAtomContainer atomContainer)
focal_class.identifier: detectAromaticity
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer atomContainer)
focal_class.return: boolean
focal_class.signature: boolean detectAromaticity(IAtomContainer atomContainer)
focal_class.class_method_signature: DoubleBondAcceptingAromaticityDetector.isHueckelValid(IAtomContainer singleRing)
focal_class.full_signature: private static boolean isHueckelValid(IAtomContainer singleRing)
focal_class.identifier: isHueckelValid
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer singleRing)
focal_class.return: boolean
focal_class.signature: boolean isHueckelValid(IAtomContainer singleRing)
focal_class.class_method_signature: DoubleBondAcceptingAromaticityDetector.atomIsPotentiallyAromatic(IAtom atom)
focal_class.full_signature: private static boolean atomIsPotentiallyAromatic(IAtom atom)
focal_class.identifier: atomIsPotentiallyAromatic
focal_class.modifiers: private static
focal_class.parameters: (IAtom atom)
focal_class.return: boolean
focal_class.signature: boolean atomIsPotentiallyAromatic(IAtom atom)
focal_class.class_method_signature: DoubleBondAcceptingAromaticityDetector.getLonePairCount(IAtom atom)
focal_class.full_signature: private static int getLonePairCount(IAtom atom)
focal_class.identifier: getLonePairCount
focal_class.modifiers: private static
focal_class.parameters: (IAtom atom)
focal_class.return: int
focal_class.signature: int getLonePairCount(IAtom atom)
focal_class.class_method_signature: DoubleBondAcceptingAromaticityDetector.markRingAtomsAndBondsAromatic(IAtomContainer container)
focal_class.full_signature: private static void markRingAtomsAndBondsAromatic(IAtomContainer container)
focal_class.identifier: markRingAtomsAndBondsAromatic
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container)
focal_class.return: void
focal_class.signature: void markRingAtomsAndBondsAromatic(IAtomContainer container)
focal_method.body: public static boolean detectAromaticity(IAtomContainer atomContainer) throws CDKException {
          SpanningTree spanningTree = new SpanningTree(atomContainer);
          IAtomContainer ringSystems = spanningTree.getCyclicFragmentsContainer();
          if (ringSystems.getAtomCount() == 0) {
              // If there are no rings, then there cannot be any aromaticity
              return false;
          }
          // disregard all atoms we know that cannot be aromatic anyway
          for (IAtom atom : ringSystems.atoms())
              if (!atomIsPotentiallyAromatic(atom)) ringSystems.removeAtom(atom);
  
          // FIXME: should not really mark them here
          Iterator<IAtom> atoms = ringSystems.atoms().iterator();
          while (atoms.hasNext())
              atoms.next().setFlag(CDKConstants.ISINRING, true);
          Iterator<IBond> bonds = ringSystems.bonds().iterator();
          while (bonds.hasNext())
              bonds.next().setFlag(CDKConstants.ISINRING, true);
  
          boolean foundSomeAromaticity = false;
          Iterator<IAtomContainer> isolatedRingSystems = ConnectivityChecker.partitionIntoMolecules(ringSystems)
                  .atomContainers().iterator();
          while (isolatedRingSystems.hasNext()) {
              IAtomContainer isolatedSystem = isolatedRingSystems.next();
              IRingSet singleRings = Cycles.sssr(isolatedSystem).toRingSet();
              Iterator<IAtomContainer> singleRingsIterator = singleRings.atomContainers().iterator();
              int maxRingSize = 20;
              boolean allRingsAreAromatic = true;
              // test single rings in SSSR
              while (singleRingsIterator.hasNext()) {
                  IAtomContainer singleRing = singleRingsIterator.next();
                  if (singleRing.getAtomCount() > maxRingSize) maxRingSize = singleRing.getAtomCount();
                  // possibly aromatic
                  boolean ringIsAromatic = isHueckelValid(singleRing);
                  foundSomeAromaticity |= ringIsAromatic;
                  allRingsAreAromatic &= ringIsAromatic;
                  if (ringIsAromatic) markRingAtomsAndBondsAromatic(singleRing);
              }
              // OK, what about the one larger ring (if no aromaticity found in SSSR)?
              if (!allRingsAreAromatic && singleRings.getAtomContainerCount() <= 3) {
                  // every ring system consisting of more than two rings is too difficult
                  Iterator<IAtomContainer> allRingsIterator = new AllRingsFinder()
                          .findAllRingsInIsolatedRingSystem(isolatedSystem).atomContainers().iterator();
                  while (allRingsIterator.hasNext()) {
                      // there should be exactly three rings, of which only one has a size larger
                      // than the two previous ones
                      IAtomContainer ring = allRingsIterator.next();
                      if (ring.getAtomCount() <= maxRingSize) {
                          // possibly aromatic
                          boolean ringIsAromatic = isHueckelValid(ring);
                          foundSomeAromaticity |= ringIsAromatic;
                          if (ringIsAromatic) markRingAtomsAndBondsAromatic(ring);
                      }
                  }
              }
          }
  
          return foundSomeAromaticity;
      }
focal_method.class_method_signature: DoubleBondAcceptingAromaticityDetector.detectAromaticity(IAtomContainer atomContainer)
focal_method.full_signature: public static boolean detectAromaticity(IAtomContainer atomContainer)
focal_method.identifier: detectAromaticity
focal_method.invocations: getCyclicFragmentsContainer getAtomCount atoms atomIsPotentiallyAromatic removeAtom iterator atoms hasNext setFlag next iterator bonds hasNext setFlag next iterator atomContainers partitionIntoMolecules hasNext next toRingSet sssr iterator atomContainers hasNext next getAtomCount getAtomCount isHueckelValid markRingAtomsAndBondsAromatic getAtomContainerCount iterator atomContainers findAllRingsInIsolatedRingSystem hasNext next getAtomCount isHueckelValid markRingAtomsAndBondsAromatic
focal_method.modifiers: public static
focal_method.parameters: (IAtomContainer atomContainer)
focal_method.return: boolean
focal_method.signature: boolean detectAromaticity(IAtomContainer atomContainer)