Skip to content

Commit

Permalink
Allowing construction of AllRingsFinder using the new threshold values.
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Aug 1, 2013
1 parent aa9eeb9 commit 9f2ec99
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions src/main/org/openscience/cdk/ringsearch/AllRingsFinder.java
Expand Up @@ -70,7 +70,13 @@
*/
@TestClass("org.openscience.cdk.ringsearch.AllRingsFinderTest")
public class AllRingsFinder {
private ILoggingTool logger = null;

/** Logger for the class. */
private final ILoggingTool logger = LoggingToolFactory
.createLoggingTool(AllRingsFinder.class);

/** Precomputed threshold - stops the computation running forever. */
private final Threshold threshold;

/*
* used for storing the original atomContainer for
Expand All @@ -85,16 +91,21 @@ public class AllRingsFinder {
* Constructor for the AllRingsFinder.
*
* @param logging true=logging will be done (slower), false = no logging.
* @deprecated turn logging off by setting the level in the logger
* implementation
*/
@Deprecated
public AllRingsFinder(boolean logging) {
if (logging)
logger =
LoggingToolFactory.createLoggingTool(AllRingsFinder.class);
this(Threshold.PubChem_99);
}

/** Constructor for the AllRingsFinder with logging. */
public AllRingsFinder() {
this(true);
this(Threshold.PubChem_99);
}

private AllRingsFinder(Threshold threshold) {
this.threshold = threshold;
}

/**
Expand Down Expand Up @@ -586,7 +597,9 @@ public int hashCode() {
* There will always be some ring systems in which we cannot compute every
* possible ring (e.g. Fullerenes). This limit replaces the previous timeout
* and provides a more meaningful measure of what to expect based on
* precomputed percentiles. <br/>
* precomputed percentiles. It is important to consider that, higher is not
* always better - generally the large values generate many more rings then
* can be reasonably be handled.<br/>
*
* The latest results were calculated on PubChem Compound (Dec' 12) and
* summarised below.
Expand Down Expand Up @@ -665,5 +678,19 @@ private Threshold(int value) {
}
}

/**
* Create an {@link AllRingsFinder} instance using the given threshold.
*
* <blockquote><pre>
* // import static AllRingsFinder.Threshold.PubChem_99;
* AllRingsFinder arf = AllRingsFinder.usingThreshold(PubChem_99);
* </pre></blockquote>
*
* @param threshold the threshold value
* @return instance with the set threshold
*/
public static AllRingsFinder usingThreshold(Threshold threshold) {
return new AllRingsFinder(threshold);
}
}

0 comments on commit 9f2ec99

Please sign in to comment.