Example #1
0
 @Test
 public void testGetAtomContainerCount() throws Exception {
   SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
   IAtomContainer molecule = sp.parseSmiles("c1ccccc1");
   IRingSet ringSet = new SSSRFinder(molecule).findSSSR();
   Assert.assertEquals(1, ringSet.getAtomContainerCount());
 }
 private List order6(IAtomContainer atomContainer) {
   QueryAtomContainer[] queries = new QueryAtomContainer[5];
   try {
     queries[0] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)(C)CCC"), false);
     queries[1] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)C(C)CC"), false);
     queries[2] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)CC(C)C"), false);
     queries[3] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CC(C)CCCC"), false);
     queries[4] =
         QueryAtomContainerCreator.createAnyAtomAnyBondContainer(
             sp.parseSmiles("CCC(C)CCC"), false);
   } catch (InvalidSmilesException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
   return ChiIndexUtils.getFragments(atomContainer, queries);
 }
Example #3
0
 /** @cdk.bug 826942 */
 @Test
 public void testSFBug826942() throws Exception {
   SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
   IAtomContainer molecule = sp.parseSmiles("C1CCC2C(C1)C4CCC3(CCCCC23)(C4)");
   IRingSet ringSet = new SSSRFinder(molecule).findSSSR();
   Assert.assertEquals(4, ringSet.getAtomContainerCount());
 }
  @Test
  public void testfp2() throws Exception {
    SmilesParser parser = new SmilesParser(NoNotificationChemObjectBuilder.getInstance());
    IFingerprinter printer = new MACCSFingerprinter();

    IMolecule mol1 = parser.parseSmiles("CC(N)CCCN");
    IMolecule mol2 = parser.parseSmiles("CC(N)CCC");
    IMolecule mol3 = parser.parseSmiles("CCCC");

    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol3);

    CDKHueckelAromaticityDetector.detectAromaticity(mol1);
    CDKHueckelAromaticityDetector.detectAromaticity(mol2);
    CDKHueckelAromaticityDetector.detectAromaticity(mol3);

    BitSet bs1 = printer.getFingerprint(mol1);
    BitSet bs2 = printer.getFingerprint(mol2);
    BitSet bs3 = printer.getFingerprint(mol3);

    Assert.assertFalse(bs1.get(124));
    Assert.assertFalse(bs2.get(124));
    Assert.assertFalse(bs3.get(124));

    Assert.assertFalse(FingerprinterTool.isSubset(bs1, bs2));
    Assert.assertTrue(FingerprinterTool.isSubset(bs2, bs3));
  }
