@PublicAPI public abstract class Search extends java.lang.Object implements StereoConstants, SearchConstants
Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Level |
MRV_OUTPUT_LEVEL
MRV format of the query and target is logged at this level.
|
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
preMatchMap
Map for storing pre-match data.
|
protected MolSearchOptions |
searchOptions
Object to store all search parameters.
|
ANTI, ATOMSTEREO_EITHER, ATOMSTEREO_MASK, ATOMSTEREO_NONE, ATOMSTEREO_SPECIFIC, CHIRALITY_M, CHIRALITY_MASK, CHIRALITY_P, CHIRALITY_r, CHIRALITY_R, CHIRALITY_s, CHIRALITY_S, CHIRALITYSUPPORT_ALL, CHIRALITYSUPPORT_ALL_POSSIBLE, CHIRALITYSUPPORT_NONE, CHIRALITYSUPPORT_SELECTED, CIS, CIS_TRANS, CTUMASK, CTUNKNOWN, CTUNSPEC, DBS_ALL, DBS_MARKED, DBS_NONE, ENDO, EXO, PARITY_ALLENE, PARITY_EITHER, PARITY_EVEN, PARITY_MASK, PARITY_NONE, PARITY_ODD, PARITY_TETRAHEDRAL, PARITY_UNSPEC, STGRP_ABS, STGRP_AND, STGRP_NONE, STGRP_OR, SYN, TRANS
ABS_STEREO_ALWAYS_ON, ABS_STEREO_CHIRAL_FLAG, ABS_STEREO_TABLE_OPTION, ATTACHED_DATA_MATCH_EXACT, ATTACHED_DATA_MATCH_GENERAL, ATTACHED_DATA_MATCH_IGNORE, ATTACHMENT_ATOM, ATTACHMENT_LABEL, ATTACHMENT_MAP, ATTACHMENT_NONE, ATTACHMENT_POINT, ATTACHMENT_RLABEL, CHARGE_MATCHING_DEFAULT, CHARGE_MATCHING_EXACT, CHARGE_MATCHING_IGNORE, DEFAULT_DISSIMILARITY_THRESHOLD, DEFAULT_SEARCHTYPE, DISSIMILARITY_PROPERTY_NAME, DUPLICATE, FULL, FULL_FRAGMENT, HCOUNT_MATCHING_AUTO, HCOUNT_MATCHING_EQUAL, HCOUNT_MATCHING_GREATER_OR_EQUAL, HIT_EXCLUDEDQ, HIT_LP, HIT_MULTICENTER, HIT_NON_R, HIT_ORDERING_NONE, HIT_ORDERING_UNDEF_R_MATCHING_GROUP_FIRST, HIT_R, HIT_R_EMPTY_MATCH, HIT_UNMAPABLE, IMPLICIT_H_MATCHING_DEFAULT, IMPLICIT_H_MATCHING_DISABLED, IMPLICIT_H_MATCHING_ENABLED, IMPLICIT_H_MATCHING_IGNORE, ISOTOPE_MATCHING_DEFAULT, ISOTOPE_MATCHING_EXACT, ISOTOPE_MATCHING_IGNORE, MARKUSH_HIT_INNER, MARKUSH_HIT_ORIGINAL, MATCH_COUNT_BETWEEN, MATCH_COUNT_RELATION, NO_ABAS, NO_SCREEN, POSITION_ON_0TH_HEAVY_ATOM, RADICAL_MATCHING_DEFAULT, RADICAL_MATCHING_EXACT, RADICAL_MATCHING_IGNORE, SEARCH_MODE_NAMES, SEARCH_TYPE_NAMES, SIMILARITY, STEREO_DIASTEREOMER, STEREO_ENANTIOMER, STEREO_EXACT, STEREO_IGNORE, STEREO_MODEL_COMPREHENSIVE, STEREO_MODEL_DEFAULT, STEREO_MODEL_GLOBAL, STEREO_MODEL_LOCAL, STEREO_SPECIFIC, SUBSTRUCTURE, SUPERSTRUCTURE, TAUTOMER_SEARCH_DEFAULT, TAUTOMER_SEARCH_OFF, TAUTOMER_SEARCH_ON, TAUTOMER_SEARCH_ON_IGNORE_TAUTOMERSTEREO, UNDEF_R_MATCHING_ALL, UNDEF_R_MATCHING_GROUP, UNDEF_R_MATCHING_GROUP_H, UNDEF_R_MATCHING_GROUP_H_EMPTY, UNDEF_R_MATCHING_UNDEF_R, VAGUE_BOND_DEFAULT, VAGUE_BOND_LEVEL_HALF, VAGUE_BOND_LEVEL1, VAGUE_BOND_LEVEL2, VAGUE_BOND_LEVEL3, VAGUE_BOND_LEVEL4, VAGUE_BOND_OFF
Constructor and Description |
---|
Search() |
Modifier and Type | Method and Description |
---|---|
void |
addMatch(int[] queryAtoms,
int[] targetAtoms,
int length)
Specifies extra prerequisites of the structure search that queryAtoms[0] must match to targetAtoms[0] only AND
queryAtoms[1] must match to targetAtoms[1], etc.
|
void |
clearMatch()
Clears the extra prerequisites of the structure search specified using
addMatch calls.
|
int[][] |
findAll()
Looks for all matching patterns in the molecule.
|
int[][][] |
findAllGroups()
Returns the group hits corresponding to all hits.
|
protected SearchHit[] |
findAllHits()
Looks for all matching patterns in the molecule.
|
int[] |
findFirst()
Looks for the first matching pattern in the target molecule.
|
int[][] |
findFirstGroup()
Returns the group hit corresponding to the first hit.
|
protected abstract SearchHit |
findFirstHit()
Looks for the first matching pattern in the target molecule.
|
int[] |
findNext()
Looks for the next matching pattern in the target molecule.
|
int[][] |
findNextGroup()
Returns the group hit corresponding to the next hit.
|
protected abstract SearchHit |
findNextHit()
Searches for the next hit.
|
int |
getMatchCount()
The number of times the query molecule appears in the target molecule.
|
abstract Molecule |
getQuery()
Retrieves the query structure.
|
protected static java.lang.String |
getQueryAsString(Molecule qToPrint)
For internal purposes only.
|
protected Molecule |
getQueryToPrint()
For internal purposes only.
|
MolSearchOptions |
getSearchOptions()
Returns the
SearchOptions object associated with this Search object. |
abstract Molecule |
getTarget()
Retrieves the target molecule.
|
protected static java.lang.String |
getTargetAsString(Molecule tToPrint)
For internal purposes only.
|
protected Molecule |
getTargetToPrint()
For internal purposes only.
|
boolean |
isMatchCountBetween(int hitLimitLow,
boolean isLowerLimitIncluded,
int hitLimitHigh,
boolean isHigherLimitIncluded)
Decides questions like "does the query match the target
between 2 and 5 times (inclusively)"
Makes this efficiently, which means it only searches
for the number of hits necessary to decide the question.
|
boolean |
isMatchCountInRelation(java.lang.String relation,
int hitLimit)
Decides questions like "does the query match the target
at least 3 times", "[] up to 5 times", "[] exactly
once".
|
static boolean |
isMatchCountInRelation(java.lang.String relation,
int hitLimit,
int foundHits) |
abstract boolean |
isMatching()
Checks if the query structure matches the target structure with respect to the search options.
|
boolean |
isVerbose()
For debugging purposes only.
|
abstract void |
setQuery(Molecule mol)
Specifies the query structure to search for.
|
abstract void |
setQuery(Molecule mol,
int[] exclude)
Specifies the query structure to search for.
|
void |
setSearchOptions(SearchOptions options)
Sets search options.
|
abstract void |
setTarget(Molecule mol)
Specifies the target molecule.
|
abstract void |
setTarget(Molecule mol,
int[] exclude)
Specifies the target molecule with excluded atoms.
|
void |
setVerbose(boolean verbose)
For debugging purposes only.
|
abstract void |
stop()
Tries to stop the running search as fast as possible.
|
protected final MolSearchOptions searchOptions
protected java.util.Map<java.lang.Integer,java.lang.Integer> preMatchMap
protected static final java.util.logging.Level MRV_OUTPUT_LEVEL
public abstract void setTarget(Molecule mol)
Note: If the molecule is changed, it will need to be reset for the searcher.
mol
- the possibly standardized target molecule. See note on aromatic bondspublic abstract void setTarget(Molecule mol, int[] exclude)
Note: If the molecule is changed, it will need to be reset for the searcher.
mol
- the standardized target molecule. See note on aromatic bondsexclude
- index of target atoms to exclude from searchpublic abstract Molecule getTarget()
public abstract void setQuery(Molecule mol)
mol
- the standardized query structure. See note on aromatic bondspublic abstract void setQuery(Molecule mol, int[] exclude)
mol
- the standardized query structure. See note on aromatic bondsexclude
- index of atoms to exclude from searchpublic abstract Molecule getQuery()
public abstract boolean isMatching() throws SearchException
SearchException
- when an error is encountered.findFirstHit()
,
findNextHit()
,
findAllHits()
,
getQuery()
public final int[] findFirst() throws SearchException
null
if there are no hits.
See SearchHit.getSingleHit()
for the description of special atom indexes.SearchException
- when an error is encountered.findNext()
,
findAll()
,
findFirstHit()
,
findNextHit()
,
findAllHits()
,
isMatching()
,
getQuery()
public final int[] findNext() throws SearchException
findFirst()
call is not necessary prior to a findNext()
call.)null
if there are no more hits.
See SearchHit.getSingleHit()
for the description of special atom indexes.SearchException
- when an error is encountered.findFirst()
,
findAll()
,
findFirstHit()
,
findNextHit()
,
findAllHits()
,
isMatching()
,
getQuery()
public final int[][] findAll() throws SearchException
null
if there are no hits.
The match arrays contain the atom indexes of the target atoms
that match the query atoms (in the order of the appropriate query atoms).
See SearchHit.getSingleHit()
for the description of special atom indexes.SearchException
- when an error is encountered.findFirst()
,
findNext()
,
findFirstHit()
,
findNextHit()
,
findAllHits()
,
isMatching()
public final int[][] findFirstGroup() throws SearchException
See SearchHit.getGroupHit()
for more information on group hits.
SearchException
- when an error is encountered.findNextGroup()
,
findAllGroups()
,
findFirstHit()
,
findNextHit()
,
findAllHits()
,
isMatching()
,
getQuery()
,
findFirst()
,
findNext()
,
findAll()
public final int[][] findNextGroup() throws SearchException
See SearchHit.getGroupHit()
for more information on group hits.
SearchException
- when an error is encountered.findFirstGroup()
,
findAllGroups()
,
findFirstHit()
,
findNextHit()
,
findAllHits()
,
isMatching()
,
getQuery()
,
findFirst()
,
findNext()
,
findAll()
public final int[][][] findAllGroups() throws SearchException
See SearchHit.getGroupHit()
for more information on group hits.
SearchException
- when an error is encountered.findFirstGroup()
,
findNextGroup()
,
findFirstHit()
,
findNextHit()
,
findAllHits()
,
isMatching()
,
findFirst()
,
findNext()
,
findAll()
protected abstract SearchHit findFirstHit() throws SearchException
See SearchHit
for more information.
null
if there is not hitSearchException
- when an error is encountered.findNextHit()
,
findAllHits()
,
isMatching()
,
getQuery()
,
findNext()
,
findAll()
,
findFirstGroup()
,
findNextGroup()
,
findAllGroups()
protected abstract SearchHit findNextHit() throws SearchException
findFirstHit()
call is not necessary prior to a findNextHit()
call.)
See SearchHit
for more information.
null
if there is no more hitSearchException
- when an error is encountered.findFirstHit()
,
findAllHits()
,
isMatching()
,
getQuery()
,
findFirst()
,
findAll()
,
findFirstGroup()
,
findNextGroup()
,
findAllGroups()
protected SearchHit[] findAllHits() throws SearchException
See SearchHit
for more information.
null
if there are no hits.SearchException
- when an error is encountered.findFirstHit()
,
findNextHit()
,
isMatching()
,
findFirst()
,
findNext()
,
findFirstGroup()
,
findNextGroup()
,
findAllGroups()
public void addMatch(int[] queryAtoms, int[] targetAtoms, int length)
Several addMatch() calls represent conditions connected by boolean operator AND.
The effect of all addMatch() calls can be canceled by clearMatch().
queryAtoms
- the query atom indexestargetAtoms
- the target atom indexeslength
- the length for which queryAtoms/targetAtoms should be interpreted.public void clearMatch()
public final boolean isMatchCountInRelation(java.lang.String relation, int hitLimit) throws SearchException
Example:
isMatchCountInRelation("<", 2) - true if the query can be found in the target less than two times.
relation
- The relational operation of the question. This
operation will be used to compare the number of hits to
hitLimit
. Available values:
hitLimit
.
hitLimit
.
hitLimit
- The limit for the number of hits.relation
> hitLimit
SearchException
- if encountered during the search.getMatchCount()
@Beta public static boolean isMatchCountInRelation(java.lang.String relation, int hitLimit, int foundHits) throws SearchException
SearchException
public final boolean isMatchCountBetween(int hitLimitLow, boolean isLowerLimitIncluded, int hitLimitHigh, boolean isHigherLimitIncluded) throws SearchException
Example:
isMatchCountBetween(2, true, 4, true) - true if the query can be found in the target exactly 2, 3 or 4 times.
isMatchCountBetween(2, false, 4, false) - true if the query can be found in the target exactly 3 times.
hitLimitLow
- The lower limit for the number of hits.isLowerLimitIncluded
- If true, equality is allowed with hitLimitLow.hitLimitHigh
- The upper limit for the number of hits. If you pass
Integer.MAX_VALUE
, it will be treated as infinity. (I.e. only the
lower limit is applied.)isHigherLimitIncluded
- If true, equality is allowed with hitLimitHigh.hitLimitLow
and hitLimitHigh
, inclusively.SearchException
- if encountered during the search.getMatchCount()
public final int getMatchCount() throws SearchException
If you would like to decide a simple relation regarding this number, you should consider method isMatchCountInRelation( String, int), because it is more efficient than this method.
SearchException
- If encountered during the search.isMatchCountInRelation(java.lang.String, int)
public boolean isVerbose()
public void setVerbose(boolean verbose)
verbose
- enables or disables verbose mode.public abstract void stop()
public MolSearchOptions getSearchOptions()
SearchOptions
object associated with this Search object. The object
returned is linked with this Search
object, so modifications in the returned
SearchOptions
object will also change the behavior of this Search
object!setSearchOptions(SearchOptions)
public void setSearchOptions(SearchOptions options)
options
- search options. A copy of this object will be stored.getSearchOptions()
protected Molecule getQueryToPrint()
protected Molecule getTargetToPrint()
protected static java.lang.String getTargetAsString(Molecule tToPrint)
tToPrint
- the molecule to be flattened to a string arrayprotected static java.lang.String getQueryAsString(Molecule qToPrint)
qToPrint
- the molecule to be flattened to a string array