CircularFingerprinter extends AbstractFingerprinter implements IFingerprinter { @Override public IBitFingerprint getBitFingerprint(IAtomContainer mol) throws CDKException { calculate(mol); final BitSet bits = new BitSet(length); for (int n = 0; n < fplist.size(); n++) { int i = fplist.get(n).hashCode; long b = i >= 0 ? i : ((i & 0x7FFFFFFF) | (1L << 31)); bits.set((int) (b % length)); } return new BitSetFingerprint(bits); } 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 testGetBitFingerprint() throws Exception { assert (trivialMol != null); CircularFingerprinter circ = new CircularFingerprinter(); IBitFingerprint result = circ.getBitFingerprint(trivialMol); BitSet wantBits = new BitSet(), gotBits = result.asBitSet(); final int[] REQUIRE_BITS = {19, 152, 293, 340, 439, 480, 507, 726, 762, 947, 993}; for (int b : REQUIRE_BITS) wantBits.set(b); if (!wantBits.equals(gotBits)) throw new CDKException("Got " + gotBits + ", wanted " + wantBits); }
@Test public void protonsDontCauseNPE() throws Exception { IAtomContainer proton = new AtomContainer(1, 0, 0, 0); proton.addAtom(atom("H", +1, 0)); CircularFingerprinter circ = new CircularFingerprinter(CircularFingerprinter.CLASS_FCFP2); assertThat(circ.getBitFingerprint(proton).cardinality(), is(0)); }
@Test public void iminesDetectionDoesntCauseNPE() throws Exception { IAtomContainer pyrazole = new AtomContainer(6, 6, 0, 0); pyrazole.addAtom(atom("H", 0, 0)); pyrazole.addAtom(atom("N", 0, 0)); pyrazole.addAtom(atom("C", 0, 1)); pyrazole.addAtom(atom("C", 0, 1)); pyrazole.addAtom(atom("C", 0, 1)); pyrazole.addAtom(atom("N", 0, 0)); pyrazole.addBond(0, 1, IBond.Order.SINGLE); pyrazole.addBond(1, 2, IBond.Order.SINGLE); pyrazole.addBond(2, 3, IBond.Order.DOUBLE); pyrazole.addBond(3, 4, IBond.Order.SINGLE); pyrazole.addBond(4, 5, IBond.Order.DOUBLE); pyrazole.addBond(1, 5, IBond.Order.SINGLE); CircularFingerprinter circ = new CircularFingerprinter(CircularFingerprinter.CLASS_FCFP2); assertNotNull(circ.getBitFingerprint(pyrazole)); }
@Test public void partialCoordinatesDontCauseNPE() throws Exception { IAtomContainer m = new AtomContainer(); m.addAtom(atom("C", 3, 0.000, 0.000)); m.addAtom(atom("C", 0, 1.299, -0.750)); m.addAtom(atom("H", 0, 0)); m.addAtom(atom("O", 0, 1)); m.addAtom(atom("C", 2, 2.598, -0.000)); m.addAtom(atom("C", 3, 3.897, -0.750)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE, IBond.Stereo.DOWN); m.addBond(1, 4, IBond.Order.SINGLE); m.addBond(4, 5, IBond.Order.SINGLE); CircularFingerprinter circ = new CircularFingerprinter(CircularFingerprinter.CLASS_ECFP6); assertNotNull(circ.getBitFingerprint(m)); }