@Test public void testFingerprinter_int_int() throws java.lang.Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024); Assert.assertNotNull(fingerprinter); IAtomContainer mol = MoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet(); IAtomContainer frag1 = MoleculeFactory.makePyrrole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(frag1); BitSet bs1 = fingerprinter.getBitFingerprint(frag1).asBitSet(); Assert.assertTrue(FingerprinterTool.isSubset(bs, bs1)); }
@Test public void testSybylAtomTypePerceptionBenzene() throws CDKException, FileNotFoundException, IOException, BioclipseException, CoreException, InvocationTargetException { IAtomContainer ac = MoleculeFactory.makeBenzene(); ICDKMolecule mol = new CDKMolecule(ac); debug.perceiveSybylAtomTypes(mol); System.out.println("** BENZENE **"); System.out.println(AtomContainerDiff.diff(ac, mol.getAtomContainer())); for (int i = 0; i < mol.getAtomContainer().getAtomCount(); i++) { IAtom a = mol.getAtomContainer().getAtom(i); System.out.println("Atom: " + a.getSymbol() + i + ", type=" + a.getAtomTypeName()); } assertEquals("C.ar", mol.getAtomContainer().getAtom(0).getAtomTypeName()); assertEquals("C.ar", mol.getAtomContainer().getAtom(1).getAtomTypeName()); assertEquals("C.ar", mol.getAtomContainer().getAtom(2).getAtomTypeName()); assertEquals("C.ar", mol.getAtomContainer().getAtom(3).getAtomTypeName()); assertEquals("C.ar", mol.getAtomContainer().getAtom(4).getAtomTypeName()); assertEquals("C.ar", mol.getAtomContainer().getAtom(5).getAtomTypeName()); }
@Test public void testFindSSSR_IAtomContainer() { IAtomContainer molecule = MoleculeFactory.makeAlphaPinene(); SSSRFinder sssrFinder = new SSSRFinder(molecule); IRingSet ringSet = sssrFinder.findSSSR(); Assert.assertEquals(2, ringSet.getAtomContainerCount()); }
@Test public void testViaFlags() throws Exception { IMolecule molecule = MoleculeFactory.makeBenzene(); for (Iterator atoms = molecule.atoms().iterator(); atoms.hasNext(); ) { ((IAtom) atoms.next()).setFlag(CDKConstants.ISAROMATIC, true); } Assert.assertEquals(6, ((IntegerResult) descriptor.calculate(molecule).getValue()).intValue()); }
@Test public void testRegression() throws Exception { IAtomContainer mol1 = MoleculeFactory.makeIndole(); IAtomContainer mol2 = MoleculeFactory.makePyrrole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2); ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(); IBitFingerprint bs1 = fingerprinter.getBitFingerprint(mol1); Assert.assertEquals( "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!", 22, bs1.cardinality()); IBitFingerprint bs2 = fingerprinter.getBitFingerprint(mol2); Assert.assertEquals( "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!", 11, bs2.cardinality()); }
@Test public void testFingerprinterBitSetSize() throws Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024); Assert.assertNotNull(fingerprinter); IAtomContainer mol = MoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet(); Assert.assertEquals(1024, bs.length()); // highest set bit Assert.assertEquals(1024, bs.size()); // actual bit set size }
@Test public void testgetBitFingerprint_IAtomContainer() throws java.lang.Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(); IAtomContainer mol = MoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); IBitFingerprint bs = fingerprinter.getBitFingerprint(mol); Assert.assertNotNull(bs); Assert.assertEquals(fingerprinter.getSize(), bs.size()); }
@Test public void testCyclohexaneWithHydrogens() { IAtomContainer cyclohexane = MoleculeFactory.makeCyclohexane(); for (int i = 0; i < 6; i++) { addHydrogens(cyclohexane, cyclohexane.getAtom(i), 2); } String expected = "[C]([C]([C]([C,0]([H][H])[H][H])[H][H])" + "[C]([C]([C,0][H][H])[H][H])[H][H])"; String actual = this.canonicalStringFromMolecule(cyclohexane); Assert.assertEquals(expected, actual); }
@Test public void testCalculateMissingHydrogens_Aromatic() throws Exception { IAtomContainer pyrrole = MoleculeFactory.makePyrrole(); IAtom n = pyrrole.getAtom(1); IRingSet rs = (new SSSRFinder(pyrrole)).findSSSR(); IRing ring = (IRing) rs.getAtomContainer(0); for (int j = 0; j < ring.getBondCount(); j++) { ring.getBond(j).setFlag(CDKConstants.ISAROMATIC, true); } Assert.assertEquals(5, ring.getBondCount()); Assert.assertEquals(1, satcheck.calculateNumberOfImplicitHydrogens(n, pyrrole)); }
@Test public void testAtomPermutation2() throws CDKException { IAtomContainer pamine = MoleculeFactory.makeCyclopentane(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(pamine); ShortestPathFingerprinter fp = new ShortestPathFingerprinter(); IBitFingerprint bs1 = fp.getBitFingerprint(pamine); AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine); while (acp.hasNext()) { IAtomContainer container = acp.next(); IBitFingerprint bs2 = fp.getBitFingerprint(container); Assert.assertTrue(bs1.equals(bs2)); } }
/** A unit test for JUnit */ @Test public void testEthylPropylPhenantren() throws Exception { IAtomContainer mol1 = MoleculeFactory.makeEthylPropylPhenantren(); SmilesGenerator sg = new SmilesGenerator(); fixCarbonHCount(mol1); String smiles1 = null; if (standAlone) { display(mol1); } smiles1 = sg.createSMILES(mol1); if (standAlone) { System.err.println("SMILES 1: " + smiles1); } Assert.assertNotNull(smiles1); Assert.assertEquals("c2cc1c3ccc(cc3(ccc1c(c2)CC))CCC", smiles1); }
@Test public void testQuinone() throws Exception { IAtomContainer mol = MoleculeFactory.makeQuinone(); Assert.assertNotNull("Created molecule was null", mol); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); CDKHueckelAromaticityDetector.detectAromaticity(mol); EquivalentClassPartitioner partitioner = new EquivalentClassPartitioner(mol); int[] eqCl = partitioner.getTopoEquivClassbyHuXu(mol); Partition autP = ArrayToPartition.convert(eqCl, 1); Assert.assertEquals("Wrong number of equivalent classes", 3, autP.size()); Partition expected = Partition.fromString("0,7|1,4|2,3,5,6"); Assert.assertEquals("Wrong class assignment", expected, autP); }
/** A unit test for JUnit */ @Test public void testSmilesGenerator() { IAtomContainer mol2 = MoleculeFactory.makeAlphaPinene(); SmilesGenerator sg = new SmilesGenerator(); fixCarbonHCount(mol2); String smiles2 = null; if (standAlone) { display(mol2); } try { smiles2 = sg.createSMILES(mol2); } catch (Exception exc) { System.out.println(exc); if (!standAlone) { Assert.fail(); } } if (standAlone) { System.err.println("SMILES 2: " + smiles2); } Assert.assertNotNull(smiles2); Assert.assertEquals("C1=C(C)C2CC(C1)C2(C)(C)", smiles2); }
/** A unit test for JUnit */ @Test public void testPropylCycloPropane() { IAtomContainer mol1 = MoleculeFactory.makePropylCycloPropane(); SmilesGenerator sg = new SmilesGenerator(); fixCarbonHCount(mol1); String smiles1 = null; if (standAlone) { display(mol1); } try { smiles1 = sg.createSMILES(mol1); } catch (Exception exc) { System.out.println(exc); if (!standAlone) { Assert.fail(); } } if (standAlone) { System.err.println("SMILES 1: " + smiles1); } Assert.assertNotNull(smiles1); Assert.assertEquals("CCCC1CC1", smiles1); }
@Test public void testSSSRFinder_IAtomContainer() { IAtomContainer molecule = MoleculeFactory.makeAlphaPinene(); SSSRFinder finder = new SSSRFinder(molecule); Assert.assertNotNull(finder); }