@Override public IFingerprinter getBitFingerprinter() { return new GraphOnlyFingerprinter(); }
public BitSet getBitFingerprint(IAtomContainer container, int size) throws Exception { BitSet bitSet = new BitSet(size); encodePaths(container, super.getSearchDepth(), bitSet, size); return bitSet; } }
@Test public void testFingerprint() throws Exception { SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance()); IFingerprinter printer = new GraphOnlyFingerprinter(); IBitFingerprint bs1 = printer.getBitFingerprint(parser.parseSmiles("C=C-C#N")); IBitFingerprint bs2 = printer.getBitFingerprint(parser.parseSmiles("CCCN")); Assert.assertEquals(bs1, bs2); }
/** * This basic test case shows that some molecules will not be considered * as a subset of each other by Fingerprint.isSubset(), for the getBitFingerprint(), * despite the fact that they are a sub graph of each other according to the * UniversalIsomorphismTester.isSubgraph(). * * @author Hugo Lafayette <hugo.lafayette@laposte.net> * * @throws CloneNotSupportedException * @throws Exception * * @cdk.bug 1626894 * */ @Test public void testFingerPrint() throws Exception { IFingerprinter printer = new GraphOnlyFingerprinter(); IAtomContainer mol1 = createMolecule(molecule_test_2); IAtomContainer mol2 = createMolecule(ethanolamine); Assert.assertTrue("SubGraph does NOT match", new UniversalIsomorphismTester().isSubgraph(mol1, mol2)); BitSet bs1 = printer.getBitFingerprint((IAtomContainer) mol1.clone()).asBitSet(); BitSet bs2 = printer.getBitFingerprint((IAtomContainer) mol2.clone()).asBitSet(); Assert.assertTrue("Subset (with fingerprint) does NOT match", FingerprinterTool.isSubset(bs1, bs2)); // Match OK logger.debug("Subset (with fingerprint) does match"); }