Example #5
0
  /** @cdk.bug 1535055 */
  @Test
  public void testBug1535055() throws Exception {
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer mol = sp.parseSmiles("COC(=O)c1ccc2c(c1)c1ccccc1[nH]2");
    CDKHueckelAromaticityDetector.detectAromaticity(mol);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    SmilesGenerator sg = new SmilesGenerator();
    sg.setUseAromaticityFlag(true);
    String s1 = sg.createSMILES(mol);

    String filename = "data/cml/bug1535055.cml";
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    CMLReader reader = new CMLReader(ins);
    IChemFile chemFile = (IChemFile) reader.read(new ChemFile());

    // test the resulting ChemFile content
    Assert.assertNotNull(chemFile);
    IAtomContainer mol2 = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
    CDKHueckelAromaticityDetector.detectAromaticity(mol2);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2);
    String s2 = sg.createSMILES(mol2);

    Assert.assertTrue(s1.contains("[nH]"));
    Assert.assertTrue(s2.contains("[nH]"));
  }
 @Test
 public void testAromaticAtomsCountDescriptor() throws java.lang.Exception {
   Object[] params = {true};
   descriptor.setParameters(params);
   SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
   IAtomContainer mol = sp.parseSmiles("CCOc1ccccc1"); // ethanol
   Assert.assertEquals(6, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
 }
Example #7
0
  @Test
  public void testVdWRadiusDescriptor()
      throws ClassNotFoundException, CDKException, java.lang.Exception {
    double[] testResult = {1.7};
    IAtomicDescriptor descriptor = new VdWRadiusDescriptor();
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles("NCCN(C)(C)");
    double retval =
        ((DoubleResult) descriptor.calculate(mol.getAtom(1), mol).getValue()).doubleValue();

    Assert.assertEquals(testResult[0], retval, 0.01);
  }
Example #8
0
  /**
   * @cdk.bug 1965254
   * @throws Exception
   */
  @Test
  public void testjunk() throws Exception {

    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer molecule = sp.parseSmiles("COC1=CC2=C(C=C1)NC3=C2CCNC3");

    TemplateHandler3D template = TemplateHandler3D.getInstance();
    ModelBuilder3D mb3d = ModelBuilder3D.getInstance(template, "mm2");
    molecule = mb3d.generate3DCoordinates(molecule, true);
    DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);

    engine.process(molecule);
  }
  @Test
  public void testGenerateFingerprintNaphthalene() throws InvalidSmilesException, Exception {

    String smiles = "C1=CC2=CC=CC=C2C=C1";
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer molecule = smilesParser.parseSmiles(smiles);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
    Aromaticity.cdkLegacy().apply(molecule);
    ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
    BitSet fingerprint1;
    fingerprint1 = fingerprint.getBitFingerprint(molecule).asBitSet();
    org.junit.Assert.assertEquals(8, fingerprint1.cardinality());
  }
 @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);
 }
Example #11
0
  @Test
  public void testRingFlags1() throws Exception {
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer molecule = sp.parseSmiles("c1ccccc1");
    new SSSRFinder(molecule).findSSSR();

    int count = 0;
    Iterator atoms = molecule.atoms().iterator();
    while (atoms.hasNext()) {
      IAtom atom = (IAtom) atoms.next();
      if (atom.getFlag(CDKConstants.ISINRING)) count++;
    }
    Assert.assertEquals("All atoms in benzene were not marked as being in a ring", 6, count);
  }
Example #12
0
  /**
   * Checks if the given structures are isomorph.
   *
   * @param candidate1 the candidate1
   * @param candidate2 the candidate2
   * @return true, if is isomorph
   * @throws CDKException the CDK exception
   */
  public boolean isIsomorph(String candidate1, String candidate2) throws CDKException {
    IAtomContainer cand1 = null;
    IAtomContainer cand2 = null;

    if (hasAtomContainer) {
      cand1 = this.candidateToStructure.get(candidate1);
      cand2 = this.candidateToStructure.get(candidate2);
    } else {
      SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
      cand1 = sp.parseSmiles(candidatesToSmiles.get(candidate1));
      cand2 = sp.parseSmiles(candidatesToSmiles.get(candidate2));
    }

    return UniversalIsomorphismTester.isIsomorph(cand1, cand2);
  }
  @Test
  public void testModelBuilder3D_C1CCCCCCC1CC() throws Exception {
    Assume.assumeTrue(runSlowTests());

    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    String smile = "C1CCCCCCC1CC";
    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);
  }
 private void updatePageComplete(Text field) {
   setPageComplete(false);
   String smiles = field.getText();
   if (smiles.length() != 0) {
     SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
     try {
       parser.parseSmiles(smiles);
       wizard.setSMILES(smiles);
     } catch (InvalidSmilesException exception) {
       setMessage(exception.getMessage());
       setErrorMessage("The given SMILES is invalid.");
       return;
     }
   }
   setPageComplete(true);
   setMessage(null);
   setErrorMessage(null);
 }
