Skip to content

Commit

Permalink
Merge pull request #164 from cdk/patch/pathfplimit
Browse files Browse the repository at this point in the history
Looks good.
  • Loading branch information
egonw committed Oct 6, 2015
2 parents 055c1dd + 73371fb commit ae42093
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -93,7 +93,7 @@
public class Fingerprinter implements IFingerprinter {

/** Throw an exception if too many paths (per atom) are generated. */
private final static int PATH_LIMIT = 150;
private final static int DEFAULT_PATH_LIMIT = 1500;

/** The default length of created fingerprints. */
public final static int DEFAULT_SIZE = 1024;
Expand All @@ -102,9 +102,11 @@ public class Fingerprinter implements IFingerprinter {

private int size;
private int searchDepth;
private int pathLimit = DEFAULT_PATH_LIMIT;

static int debugCounter = 0;


private static ILoggingTool logger = LoggingToolFactory
.createLoggingTool(Fingerprinter.class);

Expand Down Expand Up @@ -216,7 +218,7 @@ protected int[] findPathes(IAtomContainer container, int searchDepth) throws CDK
Map<IAtom, Map<IAtom, IBond>> cache = new HashMap<IAtom, Map<IAtom, IBond>>();

for (IAtom startAtom : container.atoms()) {
List<List<IAtom>> p = PathTools.getLimitedPathsOfLengthUpto(container, startAtom, searchDepth, PATH_LIMIT);
List<List<IAtom>> p = PathTools.getLimitedPathsOfLengthUpto(container, startAtom, searchDepth, pathLimit);
for (List<IAtom> path : p) {
StringBuffer sb = new StringBuffer();
IAtom x = path.get(0);
Expand Down Expand Up @@ -309,6 +311,10 @@ protected String getBondSymbol(IBond bond) {
return bondSymbol;
}

public void setPathLimit(int limit) {
this.pathLimit = limit;
}

public int getSearchDepth() {
return searchDepth;
}
Expand Down
Expand Up @@ -28,10 +28,12 @@

import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openscience.cdk.Atom;
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.Reaction;
import org.openscience.cdk.SlowTest;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.AtomContainerAtomPermutor;
import org.openscience.cdk.graph.AtomContainerBondPermutor;
Expand Down Expand Up @@ -165,7 +167,8 @@ public void testBug1851202() throws Exception {
Assert.assertNotNull(fingerprinter.getBitFingerprint(product));
}

@Test(timeout = 500, expected = CDKException.class)
@Test(expected = CDKException.class)
@Category(SlowTest.class)
public void testbug2917084() throws Exception {
String filename1 = "data/mdl/boronBuckyBall.mol";
logger.info("Testing: " + filename1);
Expand Down

0 comments on commit ae42093

Please sign in to comment.