CircularFingerprinter extends AbstractFingerprinter implements IFingerprinter { @Override public ICountFingerprint getCountFingerprint(IAtomContainer mol) throws CDKException { calculate(mol); final Map<Integer, Integer> map = new TreeMap<Integer, Integer>(); for (FP fp : fplist) { if (map.containsKey(fp.hashCode)) map.put(fp.hashCode, map.get(fp.hashCode) + 1); else map.put(fp.hashCode, 1); } final int sz = map.size(); final int[] hash = new int[sz], count = new int[sz]; int n = 0; for (int h : map.keySet()) { hash[n] = h; count[n++] = map.get(h); } return new ICountFingerprint() { @Override public long size() { return 4294967296l; } @Override public int numOfPopulatedbins() { return sz; } @Override public int getCount(int index) { return count[index]; } @Override public int getHash(int index) { return hash[index]; } @Override public void merge(ICountFingerprint fp) {} @Override public void setBehaveAsBitFingerprint(boolean behaveAsBitFingerprint) {} @Override public boolean hasHash(int hash) { return map.containsKey(hash); } @Override public int getCountForHash(int hash) { return map.containsKey(hash) ? map.get(hash) : 0; } }; } CircularFingerprinter();  CircularFingerprinter(int classType);  CircularFingerprinter(int classType, int len); void setPerceiveStereo(boolean val); void calculate(IAtomContainer mol); int getFPCount(); FP getFP(int N); @Override IBitFingerprint getBitFingerprint(IAtomContainer mol); @Override ICountFingerprint getCountFingerprint(IAtomContainer mol); @Override Map<String, Integer> getRawFingerprint(IAtomContainer mol); @Override int getSize(); static final int CLASS_ECFP0; static final int CLASS_ECFP2; static final int CLASS_ECFP4; static final int CLASS_ECFP6; static final int CLASS_FCFP0; static final int CLASS_FCFP2; static final int CLASS_FCFP4; static final int CLASS_FCFP6; }
@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."); }