@Override public IBitFingerprint getBitFingerprint(IAtomContainer iAtomContainer) throws CDKException { return FingerprinterTool.makeBitFingerprint(getRawFingerprint(iAtomContainer)); }
@Override public ICountFingerprint getCountFingerprint(IAtomContainer container) throws CDKException { return FingerprinterTool.makeCountFingerprint(getRawFingerprint(container)); }
@Test @Override public void testGetRawFingerprint() throws Exception { LingoFingerprinter lfp = new LingoFingerprinter(3); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("SPONC"); Map<String, Integer> map = lfp.getRawFingerprint(mol); Assert.assertEquals(3, map.size()); // depend on canonical ordering of the SMILES since lingos uses Unique SMILES String[] subs = {"PON", "ONC", "SPO"}; for (String s : subs) Assert.assertTrue(map.containsKey(s)); } }
@Test public void testExactMatch() throws Exception { IAtomContainer mol1 = TestMoleculeFactory.makeIndole(); IAtomContainer mol2 = TestMoleculeFactory.makeIndole(); addImplicitHydrogens(mol1); addImplicitHydrogens(mol2); LingoFingerprinter fingerprinter = new LingoFingerprinter(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2); Map<String, Integer> feat1 = fingerprinter.getRawFingerprint(mol1); Map<String, Integer> feat2 = fingerprinter.getRawFingerprint(mol2); float tanimoto = Tanimoto.calculate(feat1, feat2); Assert.assertEquals(1.0, tanimoto, 0.001); }
@Test public void testLingoSim() throws Exception { IAtomContainer mol1 = TestMoleculeFactory.makeIndole(); IAtomContainer mol2 = TestMoleculeFactory.makeIndole(); addImplicitHydrogens(mol1); addImplicitHydrogens(mol2); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2); LingoFingerprinter fingerprinter = new LingoFingerprinter(); Map<String, Integer> bs1 = fingerprinter.getRawFingerprint(mol1); Map<String, Integer> bs2 = fingerprinter.getRawFingerprint(mol2); float lingosim = LingoSimilarity.calculate(bs1, bs2); Assert.assertEquals(1.0, lingosim, 0.01); }