test_class.declarator: builder
test_class.modifier: private static
test_class.original_string: private static IChemObjectBuilder      builder;
test_class.type: IChemObjectBuilder
test_class.var_name: builder
test_class.declarator: lpcheck
test_class.modifier: private static
test_class.original_string: private static LonePairElectronChecker lpcheck;
test_class.type: LonePairElectronChecker
test_class.var_name: lpcheck
test_class.declarator: logger = LoggingToolFactory
                                                            .createLoggingTool(ConjugatedPiSystemsDetectorTest.class)
test_class.modifier: private static
test_class.original_string: private static ILoggingTool            logger = LoggingToolFactory
                                                            .createLoggingTool(ConjugatedPiSystemsDetectorTest.class);
test_class.type: ILoggingTool
test_class.var_name: logger
test_class.file: base/reaction/src/test/java/org/openscience/cdk/graph/invariant/ConjugatedPiSystemsDetectorTest.java
test_class.identifier: ConjugatedPiSystemsDetectorTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testCyanoallene() throws Exception {
          IAtomContainer mol = null;
          mol = (new SmilesParser(builder)).parseSmiles("C=C=CC#N");
          AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
          addImplicitHydrogens(mol);
          lpcheck.saturate(mol);
          Aromaticity.cdkLegacy().apply(mol);
  
          IAtomContainerSet acSet = ConjugatedPiSystemsDetector.detect(mol);
  
          Assert.assertEquals(1, acSet.getAtomContainerCount());
          IAtomContainer ac1 = acSet.getAtomContainer(0);
          Assert.assertEquals(4, ac1.getAtomCount());
          Assert.assertEquals(3, ac1.getBondCount());
  
          for (int i = 0; i < ac1.getAtomCount(); i++) {
              Assert.assertTrue(mol.contains(ac1.getAtom(i)));
          }
  
          for (int i = 0; i < ac1.getBondCount(); i++) {
              Assert.assertTrue(mol.contains(ac1.getBond(i)));
          }
  
      }
test_case.class_method_signature: ConjugatedPiSystemsDetectorTest.testCyanoallene()
test_case.full_signature: @Test public void testCyanoallene()
test_case.identifier: testCyanoallene
test_case.invocations: parseSmiles percieveAtomTypesAndConfigureAtoms addImplicitHydrogens saturate apply cdkLegacy detect assertEquals getAtomContainerCount getAtomContainer assertEquals getAtomCount assertEquals getBondCount getAtomCount assertTrue contains getAtom getBondCount assertTrue contains getBond
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCyanoallene()
focal_class.file: base/reaction/src/main/java/org/openscience/cdk/graph/invariant/ConjugatedPiSystemsDetector.java
focal_class.identifier: ConjugatedPiSystemsDetector
focal_class.class_method_signature: ConjugatedPiSystemsDetector.detect(IAtomContainer ac)
focal_class.full_signature: public static IAtomContainerSet detect(IAtomContainer ac)
focal_class.identifier: detect
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer ac)
focal_class.return: IAtomContainerSet
focal_class.signature: IAtomContainerSet detect(IAtomContainer ac)
focal_class.class_method_signature: ConjugatedPiSystemsDetector.checkAtom(IAtomContainer ac, IAtom currentAtom)
focal_class.full_signature: private static int checkAtom(IAtomContainer ac, IAtom currentAtom)
focal_class.identifier: checkAtom
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer ac, IAtom currentAtom)
focal_class.return: int
focal_class.signature: int checkAtom(IAtomContainer ac, IAtom currentAtom)
focal_method.body: public static IAtomContainerSet detect(IAtomContainer ac) {
          IAtomContainerSet piSystemSet = ac.getBuilder().newInstance(IAtomContainerSet.class);
  
          for (int i = 0; i < ac.getAtomCount(); i++) {
              IAtom atom = ac.getAtom(i);
              atom.setFlag(CDKConstants.VISITED, false);
          }
  
          for (int i = 0; i < ac.getAtomCount(); i++) {
              IAtom firstAtom = ac.getAtom(i);
              // if this atom was already visited in a previous DFS, continue
              if (firstAtom.getFlag(CDKConstants.VISITED) || checkAtom(ac, firstAtom) == -1) {
                  continue;
              }
              IAtomContainer piSystem = ac.getBuilder().newInstance(IAtomContainer.class);
              Stack<IAtom> stack = new Stack<IAtom>();
  
              piSystem.addAtom(firstAtom);
              stack.push(firstAtom);
              firstAtom.setFlag(CDKConstants.VISITED, true);
              // Start DFS from firstAtom
              while (!stack.empty()) {
                  //boolean addAtom = false;
                  IAtom currentAtom = stack.pop();
                  List<IAtom> atoms = ac.getConnectedAtomsList(currentAtom);
                  List<IBond> bonds = ac.getConnectedBondsList(currentAtom);
  
                  for (int j = 0; j < atoms.size(); j++) {
                      IAtom atom = atoms.get(j);
                      IBond bond = bonds.get(j);
                      if (!atom.getFlag(CDKConstants.VISITED)) {
                          int check = checkAtom(ac, atom);
                          if (check == 1) {
                              piSystem.addAtom(atom);
                              piSystem.addBond(bond);
                              continue;
                              // do not mark atom as visited if cumulative double bond
                          } else if (check == 0) {
                              piSystem.addAtom(atom);
                              piSystem.addBond(bond);
                              stack.push(atom);
                          }
                          atom.setFlag(CDKConstants.VISITED, true);
                      }
                      // close rings with one bond
                      else if (!piSystem.contains(bond) && piSystem.contains(atom)) {
                          piSystem.addBond(bond);
                      }
                  }
              }
  
              if (piSystem.getAtomCount() > 2) {
                  piSystemSet.addAtomContainer(piSystem);
              }
          }
  
          return piSystemSet;
      }
focal_method.class_method_signature: ConjugatedPiSystemsDetector.detect(IAtomContainer ac)
focal_method.full_signature: public static IAtomContainerSet detect(IAtomContainer ac)
focal_method.identifier: detect
focal_method.invocations: newInstance getBuilder getAtomCount getAtom setFlag getAtomCount getAtom getFlag checkAtom newInstance getBuilder addAtom push setFlag empty pop getConnectedAtomsList getConnectedBondsList size get get getFlag checkAtom addAtom addBond addAtom addBond push setFlag contains contains addBond getAtomCount addAtomContainer
focal_method.modifiers: public static
focal_method.parameters: (IAtomContainer ac)
focal_method.return: IAtomContainerSet
focal_method.signature: IAtomContainerSet detect(IAtomContainer ac)