test_class.declarator: smilesParser
test_class.modifier: static
test_class.original_string: static SmilesParser smilesParser;
test_class.type: SmilesParser
test_class.var_name: smilesParser
test_class.file: tool/fragment/src/test/java/org/openscience/cdk/fragment/FragmentUtilsTest.java
test_class.identifier: FragmentUtilsTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testSplit() throws CDKException {
          IAtomContainer mol = smilesParser.parseSmiles("C1CC1C2CCC2");
          SpanningTree st = new SpanningTree(mol);
          IRingSet rings = st.getAllRings();
          IBond splitBond = null;
          for (int i = 0; i < mol.getBondCount(); i++) {
              if (rings.getRings(mol.getBond(i)).getAtomContainerCount() == 0) {
                  splitBond = mol.getBond(i);
                  break;
              }
          }
          List<IAtomContainer> frags = FragmentUtils.splitMolecule(mol, splitBond);
          SmilesGenerator sg = new SmilesGenerator();
          Set<String> uniqueFrags = new HashSet<String>();
          for (IAtomContainer frag : frags) {
              uniqueFrags.add(sg.create(frag));
          }
          Assert.assertEquals(2, uniqueFrags.size());
          // You can put the fragments back together with a ring closure and dot
          // [CH]12CC1.[CH]12CCC1
          org.hamcrest.MatcherAssert.assertThat(uniqueFrags, hasItems("[CH]1CC1", "[CH]1CCC1"));
      }
test_case.class_method_signature: FragmentUtilsTest.testSplit()
test_case.full_signature: @Test public void testSplit()
test_case.identifier: testSplit
test_case.invocations: parseSmiles getAllRings getBondCount getAtomContainerCount getRings getBond getBond splitMolecule add create assertEquals size assertThat hasItems
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSplit()
focal_class.file: tool/fragment/src/main/java/org/openscience/cdk/fragment/FragmentUtils.java
focal_class.identifier: FragmentUtils
focal_class.class_method_signature: FragmentUtils.splitMolecule(IAtomContainer atomContainer, IBond bond)
focal_class.full_signature: protected static List<IAtomContainer> splitMolecule(IAtomContainer atomContainer, IBond bond)
focal_class.identifier: splitMolecule
focal_class.modifiers: protected static
focal_class.parameters: (IAtomContainer atomContainer, IBond bond)
focal_class.return: List<IAtomContainer>
focal_class.signature: List<IAtomContainer> splitMolecule(IAtomContainer atomContainer, IBond bond)
focal_class.class_method_signature: FragmentUtils.makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom)
focal_class.full_signature: protected static IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom)
focal_class.identifier: makeAtomContainer
focal_class.modifiers: protected static
focal_class.parameters: (IAtom atom, List<IBond> parts, IAtom excludedAtom)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom)
focal_class.class_method_signature: FragmentUtils.traverse(IAtomContainer atomContainer, IAtom atom, List<IBond> bondList)
focal_class.full_signature: protected static List<IBond> traverse(IAtomContainer atomContainer, IAtom atom, List<IBond> bondList)
focal_class.identifier: traverse
focal_class.modifiers: protected static
focal_class.parameters: (IAtomContainer atomContainer, IAtom atom, List<IBond> bondList)
focal_class.return: List<IBond>
focal_class.signature: List<IBond> traverse(IAtomContainer atomContainer, IAtom atom, List<IBond> bondList)
focal_method.body: protected static List<IAtomContainer> splitMolecule(IAtomContainer atomContainer, IBond bond) {
          List<IAtomContainer> ret = new ArrayList<IAtomContainer>();
  
          for (IAtom atom : bond.atoms()) {
  
              // later on we'll want to make sure that the fragment doesn't contain
              // the bond joining the current atom and the atom that is on the other side
              IAtom excludedAtom;
              if (atom.equals(bond.getBegin()))
                  excludedAtom = bond.getEnd();
              else
                  excludedAtom = bond.getBegin();
  
              List<IBond> part = new ArrayList<IBond>();
              part.add(bond);
              part = traverse(atomContainer, atom, part);
  
              // at this point we have a partion which contains the bond we
              // split. This partition should actually 2 partitions:
              // - one with the splitting bond
              // - one without the splitting bond
              // note that this will lead to repeated fragments when we  do this
              // with adjacent bonds, so when we gather all the fragments we need
              // to check for repeats
              IAtomContainer partContainer;
              partContainer = makeAtomContainer(atom, part, excludedAtom);
  
              // by checking for more than 2 atoms, we exclude single bond fragments
              // also if a fragment has the same number of atoms as the parent molecule,
              // it is the parent molecule, so we exclude it.
              if (partContainer.getAtomCount() > 2 && partContainer.getAtomCount() != atomContainer.getAtomCount())
                  ret.add(partContainer);
  
              part.remove(0);
              partContainer = makeAtomContainer(atom, part, excludedAtom);
              if (partContainer.getAtomCount() > 2 && partContainer.getAtomCount() != atomContainer.getAtomCount())
                  ret.add(partContainer);
          }
          return ret;
      }
focal_method.class_method_signature: FragmentUtils.splitMolecule(IAtomContainer atomContainer, IBond bond)
focal_method.full_signature: protected static List<IAtomContainer> splitMolecule(IAtomContainer atomContainer, IBond bond)
focal_method.identifier: splitMolecule
focal_method.invocations: atoms equals getBegin getEnd getBegin add traverse makeAtomContainer getAtomCount getAtomCount getAtomCount add remove makeAtomContainer getAtomCount getAtomCount getAtomCount add
focal_method.modifiers: protected static
focal_method.parameters: (IAtomContainer atomContainer, IBond bond)
focal_method.return: List<IAtomContainer>
focal_method.signature: List<IAtomContainer> splitMolecule(IAtomContainer atomContainer, IBond bond)