/**
   * Modules for cleaning a molecule
   *
   * @param molecule
   * @return cleaned AtomContainer
   */
  @TestMethod("testCheckAndCleanMolecule")
  public static IAtomContainer checkAndCleanMolecule(IAtomContainer molecule) {
    boolean isMarkush = false;
    for (IAtom atom : molecule.atoms()) {
      if (atom.getSymbol().equals("R")) {
        isMarkush = true;
        break;
      }
    }

    if (isMarkush) {
      System.err.println("Skipping Markush structure for sanity check");
    }

    // Check for salts and such
    if (!ConnectivityChecker.isConnected(molecule)) {
      // lets see if we have just two parts if so, we assume its a salt and just work
      // on the larger part. Ideally we should have a check to ensure that the smaller
      //  part is a metal/halogen etc.
      IMoleculeSet fragments = ConnectivityChecker.partitionIntoMolecules(molecule);
      if (fragments.getMoleculeCount() > 2) {
        System.err.println("More than 2 components. Skipped");
      } else {
        IMolecule frag1 = fragments.getMolecule(0);
        IMolecule frag2 = fragments.getMolecule(1);
        if (frag1.getAtomCount() > frag2.getAtomCount()) {
          molecule = frag1;
        } else {
          molecule = frag2;
        }
      }
    }
    configure(molecule);
    return molecule;
  }
  /** @cdk.bug 2142400 */
  @Test
  public void testHydrogenCount2() throws Exception {
    String cmlString =
        "<molecule><atomArray>"
            + "<atom id='a1' elementType='C' hydrogenCount='4'/>"
            + "<atom id='a2' elementType='H'/>"
            + "<atom id='a3' elementType='H'/>"
            + "<atom id='a4' elementType='H'/>"
            + "<atom id='a5' elementType='H'/>"
            + "</atomArray>"
            + "<bondArray>"
            + "<bond id='b1' atomRefs2='a1 a2' order='S'/>"
            + "<bond id='b2' atomRefs2='a1 a3' order='S'/>"
            + "<bond id='b3' atomRefs2='a1 a4' order='S'/>"
            + "<bond id='b4' atomRefs2='a1 a5' order='S'/>"
            + "</bondArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(5, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertNotNull(atom);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertNotNull(atom.getImplicitHydrogenCount());
    Assert.assertEquals(0, atom.getImplicitHydrogenCount().intValue());
  }
  /**
   * Test for SF bug #1309731.
   *
   * @cdk.bug 1309731
   */
  @Test
  public void testModelBuilder3D_keepChemObjectIDs() throws Exception {
    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();

    IMolecule methanol = new org.openscience.cdk.Molecule();
    IChemObjectBuilder builder = methanol.getBuilder();

    IAtom carbon1 = builder.newInstance(IAtom.class, "C");
    carbon1.setID("carbon1");
    methanol.addAtom(carbon1);
    for (int i = 0; i < 3; i++) {
      IAtom hydrogen = builder.newInstance(IAtom.class, "H");
      methanol.addAtom(hydrogen);
      methanol.addBond(builder.newInstance(IBond.class, carbon1, hydrogen, IBond.Order.SINGLE));
    }
    IAtom oxygen1 = builder.newInstance(IAtom.class, "O");
    oxygen1.setID("oxygen1");
    methanol.addAtom(oxygen1);
    methanol.addBond(builder.newInstance(IBond.class, carbon1, oxygen1, IBond.Order.SINGLE));
    IAtom hydrogen = builder.newInstance(IAtom.class, "H");
    methanol.addAtom(hydrogen);
    methanol.addBond(builder.newInstance(IBond.class, hydrogen, oxygen1, IBond.Order.SINGLE));

    Assert.assertEquals(6, methanol.getAtomCount());
    Assert.assertEquals(5, methanol.getBondCount());

    mb3d.generate3DCoordinates(methanol, false);

    checkAverageBondLength(methanol);
    Assert.assertEquals("carbon1", carbon1.getID());
    Assert.assertEquals("oxygen1", oxygen1.getID());
  }