Example #15
0
File: Misc.java Project: egonw/cdkr
  public static void main(String[] args) throws Exception, CloneNotSupportedException, IOException {
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer mol1 = sp.parseSmiles("c1cccc(COC(=O)NC(CC(C)C)C(=O)NC(CCc2ccccc2)C(=O)COC)c1");
    IAtomContainer mol2 = sp.parseSmiles("c1cccc(COC(=O)NC(CC(C)C)C(=O)NCC#N)c1");
    CDKHueckelAromaticityDetector.detectAromaticity(mol1);
    CDKHueckelAromaticityDetector.detectAromaticity(mol2);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1);
    IAtomContainer mcs = getMcsAsNewContainer(mol1, mol2);
    MoleculeImage mi = new MoleculeImage(mcs);
    byte[] bytes = mi.getBytes(300, 300);
    FileOutputStream fos = new FileOutputStream("test.png");
    fos.write(bytes);

    int[][] map = getMcsAsAtomIndexMapping(mol1, mol2);
    for (int i = 0; i < map.length; i++) {
      System.out.println(map[i][0] + " <-> " + map[i][1]);
    }
  }
  /**
   * Test of ShortestPathFingerprinter method
   *
   * @throws InvalidSmilesException
   * @throws CDKException
   */
  @Test
  public void testGenerateFingerprintIsSubset() throws InvalidSmilesException, CDKException {

    String smilesT = "NC(=O)C1=C2C=CC(Br)=CC2=C(Cl)C=C1";
    String smilesQ = "CC1=C2C=CC(Br)=CC2=C(Cl)C=C1";
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer moleculeQ = smilesParser.parseSmiles(smilesQ);
    IAtomContainer moleculeT = smilesParser.parseSmiles(smilesT);

    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeQ);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeT);

    ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
    BitSet fingerprintQ;
    BitSet fingerprintT;
    fingerprintQ = fingerprint.getBitFingerprint(moleculeQ).asBitSet();
    fingerprintT = fingerprint.getBitFingerprint(moleculeT).asBitSet();

    org.junit.Assert.assertTrue(FingerprinterTool.isSubset(fingerprintT, fingerprintQ));
  }
  //  A unit test for JUnit with methylenfluoride\
  @Test
  public void testModelBuilder3D_CF() throws Exception {
    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    Point3d c_coord = new Point3d(1.392, 0.0, 0.0);
    Point3d f_coord = new Point3d(0.0, 0.0, 0.0);
    Point3d h1_coord = new Point3d(1.7439615035767404, 1.0558845107302222, 0.0);
    Point3d h2_coord = new Point3d(1.7439615035767404, -0.5279422553651107, 0.914422809754875);
    Point3d h3_coord = new Point3d(1.7439615035767402, -0.5279422553651113, -0.9144228097548747);

    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles("CF");
    addExplicitHydrogens(mol);
    // mb3d.setTemplateHandler();
    mol = mb3d.generate3DCoordinates(mol, false);
    assertEquals(c_coord, mol.getAtom(0).getPoint3d(), 0.0001);
    assertEquals(f_coord, mol.getAtom(1).getPoint3d(), 0.0001);
    assertEquals(h1_coord, mol.getAtom(2).getPoint3d(), 0.0001);
    assertEquals(h2_coord, mol.getAtom(3).getPoint3d(), 0.0001);
    assertEquals(h3_coord, mol.getAtom(4).getPoint3d(), 0.0001);
    checkAverageBondLength(mol);
  }
Example #18
0
 @Test
 public void methylFerroceneTest() throws Exception {
   String smiles = "CC12C3C4C5C1[Fe]23456789C%10C6C7C8C9%10";
   IAtomContainer mol = parser.parseSmiles(smiles);
   MoleculeSignature molSig = new MoleculeSignature(mol);
   int feIndex = findFirstAtomIndexForSymbol(mol, "Fe");
   String sigForIron = molSig.signatureStringForVertex(feIndex);
   String expected =
       "[Fe]([C]([C,3][C,4])[C,3]([C,1])[C,4]([C,0])"
           + "[C]([C,5][C,6])[C,5]([C,2])[C,6]([C,7])"
           + "[C,7]([C][C,2])[C,0]([C,1])[C,1][C,2])";
   Assert.assertEquals(expected, sigForIron);
 }
