Skip to content

Commit

Permalink
Updated PubchemFingperinter to not use static variables. Allows it to…
Browse files Browse the repository at this point in the history
… be used in multithreaded scenarios

Change-Id: Iaa9481fd1fa5793cb5fe3b449219aeb7958a983d
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>

Conflicts:
	src/main/org/openscience/cdk/fingerprint/PubchemFingerprinter.java
  • Loading branch information
rajarshi authored and egonw committed Apr 1, 2012
1 parent e5b014b commit 171c06b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/org/openscience/cdk/fingerprint/PubchemFingerprinter.java
Expand Up @@ -87,11 +87,19 @@
public class PubchemFingerprinter implements IFingerprinter {

// number of bits in this fingerprint
public static int FP_SIZE = 881;
public static final int FP_SIZE = 881;

private byte[] m_bits;

private SMARTSQueryTool sqt;
public PubchemFingerprinter() {
try {
sqt = new SMARTSQueryTool("C");
} catch (CDKException e) {
// bad practice but, the above initialization
// will never fail so we don't bother throwing
// the exception
}
m_bits = new byte[(FP_SIZE + 7) >> 3];
}

Expand Down Expand Up @@ -297,13 +305,11 @@ && countHeteroInRing(ring) > 0)
}
}

static class CountSubstructures {
class CountSubstructures {
private IAtomContainer mol;
private SMARTSQueryTool sqt;

public CountSubstructures(IAtomContainer m) {
mol = m;
sqt = new SMARTSQueryTool("C");
}

public int countSubstructure(String smarts) throws CDKException {
Expand All @@ -315,7 +321,7 @@ public int countSubstructure(String smarts) throws CDKException {
}
}

static private void _generateFp(byte[] fp, IAtomContainer mol)
private void _generateFp(byte[] fp, IAtomContainer mol)
throws CDKException {
countElements(fp, mol);
countRings(fp, mol);
Expand Down Expand Up @@ -1085,7 +1091,7 @@ private static void countRings(byte[] fp, IAtomContainer mol) {
if (cr.countHeteroAromaticRing() >= 4) fp[b >> 3] |= MASK[b % 8];
}

private static void countSubstructures(byte[] fp, IAtomContainer mol) throws CDKException {
private void countSubstructures(byte[] fp, IAtomContainer mol) throws CDKException {
CountSubstructures cs = new CountSubstructures(mol);
int b;

Expand Down

0 comments on commit 171c06b

Please sign in to comment.