test_class.declarator: parser
test_class.modifier: private static
test_class.original_string: private static SmilesParser parser;
test_class.type: SmilesParser
test_class.var_name: parser
test_class.file: tool/structgen/src/test/java/org/openscience/cdk/structgen/VicinitySamplerTest.java
test_class.identifier: VicinitySamplerTest
test_class.superclass: extends CDKTestCase
test_case.body: @Test
      public void testVicinitySampler_sample() throws Exception {
          IAtomContainer mol = TestMoleculeFactory.makeEthylPropylPhenantren();
  
          Isotopes.getInstance().configureAtoms(mol);
          addImplicitHydrogens(mol);
  
          IAtomContainer temp = null;
          List structures = VicinitySampler.sample(mol);
          Assert.assertEquals(37, structures.size());
          for (int f = 0; f < structures.size(); f++) {
              temp = (IAtomContainer) structures.get(f);
              Assert.assertNotNull(temp);
              Assert.assertTrue(ConnectivityChecker.isConnected(temp));
              Assert.assertEquals(mol.getAtomCount(), temp.getAtomCount());
          }
  
      }
test_case.class_method_signature: VicinitySamplerTest.testVicinitySampler_sample()
test_case.full_signature: @Test public void testVicinitySampler_sample()
test_case.identifier: testVicinitySampler_sample
test_case.invocations: makeEthylPropylPhenantren configureAtoms getInstance addImplicitHydrogens sample assertEquals size size get assertNotNull assertTrue isConnected assertEquals getAtomCount getAtomCount
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testVicinitySampler_sample()
focal_class.declarator: LOGGER     = LoggingToolFactory.createLoggingTool(VicinitySampler.class)
focal_class.modifier: private final static
focal_class.original_string: private final static ILoggingTool LOGGER     = LoggingToolFactory.createLoggingTool(VicinitySampler.class);
focal_class.type: ILoggingTool
focal_class.var_name: LOGGER
focal_class.declarator: molCounter = 0
focal_class.original_string: int                               molCounter = 0;
focal_class.type: int
focal_class.var_name: molCounter
focal_class.file: tool/structgen/src/main/java/org/openscience/cdk/structgen/VicinitySampler.java
focal_class.identifier: VicinitySampler
focal_class.class_method_signature: VicinitySampler.sample(IAtomContainer ac)
focal_class.full_signature: public static List<IAtomContainer> sample(IAtomContainer ac)
focal_class.identifier: sample
focal_class.modifiers: public static
focal_class.parameters: (IAtomContainer ac)
focal_class.return: List<IAtomContainer>
focal_class.signature: List<IAtomContainer> sample(IAtomContainer ac)
focal_class.class_method_signature: VicinitySampler.change(IAtomContainer ac, int x1, int y1, int x2, int y2, double b11, double b12,
              double b21, double b22)
focal_class.full_signature: private static IAtomContainer change(IAtomContainer ac, int x1, int y1, int x2, int y2, double b11, double b12,
              double b21, double b22)
focal_class.identifier: change
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer ac, int x1, int y1, int x2, int y2, double b11, double b12,
              double b21, double b22)
focal_class.return: IAtomContainer
focal_class.signature: IAtomContainer change(IAtomContainer ac, int x1, int y1, int x2, int y2, double b11, double b12,
              double b21, double b22)
