test_class.file: tool/structgen/src/test/java/org/openscience/cdk/structgen/stochastic/PartialFilledStructureMergerTest.java
test_class.identifier: PartialFilledStructureMergerTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testPartialFilledStructureMerger2() throws Exception {
          SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
          IAtomContainerSet acs = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
          acs.addAtomContainer(sp.parseSmiles("[C]=[C]CC[CH2]"));
          acs.addAtomContainer(sp.parseSmiles("[C]([CH2])=C1CC1"));
          PartialFilledStructureMerger pfsm = new PartialFilledStructureMerger();
          IAtomContainer result = pfsm.generate(acs);
          Assert.assertTrue(ConnectivityChecker.isConnected(result));
          Assert.assertTrue(new SaturationChecker().allSaturated(result));
      }
test_case.class_method_signature: PartialFilledStructureMergerTest.testPartialFilledStructureMerger2()
test_case.full_signature: @Test public void testPartialFilledStructureMerger2()
test_case.identifier: testPartialFilledStructureMerger2
test_case.invocations: getInstance newInstance getInstance addAtomContainer parseSmiles addAtomContainer parseSmiles generate assertTrue isConnected assertTrue allSaturated
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPartialFilledStructureMerger2()
focal_class.declarator: logger = LoggingToolFactory.createLoggingTool(PartialFilledStructureMerger.class)
focal_class.modifier: private
focal_class.original_string: private ILoggingTool logger = LoggingToolFactory.createLoggingTool(PartialFilledStructureMerger.class);
focal_class.type: ILoggingTool
focal_class.var_name: logger
focal_class.declarator: satCheck
focal_class.original_string: SaturationChecker    satCheck;
focal_class.type: SaturationChecker
focal_class.var_name: satCheck
focal_class.file: tool/structgen/src/main/java/org/openscience/cdk/structgen/stochastic/PartialFilledStructureMerger.java
focal_class.identifier: PartialFilledStructureMerger
focal_class.class_method_signature: PartialFilledStructureMerger.PartialFilledStructureMerger()
focal_class.full_signature: public  PartialFilledStructureMerger()
focal_class.identifier: PartialFilledStructureMerger
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  PartialFilledStructureMerger()
focal_class.class_method_signature: PartialFilledStructureMerger.generate(IAtomContainerSet atomContainers)
focal_class.full_signature: public IAtomContainer generate(IAtomContainerSet atomContainers)
focal_class.identifier: generate
focal_class.modifiers: public
focal_class.parameters: (IAtomContainerSet atomContainers)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer generate(IAtomContainerSet atomContainers)
focal_class.class_method_signature: PartialFilledStructureMerger.getAnotherUnsaturatedNode(IAtom exclusionAtom,
                                              IAtomContainer exclusionAtomContainer,
                                              IAtomContainerSet atomContainers)
focal_class.full_signature: private IAtom getAnotherUnsaturatedNode(IAtom exclusionAtom,
                                              IAtomContainer exclusionAtomContainer,
                                              IAtomContainerSet atomContainers)
focal_class.identifier: getAnotherUnsaturatedNode
focal_class.modifiers: private
focal_class.parameters: (IAtom exclusionAtom,
                                              IAtomContainer exclusionAtomContainer,
                                              IAtomContainerSet atomContainers)
focal_class.return: IAtom
focal_class.signature: IAtom getAnotherUnsaturatedNode(IAtom exclusionAtom,
                                              IAtomContainer exclusionAtomContainer,
                                              IAtomContainerSet atomContainers)
focal_method.body: public IAtomContainer generate(IAtomContainerSet atomContainers) throws CDKException {
          int iteration = 0;
          boolean structureFound = false;
          do {
              iteration++;
              boolean bondFormed;
              do {
                  bondFormed = false;
                  for (IAtomContainer ac : atomContainers.atomContainers()) {
                      for (IAtom atom : AtomContainerManipulator.getAtomArray(ac)) {
                          if (!satCheck.isSaturated(atom, ac)) {
                              IAtom partner = getAnotherUnsaturatedNode(atom, ac, atomContainers);
                              if (partner != null) {
                                  IAtomContainer toadd = AtomContainerSetManipulator.getRelevantAtomContainer(
                                          atomContainers, partner);
                                  double cmax1 = satCheck.getCurrentMaxBondOrder(atom, ac);
                                  double cmax2 = satCheck.getCurrentMaxBondOrder(partner, toadd);
                                  double max = Math.min(cmax1, cmax2);
                                  double order = Math.min(Math.max(1.0, max), 3.0);//(double)Math.round(Math.random() * max)
                                  logger.debug("cmax1, cmax2, max, order: " + cmax1 + ", " + cmax2 + ", " + max + ", "
                                          + order);
                                  if (toadd != ac) {
                                      atomContainers.removeAtomContainer(toadd);
                                      ac.add(toadd);
                                  }
                                  ac.addBond(ac.getBuilder().newInstance(IBond.class, atom, partner,
                                          BondManipulator.createBondOrder(order)));
                                  bondFormed = true;
                              }
                          }
                      }
                  }
              } while (bondFormed);
              if (atomContainers.getAtomContainerCount() == 1
                      && satCheck.allSaturated(atomContainers.getAtomContainer(0))) {
                  structureFound = true;
              }
          } while (!structureFound && iteration < 5);
          if (atomContainers.getAtomContainerCount() == 1 && satCheck.allSaturated(atomContainers.getAtomContainer(0))) {
              structureFound = true;
          }
          if (!structureFound)
              throw new CDKException("Could not combine the fragments to combine a valid, satured structure");
          return atomContainers.getAtomContainer(0);
      }
focal_method.class_method_signature: PartialFilledStructureMerger.generate(IAtomContainerSet atomContainers)
focal_method.full_signature: public IAtomContainer generate(IAtomContainerSet atomContainers)
focal_method.identifier: generate
focal_method.invocations: atomContainers getAtomArray isSaturated getAnotherUnsaturatedNode getRelevantAtomContainer getCurrentMaxBondOrder getCurrentMaxBondOrder min min max debug removeAtomContainer add addBond newInstance getBuilder createBondOrder getAtomContainerCount allSaturated getAtomContainer getAtomContainerCount allSaturated getAtomContainer getAtomContainer
focal_method.modifiers: public
focal_method.parameters: (IAtomContainerSet atomContainers)
focal_method.return: IAtomContainer
focal_method.signature: IAtomContainer generate(IAtomContainerSet atomContainers)