public class MolSearch extends Search implements chemaxon.license.Licensable, SimpleSearcher
Features:
setQuery() is not
implemented yet for RgMolecules either.StandardizedMolSearch
class.
Please note that similarity search is not supported in MolSearch.
Example:
import chemaxon.sss.search.MolSearch;
import chemaxon.sss.search.SearchException;
import chemaxon.util.MolHandler;
import chemaxon.formats.MolInputStream;
import chemaxon.formats.MolImporter;
import chemaxon.struc.Molecule;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
public class SearchTest {
public static void main(String[] args) {
try {
MolSearch s = new MolSearch();
// queryMode = true forces string to be imported as SMARTS
// If SMILES import needed, set queryMode = false.
MolHandler mh1 = new MolHandler("c1ccccc1Cl", true);
// The query molecule must be aromatized if it uses the
// alternating single/double bonds for the description of
// aromaticity.
mh1.aromatize();
s.setQuery(mh1.getMolecule());
// use Molfile molecule as target
BufferedInputStream tis = null;
tis = new BufferedInputStream(new FileInputStream("target.mol"));
MolInputStream tmis = new MolInputStream(tis);
MolImporter tmolimp = new MolImporter(tmis);
Molecule target = tmolimp.read();
target.aromatize(true);
s.setTarget(target);
// search all matching substructures and print hits
int[][] hits = null;
hits = s.findAll();
if (hits == null)
System.out.println("No hits");
else {
for (int i = 0; i < hits.length; i++) {
System.out.print("Hit " + (i + 1) + ": ");
int[] hit = hits[i];
for (int j = 0; j < hit.length; j++) {
System.out.print(hit[j] + " ");
}
System.out.println();
}
}// end else
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
} catch (SearchException e) {
e.printStackTrace();
System.exit(1);
}// end catch
}// end main
}// end searchTest
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isOrigTargetMayBeMarkush
FS#9166 Should be set to 'false' to indicate that any bonds (Markush
components) occurred only after generating generic tautomer of target.
|
MRV_OUTPUT_LEVEL, preMatchMap, searchOptionsANTI, 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, TRANSABS_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 |
|---|
MolSearch()
Constructs a MolSearch object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComparator(MolComparator mc)
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 |
clearComparators()
Delete all comparator from the search object.
|
void |
clearMatch()
Clears the extra prerequisites of the structure search specified using
addMatch calls.
|
SearchHit[] |
findAllHits()
Looks for all matching patterns in the molecule.
|
SearchHit |
findFirstHit()
Looks for the first matching pattern in the target molecule.
|
SearchHit |
findNextHit()
Searches for the next hit.
|
Molecule |
getQuery()
Retrieves the query structure.
|
protected chemaxon.sss.matcher.StructureMatcher |
getSearcher() |
Molecule |
getTarget()
Retrieves the target molecule.
|
boolean |
isLicensed() |
boolean |
isMatching()
Checks if the query structure matches the target structure with respect to the search options.
|
void |
removeComparator(MolComparator mc)
Delete a comparator from the search object.
|
void |
setLicenseEnvironment(String env) |
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 |
setParameters() |
void |
setQuery(Molecule mol)
Specifies the query structure to search for.
|
void |
setQuery(Molecule mol,
int[] exclude)
Specifies the query structure to search for.
|
void |
setQuery(String queryString)
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 |
setTarget(Molecule mol)
Specifies the target molecule.
|
void |
setTarget(Molecule mol,
int[] exclude)
Specifies the target molecule with excluded atoms.
|
protected void |
setTransformer(Transformer transformer)
Sets the
Transformer to be used for query and target
standardization. |
void |
stop()
Tries to stop the running search as fast as possible.
|
findAll, findAllGroups, findFirst, findFirstGroup, findNext, findNextGroup, getMatchCount, getQueryAsString, getQueryToPrint, getSearchOptions, getTargetAsString, getTargetToPrint, isMatchCountBetween, isMatchCountInRelation, isMatchCountInRelation, isVerbose, setSearchOptions, setVerboseprotected boolean isOrigTargetMayBeMarkush
public void setTarget(Molecule mol)
SearchNote: If the molecule is changed, it will need to be reset for the searcher.
setTarget in interface SimpleSearchersetTarget in class Searchmol - the possibly standardized target molecule. See note on aromatic bondspublic void setTarget(Molecule mol, int[] exclude)
SearchNote: If the molecule is changed, it will need to be reset for the searcher.
setTarget in interface SimpleSearchersetTarget in class Searchmol - the standardized target molecule. See note on aromatic bondsexclude - index of target atoms to exclude from searchpublic Molecule getTarget()
Searchpublic void setQuery(Molecule mol)
SearchsetQuery in interface SimpleSearchersetQuery in class Searchmol - the standardized query structure. See note on aromatic bondspublic void setQuery(Molecule mol, int[] exclude)
SearchsetQuery in interface SimpleSearchersetQuery in class Searchmol - the standardized query structure. See note on aromatic bondsexclude - index of atoms to exclude from searchpublic Molecule getQuery()
Searchpublic void setQuery(String queryString)
queryString - the standardized query structure. See note on aromatic bondsprotected final void setTransformer(Transformer transformer)
Transformer to be used for query and target
standardization. For internal use only.transformer - the transformerpublic 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.
By default there is no standardization.
standardizer - the standardizer,
null for no standardizationpublic void setSearchOptions(MolSearchOptions options)
options - search options. A copy of this object will be stored.Search.getSearchOptions()public void addComparator(MolComparator mc)
mc - comparator to addMolComparator,
removeComparator(MolComparator),
clearComparators(),
SearchOptions.addUserComparator(MolComparator)public void removeComparator(MolComparator mc)
mc - comparator to be removedMolComparator,
addComparator(MolComparator),
clearComparators(),
SearchOptions.deleteUserComparator(MolComparator)public void clearComparators()
public boolean isMatching()
throws SearchException
SearchisMatching in interface SimpleSearcherisMatching in class SearchSearchException - when an error is encountered.Search.findFirstHit(),
Search.findNextHit(),
Search.findAllHits(),
Search.getQuery()public SearchHit findFirstHit() throws SearchException
Search
See SearchHit for more information.
findFirstHit in class Searchnull if there is not hitSearchException - when an error is encountered.Search.findNextHit(),
Search.findAllHits(),
Search.isMatching(),
Search.getQuery(),
Search.findNext(),
Search.findAll(),
Search.findFirstGroup(),
Search.findNextGroup(),
Search.findAllGroups()public SearchHit findNextHit() throws SearchException
SearchSearch.findFirstHit() call is not necessary prior to a Search.findNextHit() call.)
See SearchHit for more information.
findNextHit in interface SimpleSearcherfindNextHit in class Searchnull if there is no more hitSearchException - when an error is encountered.Search.findFirstHit(),
Search.findAllHits(),
Search.isMatching(),
Search.getQuery(),
Search.findFirst(),
Search.findAll(),
Search.findFirstGroup(),
Search.findNextGroup(),
Search.findAllGroups()public SearchHit[] findAllHits() throws SearchException
Search
See SearchHit for more information.
findAllHits in class Searchnull if there are no hits.SearchException - when an error is encountered.Search.findFirstHit(),
Search.findNextHit(),
Search.isMatching(),
Search.findFirst(),
Search.findNext(),
Search.findFirstGroup(),
Search.findNextGroup(),
Search.findAllGroups()public void stop()
Searchprotected void setParameters()
throws SearchException
SearchExceptionprotected final chemaxon.sss.matcher.StructureMatcher getSearcher()
public void addMatch(int queryAtomIndex,
int targetAtomIndex)
Several addMatch() calls represent conditions connected by boolean operator AND.
The effect of all addMatch() calls can be canceled by clearMatch().
addMatch in interface SimpleSearcherqueryAtomIndex - index of the query atomtargetAtomIndex - index of the target atompublic void addMatch(int[] queryAtoms,
int[] targetAtoms,
int length)
SearchSeveral addMatch() calls represent conditions connected by boolean operator AND.
The effect of all addMatch() calls can be canceled by clearMatch().
public void clearMatch()
SearchclearMatch in class Searchpublic static void checkFilter(String filteringExpression) throws chemaxon.nfunk.jep.ParseException
filteringExpression - the expression to be checkedchemaxon.nfunk.jep.ParseException - if the syntax is not correctpublic static void checkFilter(String filteringExpression, File config) throws chemaxon.nfunk.jep.ParseException
filteringExpression - the expression to be checkedconfig - the expression evaluator config XMLchemaxon.nfunk.jep.ParseException - if the syntax is not correctpublic void setOrigTargetMayBeMarkush(boolean value)
value - if false indicates that any bonds appeared only
after tautomer generation.public void setLicenseEnvironment(String env)
setLicenseEnvironment in interface chemaxon.license.Licensablepublic boolean isLicensed()
isLicensed in interface chemaxon.license.Licensable