focal_method.body: public static List<IAtomContainer> sample(IAtomContainer ac) {
          LOGGER.debug("RandomGenerator->mutate() Start");
          List<IAtomContainer> structures = new ArrayList<IAtomContainer>();
  
          int nrOfAtoms = ac.getAtomCount();
          double a11 = 0, a12 = 0, a22 = 0, a21 = 0;
          double b11 = 0, lowerborder = 0, upperborder = 0;
          double b12 = 0;
          double b21 = 0;
          double b22 = 0;
          double[] cmax = new double[4];
          double[] cmin = new double[4];
          IAtomContainer newAc = null;
  
          IAtom ax1 = null, ax2 = null, ay1 = null, ay2 = null;
          IBond b1 = null, b2 = null, b3 = null, b4 = null;
          //int[] choices = new int[3];
          /* We need at least two non-zero bonds in order to be successful */
          int nonZeroBondsCounter = 0;
          for (int x1 = 0; x1 < nrOfAtoms; x1++) {
              for (int x2 = x1 + 1; x2 < nrOfAtoms; x2++) {
                  for (int y1 = x2 + 1; y1 < nrOfAtoms; y1++) {
                      for (int y2 = y1 + 1; y2 < nrOfAtoms; y2++) {
                          nonZeroBondsCounter = 0;
                          ax1 = ac.getAtom(x1);
                          ay1 = ac.getAtom(y1);
                          ax2 = ac.getAtom(x2);
                          ay2 = ac.getAtom(y2);
  
                          /* Get four bonds for these four atoms */
  
                          b1 = ac.getBond(ax1, ay1);
                          if (b1 != null) {
                              a11 = BondManipulator.destroyBondOrder(b1.getOrder());
                              nonZeroBondsCounter++;
                          } else {
                              a11 = 0;
                          }
  
                          b2 = ac.getBond(ax1, ay2);
                          if (b2 != null) {
                              a12 = BondManipulator.destroyBondOrder(b2.getOrder());
                              nonZeroBondsCounter++;
                          } else {
                              a12 = 0;
                          }
  
                          b3 = ac.getBond(ax2, ay1);
                          if (b3 != null) {
                              a21 = BondManipulator.destroyBondOrder(b3.getOrder());
                              nonZeroBondsCounter++;
                          } else {
                              a21 = 0;
                          }
  
                          b4 = ac.getBond(ax2, ay2);
                          if (b4 != null) {
                              a22 = BondManipulator.destroyBondOrder(b4.getOrder());
                              nonZeroBondsCounter++;
                          } else {
                              a22 = 0;
                          }
                          if (nonZeroBondsCounter > 1) {
                              /*
                               * Compute the range for b11 (see Faulons formulae
                               * for details)
                               */
  
                              cmax[0] = 0;
                              cmax[1] = a11 - a22;
                              cmax[2] = a11 + a12 - 3;
                              cmax[3] = a11 + a21 - 3;
                              cmin[0] = 3;
                              cmin[1] = a11 + a12;
                              cmin[2] = a11 + a21;
                              cmin[3] = a11 - a22 + 3;
                              lowerborder = MathTools.max(cmax);
                              upperborder = MathTools.min(cmin);
                              for (b11 = lowerborder; b11 <= upperborder; b11++) {
                                  if (b11 != a11) {
  
                                      b12 = a11 + a12 - b11;
                                      b21 = a11 + a21 - b11;
                                      b22 = a22 - a11 + b11;
                                      LOGGER.debug("Trying atom combination : " + x1 + ":" + x2 + ":" + y1 + ":" + y2);
                                      try {
                                          newAc = (IAtomContainer) ac.clone();
                                          change(newAc, x1, y1, x2, y2, b11, b12, b21, b22);
                                          if (ConnectivityChecker.isConnected(newAc)) {
                                              structures.add(newAc);
                                          } else {
                                              LOGGER.debug("not connected");
                                          }
                                      } catch (CloneNotSupportedException e) {
                                          LOGGER.error("Cloning exception: " + e.getMessage());
                                          LOGGER.debug(e);
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
          return structures;
      }
focal_method.class_method_signature: VicinitySampler.sample(IAtomContainer ac)
focal_method.full_signature: public static List<IAtomContainer> sample(IAtomContainer ac)
focal_method.identifier: sample
focal_method.invocations: debug getAtomCount getAtom getAtom getAtom getAtom getBond destroyBondOrder getOrder getBond destroyBondOrder getOrder getBond destroyBondOrder getOrder getBond destroyBondOrder getOrder max min debug clone change isConnected add debug error getMessage debug
focal_method.modifiers: public static
focal_method.parameters: (IAtomContainer ac)
focal_method.return: List<IAtomContainer>
focal_method.signature: List<IAtomContainer> sample(IAtomContainer ac)