Example #19
0
  private IAtomContainer parseSMILES() {
    if (SMILES_PARSER == null) {
      SMILES_PARSER = new SmilesParser(SilentChemObjectBuilder.getInstance());
    }
    try {
      atomContainer = new AtomContainer(SMILES_PARSER.parseSmiles(getValue()));
    } catch (CDKException ex) {
      LOGGER.error("Could not parse SMILES ", ex);
      atomContainer = new AtomContainer();
    }

    return atomContainer;
  }
  /**
   * Test of ShortestPathFingerprinter method
   *
   * @throws InvalidSmilesException
   * @throws CDKException
   * @throws FileNotFoundException
   */
  @Test
  public void testGenerateFingerprintIsNotASubset1()
      throws InvalidSmilesException, CDKException, FileNotFoundException, FileNotFoundException {

    String smilesT = "O[C@H]1[C@H](O)[C@@H](O)[C@H](O)[C@H](O)[C@@H]1O";
    String smilesQ = "OC[C@@H](O)[C@@H](O)[C@H](O)[C@@H](O)C(O)=O";
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    smilesParser.kekulise(false);
    IAtomContainer moleculeQ = smilesParser.parseSmiles(smilesQ);

    IAtomContainer moleculeT = smilesParser.parseSmiles(smilesT);

    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeQ);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeT);

    ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
    BitSet fingerprintQ;
    BitSet fingerprintT;
    fingerprintQ = fingerprint.getBitFingerprint(moleculeQ).asBitSet();
    fingerprintT = fingerprint.getBitFingerprint(moleculeT).asBitSet();
    org.junit.Assert.assertFalse(FingerprinterTool.isSubset(fingerprintT, fingerprintQ));
  }
Example #21
0
 @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.createSMILES(frag));
   }
   Assert.assertEquals(2, uniqueFrags.size());
   // You can put the fragments back together with a ring closure and dot
   // [CH]12CC1.[CH]12CCC1
   Assert.assertThat(uniqueFrags, hasItems("[CH]1CC1", "[CH]1CCC1"));
 }
Example #22
0
  @Test
  public void unionMolecules() throws IOException, CDKException {
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer mol1 = sp.parseSmiles("OOC1=CC=CC=C1");
    IAtomContainer mol2 = sp.parseSmiles("c1ccc(cc1)c2ccccc2");
    int i = 0;
    for (IAtom atom1 : mol1.atoms()) {
      atom1.setID(String.valueOf((i++)));
    }
    int j = 0;
    for (IAtom atom2 : mol2.atoms()) {
      atom2.setID(String.valueOf((j++)));
    }

    MoleculeSanityCheck.aromatizeMolecule(mol1);
    MoleculeSanityCheck.aromatizeMolecule(mol2);

    Isomorphism isomorphism = new Isomorphism(mol1, mol2, Algorithm.DEFAULT, true, false, false);
    isomorphism.setChemFilters(false, false, false);

    int combinations = 1;

    List<String> acSet = new ArrayList<String>();

    if (isomorphism.getFirstAtomMapping() != null) {

      for (AtomAtomMapping mapping : isomorphism.getAllAtomMapping()) {

        IAtomContainer union = new AtomContainer();

        for (IAtom atom : mol1.atoms()) {
          union.addAtom(atom);
        }

        for (IBond bond : mol1.bonds()) {
          union.addBond(bond);
        }

        for (IBond bond : mol2.bonds()) {
          IAtom a1 = bond.getAtom(0);
          IAtom a2 = bond.getAtom(1);

          if (!mapping.getMappingsByAtoms().containsValue(a1)
              && !mapping.getMappingsByAtoms().containsValue(a2)) {
            if (!union.contains(a1)) {
              union.addAtom(a1);
            }
            if (!union.contains(a2)) {
              union.addAtom(a2);
            }
            union.addBond(bond);
          } else if (mapping.getMappingsByAtoms().containsValue(a1)
              && !mapping.getMappingsByAtoms().containsValue(a2)) {
            if (!union.contains(a2)) {
              union.addAtom(a2);
            }
            union.addBond(
                new Bond(
                    a2,
                    getKey(a1, mapping.getMappingsByAtoms()),
                    bond.getOrder(),
                    bond.getStereo()));
          } else if (!mapping.getMappingsByAtoms().containsValue(a1)
              && mapping.getMappingsByAtoms().containsValue(a2)) {
            if (!union.contains(a1)) {
              union.addAtom(a1);
            }
            union.addBond(
                new Bond(
                    a1,
                    getKey(a2, mapping.getMappingsByAtoms()),
                    bond.getOrder(),
                    bond.getStereo()));
          }
        }
        /*check if this combination is chemically valid*/
        if (isChemicallyValid(union)) {
          String molSMILES = getSMILES(union).toString();
          if (!acSet.contains(molSMILES)) {
            acSet.add(molSMILES);
          }
        }
      }
    }

    //        for (String container : acSet) {
    // System.out.println("\n-------------" + " Combination " + combinations++ +
    // "--------------------");
    // System.out.println("Query SMILES " + getSMILES(mol1).toString() + ", count " +
    // mol1.getAtomCount());
    // System.out.println("Target SMILES " + getSMILES(mol2).toString() + ", count " +
    // mol2.getAtomCount());
    // System.out.println("Union SMILES " + container + ", count " +
    // sp.parseSmiles(container).getAtomCount());
    //        }
  }