示例#4
0
  @Test
  public void testReading() throws Exception {
    String filename = "data/asn/pubchem/cid1145.xml";
    logger.info("Testing: " + filename);
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    PCCompoundXMLReader reader = new PCCompoundXMLReader(ins);
    IMolecule molecule = (IMolecule) reader.read(new Molecule());
    Assert.assertNotNull(molecule);

    // check atom stuff
    Assert.assertEquals(14, molecule.getAtomCount());
    Assert.assertEquals("O", molecule.getAtom(0).getSymbol());
    Assert.assertEquals(Integer.valueOf(-1), molecule.getAtom(0).getFormalCharge());
    Assert.assertEquals("N", molecule.getAtom(1).getSymbol());
    Assert.assertEquals(Integer.valueOf(1), molecule.getAtom(1).getFormalCharge());

    // check bond stuff
    Assert.assertEquals(13, molecule.getBondCount());
    Assert.assertNotNull(molecule.getBond(3));

    // coordinates
    Assert.assertNull(molecule.getAtom(0).getPoint3d());
    Point2d point = molecule.getAtom(0).getPoint2d();
    Assert.assertNotNull(point);
    Assert.assertEquals(3.7320508956909, point.x, 0.00000001);
    Assert.assertEquals(0.5, point.y, 0.00000001);
  }
  /**
   * Bug #1610997 says the modelbuilder does not work if 2d coordinates exist before - we test this
   * here
   *
   * @cdk.bug 1610997
   */
  @Test
  public void testModelBuilder3D_CCCCCCCCCC_with2d() throws Exception {
    Assume.assumeTrue(runSlowTests());

    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    String smile = "CCCCCCCCCC";
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles(smile);
    for (int i = 0; i < mol.getAtomCount(); i++) {
      mol.getAtom(i).setPoint2d(new Point2d(1, 1));
    }
    addExplicitHydrogens(mol);
    mol = mb3d.generate3DCoordinates(mol, false);
    for (int i = 0; i < mol.getAtomCount(); i++) {
      Assert.assertNotNull(mol.getAtom(i).getPoint3d());
    }
    checkAverageBondLength(mol);
  }
示例#6
0
 @Test
 public void testNNMolecule_int_int_int_int() {
   IMolecule m = new NNMolecule(5, 5, 1, 1);
   Assert.assertNotNull(m);
   Assert.assertEquals(0, m.getAtomCount());
   Assert.assertEquals(0, m.getBondCount());
   Assert.assertEquals(0, m.getLonePairCount());
   Assert.assertEquals(0, m.getSingleElectronCount());
 }
 /** Sets the format origin and tries to find a good title */
 protected void setMetaData(MoleculeType molMolecule, IMolecule molStructure) {
   if (molStructure != null) {
     if (molStructure.getProperty("cdk:Title") != null) {
       molMolecule.setTitle(molStructure.getProperty("cdk:Title").toString());
     } else {
       molMolecule.setTitle("Unknown molecule");
     }
     if (molStructure.getID() != null) {
       molMolecule.setId(molStructure.getID().toString());
     } else {
       molMolecule.setId("ID" + Integer.toString(molStructure.hashCode()));
     }
     if (molStructure.getAtomCount() > 0) {
       molMolecule.setCount((double) molStructure.getAtomCount());
     }
     // ToDo add additional properties from the >property block and/or M
     // block
   }
 }
  @Test
  public void testAtomElementType3() throws Exception {
    String cmlString = "<molecule id='m1'><atomArray atomID='a1' elementType='C'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
  }
  @Test
  public void testAtomId3() throws Exception {
    String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2 a3'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(3, mol.getAtomCount());
    IAtom atom = mol.getAtom(1);
    Assert.assertEquals("a2", atom.getID());
  }
示例#10
0
  @Test
  public void testBondStereo() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'><bondStereo dictRef='cml:H'/></bond></bondArray></molecule>";
    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertEquals(1, mol.getBondCount());
    IBond bond = mol.getBond(0);
    Assert.assertEquals(IBond.Stereo.DOWN, bond.getStereo());
  }
示例#11
0
  @Test
  public void testIsotopicMass() throws Exception {
    String cmlString =
        "<molecule><atomArray><atom id='a1' elementType=\"C\"><scalar dataType=\"xsd:float\" dictRef=\"cdk:isotopicMass\">12.0</scalar></atom></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertEquals(12.0, atom.getExactMass().doubleValue(), 0.01);
  }
示例#12
0
  @Test
  public void testBondAromatic2() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray atomID='a1 a2'/><bondArray><bond atomRefs='a1 a2' order='2'><bondType dictRef='cdk:aromaticBond'/></bond></bondArray></molecule>";
    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertEquals(1, mol.getBondCount());
    org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);
    Assert.assertEquals(CDKConstants.BONDORDER_DOUBLE, bond.getOrder());
    Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC));
  }
