@Override public IBitFingerprint getBitFingerprint(IAtomContainer container) throws CDKException { final BitSetFingerprint bf = new BitSetFingerprint(getSize()); final ICountFingerprint icfp = circularFingerprinter.getCountFingerprint(container); for (int k=0, n = icfp.numOfPopulatedbins(); k < n; ++k) { final int index = HASH_SET.get(icfp.getHash(k)); if (index >= 0) { if (icfp.getCount(k)>0) bf.set(index, true); } } return bf; }
@Test public void testGetCountFingerprint() throws Exception { assert (trivialMol != null); CircularFingerprinter circ = new CircularFingerprinter(); ICountFingerprint result = circ.getCountFingerprint(trivialMol); final int[] ANSWER_KEY = {-414937772, 1, -1027418143, 1, 1627608083, 1, -868007456, 1, -1006701866, 1, -1059145289, 1, -801752141, 1, 790592664, 1, -289109509, 1, -1650154758, 1, 1286833445, 1}; int wantBits = ANSWER_KEY.length >> 1; boolean fail = result.numOfPopulatedbins() != wantBits; for (int n = 0; !fail && n < result.numOfPopulatedbins(); n++) { int gotHash = result.getHash(n), gotCount = result.getCount(n); boolean found = false; for (int i = 0; i < wantBits; i++) { int wantHash = ANSWER_KEY[i * 2], wantCount = ANSWER_KEY[i * 2 + 1]; if (gotHash == wantHash) { found = true; if (gotCount != wantCount) throw new CDKException("For hash " + gotHash + " got count " + gotCount + " but wanted " + wantCount); } } if (!found) { fail = true; break; } } if (fail) throw new CDKException("Hash values do not match."); }