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 test3Amino2MethylPyridine() throws Exception {
  
          IAtomContainer mol = new AtomContainer();
          IAtom a1 = mol.getBuilder().newInstance(IAtom.class, "N");
          a1.setPoint2d(new Point2d(3.7321, 1.345));
          mol.addAtom(a1);
          IAtom a2 = mol.getBuilder().newInstance(IAtom.class, "N");
          a2.setPoint2d(new Point2d(4.5981, -1.155));
          mol.addAtom(a2);
          IAtom a3 = mol.getBuilder().newInstance(IAtom.class, "C");
          a3.setPoint2d(new Point2d(2.866, -0.155));
          mol.addAtom(a3);
          IAtom a4 = mol.getBuilder().newInstance(IAtom.class, "C");
          a4.setPoint2d(new Point2d(3.7321, 0.345));
          mol.addAtom(a4);
          IAtom a5 = mol.getBuilder().newInstance(IAtom.class, "C");
          a5.setPoint2d(new Point2d(2.866, -1.155));
          mol.addAtom(a5);
          IAtom a6 = mol.getBuilder().newInstance(IAtom.class, "C");
          a6.setPoint2d(new Point2d(2.0, 0.345));
          mol.addAtom(a6);
          IAtom a7 = mol.getBuilder().newInstance(IAtom.class, "C");
          a7.setPoint2d(new Point2d(4.5981, -0.155));
          mol.addAtom(a7);
          IAtom a8 = mol.getBuilder().newInstance(IAtom.class, "C");
          a8.setPoint2d(new Point2d(3.7321, -1.655));
          mol.addAtom(a8);
          IAtom a9 = mol.getBuilder().newInstance(IAtom.class, "H");
          a9.setPoint2d(new Point2d(2.3291, -1.465));
          mol.addAtom(a9);
          IAtom a10 = mol.getBuilder().newInstance(IAtom.class, "H");
          a10.setPoint2d(new Point2d(2.31, 0.8819));
          mol.addAtom(a10);
          IAtom a11 = mol.getBuilder().newInstance(IAtom.class, "H");
          a11.setPoint2d(new Point2d(1.4631, 0.655));
          mol.addAtom(a11);
          IAtom a12 = mol.getBuilder().newInstance(IAtom.class, "H");
          a12.setPoint2d(new Point2d(1.69, -0.1919));
          mol.addAtom(a12);
          IAtom a13 = mol.getBuilder().newInstance(IAtom.class, "H");
          a13.setPoint2d(new Point2d(5.135, 0.155));
          mol.addAtom(a13);
          IAtom a14 = mol.getBuilder().newInstance(IAtom.class, "H");
          a14.setPoint2d(new Point2d(3.7321, -2.275));
          mol.addAtom(a14);
          IAtom a15 = mol.getBuilder().newInstance(IAtom.class, "H");
          a15.setPoint2d(new Point2d(4.269, 1.655));
          mol.addAtom(a15);
          IAtom a16 = mol.getBuilder().newInstance(IAtom.class, "H");
          a16.setPoint2d(new Point2d(3.1951, 1.655));
          mol.addAtom(a16);
          IBond b1 = mol.getBuilder().newInstance(IBond.class, a1, a4, IBond.Order.SINGLE);
          mol.addBond(b1);
          IBond b2 = mol.getBuilder().newInstance(IBond.class, a1, a15, IBond.Order.SINGLE);
          mol.addBond(b2);
          IBond b3 = mol.getBuilder().newInstance(IBond.class, a1, a16, IBond.Order.SINGLE);
          mol.addBond(b3);
          IBond b4 = mol.getBuilder().newInstance(IBond.class, a2, a7, IBond.Order.DOUBLE);
          mol.addBond(b4);
          IBond b5 = mol.getBuilder().newInstance(IBond.class, a2, a8, IBond.Order.SINGLE);
          mol.addBond(b5);
          IBond b6 = mol.getBuilder().newInstance(IBond.class, a3, a4, IBond.Order.DOUBLE);
          mol.addBond(b6);
          IBond b7 = mol.getBuilder().newInstance(IBond.class, a3, a5, IBond.Order.SINGLE);
          mol.addBond(b7);
          IBond b8 = mol.getBuilder().newInstance(IBond.class, a3, a6, IBond.Order.SINGLE);
          mol.addBond(b8);
          IBond b9 = mol.getBuilder().newInstance(IBond.class, a4, a7, IBond.Order.SINGLE);
          mol.addBond(b9);
          IBond b10 = mol.getBuilder().newInstance(IBond.class, a5, a8, IBond.Order.DOUBLE);
          mol.addBond(b10);
          IBond b11 = mol.getBuilder().newInstance(IBond.class, a5, a9, IBond.Order.SINGLE);
          mol.addBond(b11);
          IBond b12 = mol.getBuilder().newInstance(IBond.class, a6, a10, IBond.Order.SINGLE);
          mol.addBond(b12);
          IBond b13 = mol.getBuilder().newInstance(IBond.class, a6, a11, IBond.Order.SINGLE);
          mol.addBond(b13);
          IBond b14 = mol.getBuilder().newInstance(IBond.class, a6, a12, IBond.Order.SINGLE);
          mol.addBond(b14);
          IBond b15 = mol.getBuilder().newInstance(IBond.class, a7, a13, IBond.Order.SINGLE);
          mol.addBond(b15);
          IBond b16 = mol.getBuilder().newInstance(IBond.class, a8, a14, IBond.Order.SINGLE);
          mol.addBond(b16);
  
          AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
          boolean isAromatic = DoubleBondAcceptingAromaticityDetector.detectAromaticity(mol);
          Assert.assertTrue(isAromatic);
  
          Iterator<IAtom> atoms = mol.atoms().iterator();
          int nCarom = 0;
          int nCalip = 0;
          int nNarom = 0;
          int nNaliph = 0;
          while (atoms.hasNext()) {
              IAtom atom = atoms.next();
              if (atom.getSymbol().equals("C")) {
                  if (atom.getFlag(CDKConstants.ISAROMATIC))
                      nCarom++;
                  else
                      nCalip++;
              } else if (atom.getSymbol().equals("N")) {
                  if (atom.getFlag(CDKConstants.ISAROMATIC))
                      nNarom++;
                  else
                      nNaliph++;
              }
  
          }
          Assert.assertEquals(5, nCarom);
          Assert.assertEquals(1, nCalip);
          Assert.assertEquals(1, nNarom);
          Assert.assertEquals(1, nNaliph);
      }
test_case.class_method_signature: DoubleBondAcceptingAromaticityDetectorTest.test3Amino2MethylPyridine()
test_case.full_signature: @Test public void test3Amino2MethylPyridine()
test_case.identifier: test3Amino2MethylPyridine
test_case.invocations: newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder setPoint2d addAtom newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond newInstance getBuilder addBond percieveAtomTypesAndConfigureAtoms detectAromaticity assertTrue iterator atoms hasNext next equals getSymbol getFlag equals getSymbol getFlag assertEquals assertEquals assertEquals assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test3Amino2MethylPyridine()
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)