示例#13
0
  @Test
  public void testBondId() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertEquals(1, mol.getBondCount());
    org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);
    Assert.assertEquals("b1", bond.getID());
  }
示例#14
0
  @Test
  public void testMassNumber() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1' elementType='C' isotopeNumber='12'/></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertEquals(12, atom.getMassNumber().intValue());
  }
示例#15
0
  @Test
  public void testAtomicNumber() throws Exception {
    String cmlString =
        "<molecule><atomArray><atom id='a1' elementType=\"C\"><scalar dataType=\"xsd:integer\" dictRef=\"cdk:atomicNumber\">6</scalar></atom></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertEquals(6, atom.getAtomicNumber().intValue());
  }
示例#16
0
  @Test
  public void testFractional3D() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray atomID='a1 a2' xFract='0.0 0.1' yFract='1.2 1.3' zFract='2.1 2.5'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertNull(mol.getAtom(0).getPoint3d());
    Assert.assertNull(mol.getAtom(1).getPoint3d());
    Assert.assertNotNull(mol.getAtom(0).getFractionalPoint3d());
    Assert.assertNotNull(mol.getAtom(1).getFractionalPoint3d());
  }
示例#17
0
 @Test
 public void testModelBuilder3D_CccccC() throws Exception {
   ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
   String smile = "CccccC";
   SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
   IMolecule mol = sp.parseSmiles(smile);
   addExplicitHydrogens(mol);
   mol = mb3d.generate3DCoordinates(mol, false);
   for (int i = 0; i < mol.getAtomCount(); i++) {
     Assert.assertNotNull(mol.getAtom(i).getPoint3d());
   }
   checkAverageBondLength(mol);
   // logger.debug("Layout molecule with SMILE: "+smile);
 }
示例#18
0
  /** @cdk.bug 2142400 */
  @Test
  public void testHydrogenCount1() throws Exception {
    String cmlString =
        "<molecule><atomArray><atom id='a1' elementType='C' hydrogenCount='4'/></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertNotNull(atom);
    Assert.assertNotNull(atom.getImplicitHydrogenCount());
    Assert.assertEquals(4, atom.getImplicitHydrogenCount().intValue());
  }
示例#19
0
 @Test
 public void testModelBuilder3D_reserpine() throws Exception {
   ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
   String filename = "data/mdl/reserpine.mol";
   InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
   MDLV2000Reader reader = new MDLV2000Reader(ins);
   ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
   List containersList = ChemFileManipulator.getAllAtomContainers(chemFile);
   IMolecule ac = new NNMolecule((IAtomContainer) containersList.get(0));
   ac = mb3d.generate3DCoordinates(ac, false);
   for (int i = 0; i < ac.getAtomCount(); i++) {
     Assert.assertNotNull(ac.getAtom(i).getPoint3d());
   }
   checkAverageBondLength(ac);
 }
示例#20
0
  @Test
  public void testModelBuilder3D_Konstanz() throws Exception {
    Assume.assumeTrue(runSlowTests());

    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    String smile =
        "C12(-[H])-C3(-C(-[H])(-[H])-C(-C4(-C5(-C(-Cl)(-Cl)-C(-C-3-4-[H])(-Cl)-C(-Cl)(-[H])-C-5(-Cl)-[H])-Cl)-[H])(-[H])-C-2(-O-1)-[H])-[H]";
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles(smile);
    addExplicitHydrogens(mol);
    mol = mb3d.generate3DCoordinates(mol, false);
    for (int i = 0; i < mol.getAtomCount(); i++) {
      Assert.assertNotNull(mol.getAtom(i).getPoint3d());
    }
    checkAverageBondLength(mol);
  }
示例#21
0
  @Test
  public void testBond5() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray atomID='a1 a2 a3'/><bondArray atomRef1='a1 a1' atomRef2='a2 a3' order='1 1'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(3, mol.getAtomCount());
    Assert.assertEquals(2, mol.getBondCount());
    org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);
    Assert.assertEquals(2, bond.getAtomCount());
    Assert.assertEquals(IBond.Order.SINGLE, bond.getOrder());
    bond = mol.getBond(1);
    Assert.assertEquals(2, bond.getAtomCount());
    Assert.assertEquals(IBond.Order.SINGLE, bond.getOrder());
  }