Example #23
0
 @Test
 public void threeMethylSulphanylPropanal() throws Exception {
   String smiles = "O=CCCSC";
   fullPermutationTest(parser.parseSmiles(smiles));
 }
Example #24
0
 public String canonicalStringFromSmiles(String smiles) throws InvalidSmilesException {
   IAtomContainer mol = parser.parseSmiles(smiles);
   MoleculeSignature signature = new MoleculeSignature(mol);
   return signature.toCanonicalString();
 }
Example #25
0
  /**
   * Returns a similarity matrix based on the tanimoto distance of the fingerprints. (Upper
   * triangular matrix)
   *
   * @param molList the mol list
   * @param similarityThreshold the similarity threshold
   * @return the float[][]
   * @throws CDKException the CDK exception
   */
  private float[][] calculateSimilarity(boolean completeMatrix) throws CDKException {
    Map<String, BitSet> candidateToFingerprint = new HashMap<String, BitSet>();

    if (hasAtomContainer) {
      for (String strCandidate : candidateToStructure.keySet()) {
        Fingerprinter f = new Fingerprinter();
        BitSet fp = f.getFingerprint(candidateToStructure.get(strCandidate));
        candidateToFingerprint.put(strCandidate, fp);
      }
    } else {
      SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
      for (String string : candidatesToSmiles.keySet()) {
        try {
          IMolecule mol = sp.parseSmiles(candidatesToSmiles.get(string));
          Fingerprinter f = new Fingerprinter();
          BitSet fp = f.getFingerprint(mol);
          candidateToFingerprint.put(string, fp);
        } catch (Exception e) {
          System.err.println("Error in smiles!" + e.getMessage());
        }
      }
    }

    int countJ = 0;
    int countI = 0;

    if (!hasAtomContainer) {
      for (String candidate1 : candidatesToSmiles.keySet()) {
        //			System.out.print(candidate1 + " ");
        for (String candidate2 : candidatesToSmiles.keySet()) {
          if ((countJ < countI || candidate1.equals(candidate2)) && !completeMatrix) {
            //					System.out.print("x ");
            countJ++;
            continue;
          }
          float similarity =
              compareFingerprints(
                  candidateToFingerprint.get(candidate1), candidateToFingerprint.get(candidate2));
          matrix[countI][countJ] = similarity;
          // allSimilarityValues.append(similarity + "\n");

          countJ++;
          //				System.out.print(compareFingerprints(candidateToFingerprint.get(candidate1),
          // candidateToFingerprint.get(candidate2)) + " ");
        }
        countJ = 0;
        countI++;
        //			System.out.println("");
      }
    } else {
      for (String candidate1 : candidateToStructure.keySet()) {
        //			System.out.print(candidate1 + " ");
        for (String candidate2 : candidateToStructure.keySet()) {
          if ((countJ < countI || candidate1.equals(candidate2)) && !completeMatrix) {
            //					System.out.print("x ");
            countJ++;
            continue;
          }
          float similarity =
              compareFingerprints(
                  candidateToFingerprint.get(candidate1), candidateToFingerprint.get(candidate2));
          matrix[countI][countJ] = similarity;
          // allSimilarityValues.append(similarity + "\n");

          countJ++;
          //				System.out.print(compareFingerprints(candidateToFingerprint.get(candidate1),
          // candidateToFingerprint.get(candidate2)) + " ");
        }
        countJ = 0;
        countI++;
        //			System.out.println("");
      }
    }

    return matrix;
  }
  /*
   * this is a test contributed by mario baseda / see bug #1610997
   *  @cdk.bug 1610997
   */
  @Test
  public void testModel3D_bug_1610997() throws Exception {
    Assume.assumeTrue(runSlowTests());

    boolean notCalculatedResults = false;
    List inputList = new ArrayList();

    ////////////////////////////////////////////////////////////////////////////////////////////
    // generate the input molecules. This are molecules without x, y, z coordinats

    String[] smiles =
        new String[] {
          "CC",
          "OCC",
          "O(C)CCC",
          "c1ccccc1",
          "C(=C)=C",
          "OCC=CCc1ccccc1(C=C)",
          "O(CC=C)CCN",
          "CCCCCCCCCCCCCCC",
          "OCC=CCO",
          "NCCCCN"
        };
    SmilesParser sp = new SmilesParser(NoNotificationChemObjectBuilder.getInstance());
    IAtomContainer[] atomContainer = new IAtomContainer[smiles.length];
    for (int i = 0; i < smiles.length; i++) {
      atomContainer[i] = sp.parseSmiles(smiles[i]);

      inputList.add(atomContainer[i]);
    }
    System.out.println(inputList.size());
    ///////////////////////////////////////////////////////////////////////////////////////////
    // Generate 2D coordinats for the input molecules with the Structure Diagram Generator

    StructureDiagramGenerator str;
    List resultList = new ArrayList();
    for (Iterator iter = inputList.iterator(); iter.hasNext(); ) {
      IAtomContainer molecules = (IAtomContainer) iter.next();
      str = new StructureDiagramGenerator();
      str.setMolecule((IMolecule) molecules);
      str.generateCoordinates();
      resultList.add(str.getMolecule());
    }
    inputList = resultList;

    /////////////////////////////////////////////////////////////////////////////////////////////
    // Delete x and y coordinats

    for (Iterator iter = inputList.iterator(); iter.hasNext(); ) {
      IAtomContainer molecules = (IAtomContainer) iter.next();
      for (Iterator atom = molecules.atoms().iterator(); atom.hasNext(); ) {
        Atom last = (Atom) atom.next();
        last.setPoint2d(null);
      }
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // Test for the method Model3DBuildersWithMM2ForceField

    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    for (Iterator iter = inputList.iterator(); iter.hasNext(); ) {
      IAtomContainer molecules = (IAtomContainer) iter.next();
      IMolecule mol = molecules.getBuilder().newInstance(IMolecule.class, molecules);
      mol = mb3d.generate3DCoordinates(mol, false);
      System.out.println("Calculation done");
    }

    for (Iterator iter = inputList.iterator(); iter.hasNext(); ) {
      IAtomContainer molecule = (IAtomContainer) iter.next();
      checkAverageBondLength(molecule);
      for (Iterator atom = molecule.atoms().iterator(); atom.hasNext(); ) {
        Atom last = (Atom) atom.next();
        if (last.getPoint3d() == null) notCalculatedResults = true;
      }
    }
    Assert.assertFalse(notCalculatedResults);
  }