Class MolSearch
- All Implemented Interfaces:
chemaxon.license.Licensable
,SearchConstants
,StereoConstants
,SimpleSearcher
- Direct Known Subclasses:
StandardizedMolSearch
Features:
- Determines whether a target structure contains a query structure.
- Specifies the matching atoms in the target structure in order of the corresponding query atoms. (When the returning match is larger than the original query atoms, eg. in link node queries, the extra target atom indexes appear at the end.)
- Generic query atoms (Any, Q), atom properties (A, a, R<n>, H<n> etc.) , atom lists (e.g.: "[C,N,F]"), generic bonds (any bond) are evaluated. For full details of JChem substructure features, see the JChem Query Guide
- Stereo specific search: chiral and cis/trans stereo isomers are recognized.
- R-groups: If the query is an RgMolecule with R-groups defined,
R-group search
is performed. In this case hits of the root atoms are returned.
Specifying excluded atoms forsetQuery()
is not implemented yet for RgMolecules either. - Filtering expression: filters search hits by chemical feasibility. For details of the expression syntax, see the Chemical Terms Evaluator Guide.
StandardizedMolSearch
class.
Please note that similarity search is not supported in MolSearch.
Example:
try { // The molecules must be aromatized if they use Kekulé representation query.aromatize(); target.aromatize(); // Init MolSearch MolSearch s = new MolSearch(); s.setQuery(query); s.setTarget(target); // Search all matching substructures and print hits int[][] hits = s.findAll(); if (hits == null) System.out.println("No hits"); else { for (int i = 0; i < hits.length; i++) { System.out.println("Hit " + (i + 1) + ": " + Arrays.toString(hits[i])); } } } catch (SearchException e) { throw new RuntimeException(e); }
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
FS#9166 Should be set to 'false' to indicate that any bonds (Markush components) occurred only after generating generic tautomer of target.Fields inherited from class chemaxon.sss.search.Search
MRV_OUTPUT_LEVEL, preMatchMap, searchOptions
Fields inherited from interface chemaxon.sss.SearchConstants
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
Fields inherited from interface chemaxon.struc.StereoConstants
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a comparator to the search object.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
addMatch
(int queryAtomIndex, int targetAtomIndex) Adds a fixed matching between the given query and target atoms.static void
checkFilter
(String filteringExpression) Checks the syntax of the filtering expression.static void
checkFilter
(String filteringExpression, File config) Checks the syntax of the filtering expression.void
Delete all comparator from the search object.void
Clears the extra prerequisites of the structure search specified using addMatch calls.Looks for all matching patterns in the molecule.Looks for the first matching pattern in the target molecule.Searches for the next hit.getQuery()
Retrieves the query structure.Retrieves the target molecule.boolean
boolean
Checks if the query structure matches the target structure with respect to the search options.void
Delete a comparator from the search object.void
void
setOrigTargetMayBeMarkush
(boolean value) Only for internal use!
Used for indicating that any bonds appeared after generating the generic tautomer of the target.protected void
void
Specifies the query structure to search for.void
Specifies the query structure to search for.void
Specifies the query structure to search for in String format.void
setSearchOptions
(MolSearchOptions options) Sets search options.void
setStandardizer
(Standardizer standardizer) Sets the standardizer to be used for query and target molecules and re-standardization of query tautomers in case of tautomer substructure search.void
Specifies the target molecule.void
Specifies the target molecule with excluded atoms.protected final void
setTransformer
(Transformer transformer) Sets theTransformer
to be used for query and target standardization.void
stop()
Tries to stop the running search as fast as possible.Methods inherited from class chemaxon.sss.search.Search
findAll, findAllGroups, findFirst, findFirstGroup, findNext, findNextGroup, getMatchCount, getQueryAsString, getQueryToPrint, getSearchOptions, getTargetAsString, getTargetToPrint, isMatchCountBetween, isMatchCountInRelation, isMatchCountInRelation, isVerbose, setSearchOptions, setVerbose
-
Field Details
-
isOrigTargetMayBeMarkush
protected boolean isOrigTargetMayBeMarkushFS#9166 Should be set to 'false' to indicate that any bonds (Markush components) occurred only after generating generic tautomer of target. Is used only in selectSearchMode()!
-
-
Constructor Details
-
MolSearch
public MolSearch()Constructs a MolSearch object.
-
-
Method Details
-
setTarget
Description copied from class:Search
Specifies the target molecule.Note: If the molecule is changed, it will need to be reset for the searcher.
- Specified by:
setTarget
in interfaceSimpleSearcher
- Specified by:
setTarget
in classSearch
- Parameters:
mol
- the possibly standardized target molecule. See note on aromatic bonds
-
setTarget
Description copied from class:Search
Specifies the target molecule with excluded atoms. Excluded atoms are not used during the search procedure. Atoms connected to excluded ones keep their stereo features.Note: If the molecule is changed, it will need to be reset for the searcher.
- Specified by:
setTarget
in interfaceSimpleSearcher
- Specified by:
setTarget
in classSearch
- Parameters:
mol
- the standardized target molecule. See note on aromatic bondsexclude
- index of target atoms to exclude from search
-
getTarget
Description copied from class:Search
Retrieves the target molecule. -
setQuery
Description copied from class:Search
Specifies the query structure to search for. Note: If the molecule is changed, it will need to be reset for the searcher.- Specified by:
setQuery
in interfaceSimpleSearcher
- Specified by:
setQuery
in classSearch
- Parameters:
mol
- the standardized query structure. See note on aromatic bonds
-
setQuery
Description copied from class:Search
Specifies the query structure to search for. Excluded atoms are not used during the search procedure. Atoms connected to excluded ones keep their stereo features. Note: If the molecule is changed, it will need to be reset for the searcher.- Specified by:
setQuery
in interfaceSimpleSearcher
- Specified by:
setQuery
in classSearch
- Parameters:
mol
- the standardized query structure. See note on aromatic bondsexclude
- index of atoms to exclude from search
-
getQuery
Description copied from class:Search
Retrieves the query structure. -
setQuery
Specifies the query structure to search for in String format.- Parameters:
queryString
- the standardized query structure. See note on aromatic bonds
-
setTransformer
Sets theTransformer
to be used for query and target standardization. For internal use only.- Parameters:
transformer
- the transformer
-
setStandardizer
Sets the standardizer to be used for query and target molecules and re-standardization of query tautomers in case of tautomer substructure search.
By default there is no standardization.
- Parameters:
standardizer
- the standardizer,null
for no standardization- Since:
- JChem 5.12
-
setSearchOptions
Sets search options. This function makes a copy of the given search options object, thus modification of the original object does not affect future searches unless this method is called again.- Parameters:
options
- search options. A copy of this object will be stored.- Since:
- JChem 5.0
- See Also:
-
addComparator
Add a comparator to the search object.- Parameters:
mc
- comparator to add- See Also:
-
removeComparator
Delete a comparator from the search object.- Parameters:
mc
- comparator to be removed- See Also:
-
clearComparators
public void clearComparators()Delete all comparator from the search object. -
isMatching
Description copied from class:Search
Checks if the query structure matches the target structure with respect to the search options.- Specified by:
isMatching
in interfaceSimpleSearcher
- Specified by:
isMatching
in classSearch
- Returns:
- true if a match is found.
- Throws:
SearchException
- when an error is encountered.- See Also:
-
findFirstHit
Description copied from class:Search
Looks for the first matching pattern in the target molecule. If the search object was previously used, this method re-initializes the search process, and starts returning the hits from the beginning.See
SearchHit
for more information.- Specified by:
findFirstHit
in classSearch
- Returns:
- the search hit or
null
if there is not hit - Throws:
SearchException
- when an error is encountered.- See Also:
-
findNextHit
Description copied from class:Search
Searches for the next hit. If the search object was not used previously, it also initializes the search. (SoSearch.findFirstHit()
call is not necessary prior to aSearch.findNextHit()
call.)See
SearchHit
for more information.- Specified by:
findNextHit
in interfaceSimpleSearcher
- Specified by:
findNextHit
in classSearch
- Returns:
- the next search hit or
null
if there is no more hit - Throws:
SearchException
- when an error is encountered.- See Also:
-
findAllHits
Description copied from class:Search
Looks for all matching patterns in the molecule.See
SearchHit
for more information.- Overrides:
findAllHits
in classSearch
- Returns:
- the search hits or
null
if there are no hits. - Throws:
SearchException
- when an error is encountered.- See Also:
-
stop
public void stop()Description copied from class:Search
Tries to stop the running search as fast as possible. (E.g. used in another thread.) -
setParameters
- Throws:
SearchException
-
addMatch
public void addMatch(int queryAtomIndex, int targetAtomIndex) Adds a fixed matching between the given query and target atoms. That is, the query atom can only match the given target atom. If such a hit is not possible, no hits will be returned. The use of this method makes the search more effective than checking the hits afterwards.Several addMatch() calls represent conditions connected by boolean operator AND.
The effect of all addMatch() calls can be canceled by clearMatch().
- Specified by:
addMatch
in interfaceSimpleSearcher
- Parameters:
queryAtomIndex
- index of the query atomtargetAtomIndex
- index of the target atom
-
addMatch
public void addMatch(int[] queryAtoms, int[] targetAtoms, int length) Description copied from class:Search
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. If this is impossible, the search methods will report no matching. The use of this method makes the search more effective than checking the hits afterwards.Several addMatch() calls represent conditions connected by boolean operator AND.
The effect of all addMatch() calls can be canceled by clearMatch().
-
clearMatch
public void clearMatch()Description copied from class:Search
Clears the extra prerequisites of the structure search specified using addMatch calls.- Overrides:
clearMatch
in classSearch
-
checkFilter
Checks the syntax of the filtering expression. For internal use only.- Parameters:
filteringExpression
- the expression to be checked- Throws:
chemaxon.nfunk.jep.ParseException
- if the syntax is not correct- Since:
- JChem 3.0
-
checkFilter
public static void checkFilter(String filteringExpression, File config) throws chemaxon.nfunk.jep.ParseException Checks the syntax of the filtering expression. For internal use only.- Parameters:
filteringExpression
- the expression to be checkedconfig
- the expression evaluator config XML- Throws:
chemaxon.nfunk.jep.ParseException
- if the syntax is not correct- Since:
- JChem 3.0
-
setOrigTargetMayBeMarkush
public void setOrigTargetMayBeMarkush(boolean value) Only for internal use!
Used for indicating that any bonds appeared after generating the generic tautomer of the target.- Parameters:
value
- iffalse
indicates that any bonds appeared only after tautomer generation.
-
setLicenseEnvironment
- Specified by:
setLicenseEnvironment
in interfacechemaxon.license.Licensable
-
isLicensed
public boolean isLicensed()- Specified by:
isLicensed
in interfacechemaxon.license.Licensable
-