Class MolSearch
- All Implemented Interfaces:
Licensable,SearchConstants,StereoConstants
- 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 for
setQuery()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
FieldsModifier and TypeFieldDescriptionprotected booleanFor internal use only.Fields inherited from class chemaxon.search.AbstractSearch
MRV_OUTPUT_LEVEL, preMatchMap, searchOptionsFields inherited from interface chemaxon.search.api.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_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_OFFFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a comparator to the search object.voidaddMatch(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.voidaddMatch(int queryAtomIndex, int targetAtomIndex) Adds a fixed matching between the given query and target atoms.static voidcheckFilter(String filteringExpression) Checks the syntax of the filtering expression.static voidcheckFilter(String filteringExpression, File config) Checks the syntax of the filtering expression.voidDelete all comparator from the search object.voidClears 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.booleanChecks if the required license is available for using this class or product.booleanChecks if the query structure matches the target structure with respect to the search options.voidDelete a comparator from the search object.voidSets the current license environment identifier.voidsetOrigTargetMayBeMarkush(boolean value) Only for internal use!protected voidvoidSpecifies the query structure to search for.voidSpecifies the query structure to search for.voidSpecifies the query structure to search for in String format.voidsetSearchOptions(MolSearchOptions options) Sets search options.voidsetStandardizer(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.voidSpecifies the target molecule.voidSpecifies the target molecule with excluded atoms.voidstop()Tries to stop the running search as fast as possible.Methods inherited from class chemaxon.search.AbstractSearch
findAll, findAllGroups, findFirst, findFirstGroup, findNext, findNextGroup, getMatchCount, getQueryToPrint, getSearchOptions, getTargetToPrint, isMatchCountBetween, isMatchCountInRelation, isVerbose, setSearchOptions, setVerbose
-
Field Details
-
isOrigTargetMayBeMarkush
protected boolean isOrigTargetMayBeMarkushFor internal use only.
-
-
Constructor Details
-
MolSearch
public MolSearch()Constructs a MolSearch object.
-
-
Method Details
-
setTarget
Description copied from class:AbstractSearchSpecifies the target molecule.Note: If the molecule is changed, it will need to be reset for the searcher.
- Specified by:
setTargetin classAbstractSearch- Parameters:
mol- the possibly standardized target molecule. See note on aromatic bonds
-
setTarget
Description copied from class:AbstractSearchSpecifies 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:
setTargetin classAbstractSearch- Parameters:
mol- the standardized target molecule. See note on aromatic bondsexclude- index of target atoms to exclude from search
-
getTarget
Description copied from class:AbstractSearchRetrieves the target molecule.- Specified by:
getTargetin classAbstractSearch- Returns:
- the target molecule
-
setQuery
Description copied from class:AbstractSearchSpecifies the query structure to search for. Note: If the molecule is changed, it will need to be reset for the searcher.- Specified by:
setQueryin classAbstractSearch- Parameters:
mol- the standardized query structure. See note on aromatic bonds
-
setQuery
Description copied from class:AbstractSearchSpecifies 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:
setQueryin classAbstractSearch- Parameters:
mol- the standardized query structure. See note on aromatic bondsexclude- index of atoms to exclude from search
-
getQuery
Description copied from class:AbstractSearchRetrieves the query structure.- Specified by:
getQueryin classAbstractSearch- Returns:
- 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
-
setStandardizer
Sets the standardizer to be used for query and target molecules and re-standardization of query tautomers in case of tautomer substructure search. The input molecules are cloned before standardization, so the original objects are not modified during the use of this class.By default, there is no standardization.
- Parameters:
standardizer- the standardizer,nullfor 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.- See Also:
-
isMatching
Description copied from class:AbstractSearchChecks if the query structure matches the target structure with respect to the search options.- Specified by:
isMatchingin classAbstractSearch- Returns:
- true if a match is found.
- Throws:
SearchException- when an error is encountered.- See Also:
-
findFirstHit
Description copied from class:AbstractSearchLooks 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
SearchHitfor more information.- Specified by:
findFirstHitin classAbstractSearch- Returns:
- the search hit or
nullif there is not hit - Throws:
SearchException- when an error is encountered.- See Also:
-
findNextHit
Description copied from class:AbstractSearchSearches for the next hit. If the search object was not used previously, it also initializes the search. (SoAbstractSearch.findFirstHit()call is not necessary prior to aAbstractSearch.findNextHit()call.)See
SearchHitfor more information.- Specified by:
findNextHitin classAbstractSearch- Returns:
- the next search hit or
nullif there is no more hit - Throws:
SearchException- when an error is encountered.- See Also:
-
findAllHits
Description copied from class:AbstractSearchLooks for all matching patterns in the molecule.See
SearchHitfor more information.- Overrides:
findAllHitsin classAbstractSearch- Returns:
- the search hits or
nullif there are no hits. - Throws:
SearchException- when an error is encountered.- See Also:
-
stop
public void stop()Description copied from class:AbstractSearchTries to stop the running search as fast as possible. (E.g. used in another thread.)- Specified by:
stopin classAbstractSearch
-
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().
-
addMatch
public void addMatch(int[] queryAtoms, int[] targetAtoms, int length) Description copied from class:AbstractSearchSpecifies 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().
- Overrides:
addMatchin classAbstractSearch- Parameters:
queryAtoms- the query atom indexestargetAtoms- the target atom indexeslength- the length for which queryAtoms/targetAtoms should be interpreted.
-
clearMatch
public void clearMatch()Description copied from class:AbstractSearchClears the extra prerequisites of the structure search specified using addMatch calls.- Overrides:
clearMatchin classAbstractSearch
-
checkFilter
Checks the syntax of the filtering expression. For internal use only.- Parameters:
filteringExpression- the expression to be checked- Throws:
ParseException- if the syntax is not correct- Since:
- JChem 3.0
-
checkFilter
Checks the syntax of the filtering expression. For internal use only.- Parameters:
filteringExpression- the expression to be checkedconfig- the expression evaluator config XML- Throws:
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- iffalseindicates that any bonds appeared only after tautomer generation.
-
setLicenseEnvironment
Description copied from interface:LicensableSets the current license environment identifier. For internal use only!- Specified by:
setLicenseEnvironmentin interfaceLicensable- Parameters:
env- license environment. It is string identifier of a certain integration environment.
-
isLicensed
public boolean isLicensed()Description copied from interface:LicensableChecks if the required license is available for using this class or product.- Specified by:
isLicensedin interfaceLicensable- Returns:
- true if this software component is correctly licensed
-