示例#22
0
  @Test
  public void testMissing3DCoordinates() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1' xyz3='0.0 0.1 0.2'/><atom id='a2'/><atom id='a3' xyz3='0.1 0.0 0.2'/></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(3, mol.getAtomCount());
    IAtom atom1 = mol.getAtom(0);
    IAtom atom2 = mol.getAtom(1);
    IAtom atom3 = mol.getAtom(2);

    Assert.assertNotNull(atom1.getPoint3d());
    Assert.assertNull(atom2.getPoint3d());
    Assert.assertNotNull(atom3.getPoint3d());
  }
示例#23
0
  @Test
  public void testReading3DCoords() throws Exception {
    String filename = "data/asn/pubchem/cid176.xml";
    logger.info("Testing: " + filename);
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    PCCompoundXMLReader reader = new PCCompoundXMLReader(ins);
    IMolecule molecule = (IMolecule) reader.read(new Molecule());
    Assert.assertNotNull(molecule);

    // check atom stuff
    Assert.assertEquals(8, molecule.getAtomCount());
    Assert.assertNull(molecule.getAtom(0).getPoint2d());
    Point3d point = molecule.getAtom(0).getPoint3d();
    Assert.assertNotNull(point);
    Assert.assertEquals(-0.9598, point.x, 0.0001);
    Assert.assertEquals(1.5616, point.y, 0.0001);
    Assert.assertEquals(1.8714, point.z, 0.0001);
  }
示例#24
0
  @Test
  public void testBond4() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray atomID='a1 a2 a3'/><bondArray atomRef1='a1 a1' atomRef2='a2 a3' bondID='b1 b2'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(3, mol.getAtomCount());
    Assert.assertEquals(2, mol.getBondCount());
    org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);
    Assert.assertEquals(2, bond.getAtomCount());
    IAtom atom1 = bond.getAtom(0);
    IAtom atom2 = bond.getAtom(1);
    Assert.assertEquals("a1", atom1.getID());
    Assert.assertEquals("a2", atom2.getID());
    Assert.assertEquals("b2", mol.getBond(1).getID());
  }
  /** A unit test for JUnit with Methanol */
  @Test
  public void testPartialTotalChargeDescriptor_Methanol()
      throws ClassNotFoundException, CDKException, java.lang.Exception {
    double[] testResult = {
      0.28, -0.67, 0.0, 0.0, 0.0, 0.4
    }; /* from Merck Molecular Force Field. II. Thomas A. Halgren*/
    IAtomicDescriptor descriptor = new PartialTChargeMMFF94Descriptor();

    IMolecule mol = builder.newInstance(IMolecule.class);
    IAtom carbon = builder.newInstance(IAtom.class, Elements.CARBON);
    IAtom oxygen = builder.newInstance(IAtom.class, Elements.OXYGEN);
    // making sure the order matches the test results
    mol.addAtom(carbon);
    mol.addAtom(oxygen);
    mol.addBond(builder.newInstance(IBond.class, carbon, oxygen, CDKConstants.BONDORDER_SINGLE));
    addExplicitHydrogens(mol);

    for (int i = 0; i < mol.getAtomCount(); i++) {
      double result =
          ((DoubleResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).doubleValue();
      Assert.assertEquals(testResult[i], result, METHOD_ERROR);
    }
  }
示例#26
0
  @Test
  public void testNNMolecule_IAtomContainer() {
    IAtomContainer acetone = new org.openscience.cdk.AtomContainer();
    IAtom c1 = acetone.getBuilder().newAtom("C");
    IAtom c2 = acetone.getBuilder().newAtom("C");
    IAtom o = acetone.getBuilder().newAtom("O");
    IAtom c3 = acetone.getBuilder().newAtom("C");
    acetone.addAtom(c1);
    acetone.addAtom(c2);
    acetone.addAtom(c3);
    acetone.addAtom(o);
    IBond b1 = acetone.getBuilder().newBond(c1, c2, IBond.Order.SINGLE);
    IBond b2 = acetone.getBuilder().newBond(c1, o, IBond.Order.DOUBLE);
    IBond b3 = acetone.getBuilder().newBond(c1, c3, IBond.Order.SINGLE);
    acetone.addBond(b1);
    acetone.addBond(b2);
    acetone.addBond(b3);

    IMolecule m = new NNMolecule(acetone);
    Assert.assertNotNull(m);
    Assert.assertEquals(4, m.getAtomCount());
    Assert.assertEquals(3, m.getBondCount());
  }
  /**
   * Choose any possible quadruple of the set of atoms in ac and establish all of the possible
   * bonding schemes according to Faulon's equations.
   */
  public static List sample(IMolecule ac) {
    logger.debug("RandomGenerator->mutate() Start");
    List structures = new ArrayList();

    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;
  }