|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.sss.search.Search
chemaxon.sss.search.MolSearch
public class MolSearch
Atom-by-atom structure search.
Features:
For correct behaviour of the MolSearch class, both the query and target
molecules has to be standardized prior to searching. See note on aromatic
bonds Alternatively, you can use the StandardizedMolSearch class.
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
| Field Summary | |
|---|---|
protected int[][] |
groupHit
|
protected chemaxon.sss.search.ratom.GroupHitHandler |
groupHitHandler
Group hit handler. |
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. |
protected boolean |
isQueryStandardizable
|
protected boolean |
isTargetStandardizable
|
| Fields inherited from class chemaxon.sss.search.Search |
|---|
preMatchLength, preMatchQueryAtoms, preMatchTargetAtoms, searchOptions |
| Fields inherited from interface chemaxon.struc.StereoConstants |
|---|
ATOMSTEREO_EITHER, ATOMSTEREO_MASK, ATOMSTEREO_NONE, ATOMSTEREO_SPECIFIC, CHIRALITY_MASK, CHIRALITY_R, CHIRALITY_S, CHIRALITYSUPPORT_ALL, CHIRALITYSUPPORT_NONE, CHIRALITYSUPPORT_SELECTED, CIS, CTUMASK, CTUNKNOWN, CTUNSPEC, DBS_ALL, DBS_MARKED, DBS_NONE, PARITY_EITHER, PARITY_EVEN, PARITY_MASK, PARITY_ODD, PARITY_UNSPEC, STGRP_ABS, STGRP_AND, STGRP_NONE, STGRP_OR, TRANS |
| Constructor Summary | |
|---|---|
MolSearch()
Constructs a MolSearch object. |
|
| Method Summary | |
|---|---|
void |
addComparator(MolComparator mc)
|
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 queryAtom,
int targetAtom)
Specifies an extra prerequisite of the structure search that queryAtom must match to targetAtom only. |
static void |
checkFilter(java.lang.String filteringExpression)
Checks the syntax of the filtering expression. |
static void |
checkFilter(java.lang.String filteringExpression,
java.io.File config)
Checks the syntax of the filtering expression. |
void |
clearComparators()
|
void |
clearMatch()
Clears the extra prerequisites of the structure search specified using addMatch calls. |
protected boolean |
filter(int[] hit)
Returns true if the hit is accepted by the filteringExpression. |
int[][] |
findAll()
Looks for all matching patterns in the molecule. |
int[][][] |
findAllGroups()
Returns the group hits corresponding to all hits. |
int[][] |
findAllOrder()
Deprecated. Use setOrderSensitiveSearch(true) instead |
int[] |
findFirst()
Looks for the first matching pattern in the target molecule. |
int[][] |
findFirstGroup()
Returns the group hit corresponding to the first hit. |
int[] |
findNext()
Looks for the next matching pattern in the target molecule. |
int[][] |
findNextGroup()
Returns the group hit corresponding to the next hit. |
java.lang.String |
getFilter()
Returns the filtering expression. |
int[][] |
getGroupHit(int[] hit)
Gets the 2D hit in which there might be several target atoms belonging to the same query atom (e.g. undefined Ratom, query side homology atom). |
Molecule |
getMatchingQuery()
Returns the most specific enumeration of the query which produced the hit vector of the last findNext(), findFirst() or findAll() result. |
Molecule |
getMatchingTarget()
Returns the most specific enumeration of the target which produced the hit vector of the last findNext(), findFirst() or findAll() result. |
Molecule |
getMolecule()
Deprecated. Use getTarget instead |
Molecule |
getQuery()
Retrieves the query structure stored in the MolSearch object. |
Molecule |
getQueryStructure()
Deprecated. Use getQuery instead |
Molecule |
getTarget()
Retrieves the target molecule to search in. |
protected boolean |
hasFilter()
Returns true if filter is set. |
protected boolean |
hasHitFilter()
Returns true if filter is set and
references the hit, not only the query/target structures. |
boolean |
isLicensed()
|
boolean |
isMatching()
Checks if the query structure matches a substructure in the molecule. |
protected boolean |
keepGroupOrder()
Return false if groups in group hit should be reordered
so that scaffold ligand matching the R-atom should come first. |
void |
removeComparator(MolComparator mc)
|
void |
setFilter(java.lang.String filteringExpression)
Sets the filtering expression. |
void |
setFilterConfig(java.io.File config)
Sets additional evaluator configuration for filtering expression evaluation. |
void |
setFilterConfig(java.io.File config,
Standardizer st)
Deprecated. Please use setFilterConfig(File) and/or
setStandardizer(chemaxon.reaction.Standardizer, boolean, boolean)
instead. |
void |
setHitIncludesRNodes(boolean value)
Deprecated. Since 5.0 Use MolSearchOptions.setHitIncludesRNodes(boolean) instead. |
void |
setLicenseEnvironment(java.lang.String env)
|
void |
setMolecule(Molecule mol)
Deprecated. Use setTarget instead |
void |
setOrigTargetMayBeMarkush(boolean value)
Only for internal use! |
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(java.lang.String queryString)
Specifies the query structure to search for in String format. |
void |
setQueryStructure(Molecule mol)
Deprecated. Use setQuery instead |
void |
setSearchOptions(MolSearchOptions options)
Sets search parameters. |
void |
setStandardizer(Standardizer st,
boolean bq,
boolean bt)
Sets standardizer object of this MolSearch class, to be used for the query and target molecules, Chemical Terms configuration and re-standardization of query tautomers at tautomer searching. |
void |
setTarget(Molecule mol)
Specifies the target molecule to search in. |
void |
setTarget(Molecule mol,
int[] exclude)
Specifies the target molecule to search in. |
void |
stop()
Tries to stop the running search as fast as possible. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected chemaxon.sss.search.ratom.GroupHitHandler groupHitHandler
RGroupDecomposition to construct the fragments.
protected int[][] groupHit
protected boolean isQueryStandardizable
protected boolean isTargetStandardizable
protected boolean isOrigTargetMayBeMarkush
| Constructor Detail |
|---|
public MolSearch()
| Method Detail |
|---|
public void setTarget(Molecule mol)
setTarget in class Searchmol - the possibly standardized target molecule. See
note on aromatic bonds
public void setTarget(Molecule mol,
int[] exclude)
setTarget in class Searchmol - the standardized target molecule. See
note on aromatic bondsexclude - index of target atoms to exclude from searchpublic void setMolecule(Molecule mol)
setTarget instead
mol - the standardized target molecule. See
note on aromatic bondspublic Molecule getTarget()
getTarget in class Searchpublic Molecule getMolecule()
getTarget instead
public void setQuery(Molecule mol)
setQuery in class Searchmol - the standardized query structure. See note on aromatic bondsprotected boolean keepGroupOrder()
false if groups in group hit should be reordered
so that scaffold ligand matching the R-atom should come first.
false if groups in group hit should be reordered
public void setQuery(Molecule mol,
int[] exclude)
setQuery in class Searchmol - the standardized query structure. See note on aromatic bondsexclude - index of atoms to exclude from searchpublic Molecule getQuery()
getQuery in class Searchpublic void setQuery(java.lang.String queryString)
queryString - the standardized query structure. See note on aromatic bondspublic Molecule getQueryStructure()
getQuery instead
public void setQueryStructure(Molecule mol)
setQuery instead
mol - the standardized query structure. See note on aromatic bonds
public void setStandardizer(Standardizer st,
boolean bq,
boolean bt)
st - Standardizer object. null means default aromatization.
WARNING: Standardization that changes atom indexes are not supported!bq - if true, standardization is done on query.bt - if true, standardization is done on target.
public void setFilterConfig(java.io.File config,
Standardizer st)
throws chemaxon.sss.search.SearchException
setFilterConfig(File) and/or
setStandardizer(chemaxon.reaction.Standardizer, boolean, boolean)
instead.
config - the expression evaluator config XMLst - the expression evaluator config standardizer
chemaxon.sss.search.SearchException
public void setFilterConfig(java.io.File config)
throws chemaxon.sss.search.SearchException
config - the expression evaluator config XML
chemaxon.sss.search.SearchException
public void setFilter(java.lang.String filteringExpression)
throws chemaxon.sss.search.SearchException
filteringExpression - the filtering expression
chemaxon.sss.search.SearchExceptionpublic java.lang.String getFilter()
public void setHitIncludesRNodes(boolean value)
MolSearchOptions.setHitIncludesRNodes(boolean) instead.
value - if set to false, the hits will contain only the
matching atom indexes for non-R-group atoms in the root structure, in
order (default). In this case the hit list contains less indexes, than
the number of nodes in the root structure. true, the hit list will contain placeholders for
the R-nodes with the value of SearchConstants.R_NODE_PLACEHOLDER, thus
maintaining root indexes in the result.public void setSearchOptions(MolSearchOptions options)
options - search options. Will be copied, modification of the
original object does not affect future searches unless
this method is called again.Search.getSearchOptions()public Molecule getMatchingQuery()
getMatchingQuery in class SearchgetMatchingTarget()public Molecule getMatchingTarget()
getMatchingQuery()public void addComparator(MolComparator mc)
public void removeComparator(MolComparator mc)
public void clearComparators()
protected boolean hasFilter()
true if filter is set.
true if filter is setprotected boolean hasHitFilter()
true if filter is set and
references the hit, not only the query/target structures.
true if filter references the hit
public boolean isMatching()
throws chemaxon.sss.search.SearchException
isMatching in class Searchchemaxon.sss.search.SearchExceptionfindFirst(),
findNext(),
findAll()
public int[] findFirst()
throws chemaxon.sss.search.SearchException
findFirst in class Searchnull if there are no hits.
Special atom indexes: see description in findNext().
chemaxon.sss.search.SearchExceptionfindNext(),
findAll(),
findFirstGroup(),
findNextGroup(),
findAllGroups(),
isMatching(),
getMatchingQuery()
public int[] findNext()
throws chemaxon.sss.search.SearchException
findFirst() call is not necessary prior to a findNext() call.)
findNext in class Searchnull if there are no more hits.
Special atom indexes:
Integer.MIN_VALUE in case of 0
heavy atom index.
Integer.MIN_VALUE
for 0 index. SearchConstants.HIT_LP is set
for isolated lone pairs (in which case there is no such target heavy atom).
SearchConstants.HIT_MULTICENTER
for these atoms.
SearchConstants.HIT_R
for these atoms. If the "hitIncludesRNodes" parameter is NOT set then only the
scaffold atoms are included in the match array. See
MolSearchOptions.setHitIncludesRNodes(boolean).
SearchOptions.setUndefinedRAtom(int).
In case of undefined R-atom matching a group of atoms
(see SearchOptions.isUndefinedRAtomMatchingGroup()),
only one matching atom is set in the match array, or
SearchConstants.HIT_R_EMPTY_MATCH denoting the empty group.
To get the matching groups call findFirstGroup(), findNextGroup()
or findAllGroups().
SearchConstants.HIT_UNMAPABLE in the match array.
setTarget(chemaxon.struc.Molecule,int[])) will not
appear in the match array at all (their appropriate indexes are
left out).
getMatchingQuery() can be
used to get the most specific matching form of the query.
chemaxon.sss.search.SearchExceptionfindFirst(),
findAll(),
findFirstGroup(),
findNextGroup(),
findAllGroups(),
isMatching(),
getMatchingQuery()
public int[][] findAll()
throws chemaxon.sss.search.SearchException
findAll in class Searchnull 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).
Special atom indexes: see description in findNext().
chemaxon.sss.search.SearchExceptionisMatching(),
findFirst(),
findNext(),
findFirstGroup(),
findNextGroup(),
findAllGroups()
public int[][] findAllOrder()
throws chemaxon.sss.search.SearchException
setOrderSensitiveSearch(true) instead
findAll(), but returns hits in every possible order.
chemaxon.sss.search.SearchException
public int[][] findFirstGroup()
throws chemaxon.sss.search.SearchException
SearchOptions.setUndefinedRAtom(int)).
If the SearchConstants.UNDEF_R_MATCHING_GROUP_H_EMPTY
option is set then empty match is denoted by an empty int[] array.
For special matching atom indexes, refer to the description in findNext().
chemaxon.sss.search.SearchExceptionfindNextGroup(),
findAllGroups(),
isMatching(),
getMatchingQuery(),
findFirst(),
findNext(),
findAll()
public int[][] findNextGroup()
throws chemaxon.sss.search.SearchException
SearchOptions.setUndefinedRAtom(int)).
If the SearchConstants.UNDEF_R_MATCHING_GROUP_H_EMPTY
option is set then empty match is denoted by an empty int[] array.
For special matching atom indexes, refer to the description in findNext().
chemaxon.sss.search.SearchExceptionfindFirstGroup(),
findAllGroups(),
isMatching(),
getMatchingQuery(),
findFirst(),
findNext(),
findAll()
public int[][][] findAllGroups()
throws chemaxon.sss.search.SearchException
SearchOptions.setUndefinedRAtom(int)).
If the SearchConstants.UNDEF_R_MATCHING_GROUP_H_EMPTY
option is set then empty match is denoted by an empty int[] array.
For special matching atom indexes, refer to the description in findNext().
chemaxon.sss.search.SearchExceptionfindFirstGroup(),
findNextGroup(),
isMatching(),
findFirst(),
findNext(),
findAll()public void stop()
stop in class Search
public void addMatch(int queryAtom,
int targetAtom)
Several addMatch() calls represent conditions connected by boolean operator AND.
The effect of all addMatch() calls can be canceled by clearMatch().
addMatch in class Search
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().
addMatch in class Searchpublic void clearMatch()
clearMatch in class Search
protected boolean filter(int[] hit)
throws chemaxon.sss.search.SearchException
true if the hit is accepted by the filteringExpression.
If the filteringExpression is not set or the hit is null then
also returns true.
hit - is the search hit
true if the hit is accepted
chemaxon.sss.search.SearchException
public static void checkFilter(java.lang.String filteringExpression)
throws chemaxon.nfunk.jep.ParseException
filteringExpression - the expression to be checked
chemaxon.nfunk.jep.ParseException - if the syntax is not sorrect
public static void checkFilter(java.lang.String filteringExpression,
java.io.File config)
throws chemaxon.nfunk.jep.ParseException
filteringExpression - the expression to be checkedconfig - the expression evaluator config XML
chemaxon.nfunk.jep.ParseException - if the syntax is not sorrectpublic int[][] getGroupHit(int[] hit)
getGroupHit in class Searchhit - the normal 1-1 1D hit.
findFirstGroup(),
findNextGroup(),
findAllGroups()public void setOrigTargetMayBeMarkush(boolean value)
public void setLicenseEnvironment(java.lang.String env)
setLicenseEnvironment in interface chemaxon.license.Licensablepublic boolean isLicensed()
isLicensed in interface chemaxon.license.Licensable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||