|
||||||||||
| 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
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();
// use SMILES string as query
MolHandler mh1 = new MolHandler("c1ccccc1Cl");
// 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 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[][] |
findAllOrder()
Deprecated. Use setOrderSensitiveSearch(true) instead |
int[] |
findFirst()
Looks for the first matching pattern in the target molecule. |
int[] |
findNext()
Looks for the next matching pattern in the target molecule. |
int[][] |
get2DHit()
|
java.lang.String |
getFilter()
Returns the filtering expression. |
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 |
isMatching()
Checks if the query structure matches a substructure in the molecule. |
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 |
setMolecule(Molecule mol)
Deprecated. Use setTarget instead |
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 |
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 boolean isQueryStandardizable
protected boolean isTargetStandardizable
| 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 bonds
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 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 indices:
MolSearchOptions.setHitIncludesRNodes(boolean)
setTarget(chemaxon.struc.Molecule,int[])) will not
appear in the match array at all (their appropriate indices are
left out).
getMatchingQuery() can be
used to get the most specific matching form of the query.
chemaxon.sss.search.SearchExceptionfindNext(),
findAll(),
isMatching(),
getMatchingQuery()
public int[] findNext()
throws chemaxon.sss.search.SearchException
findNext in class Searchnull if there are no more hits.
Special atom indices:
MolSearchOptions.setHitIncludesRNodes(boolean)
setTarget(chemaxon.struc.Molecule,int[])) will not
appear in the match array at all (their appropriate indices are
left out).
getMatchingQuery() can be
used to get the most specific matching form of the query.
chemaxon.sss.search.SearchExceptionfindFirst(),
findAll(),
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 indices:
MolSearchOptions.setHitIncludesRNodes(boolean)
setTarget(chemaxon.struc.Molecule, int[])) will not
appear in the match array at all (their appropriate indices are
left out).
chemaxon.sss.search.SearchExceptionisMatching(),
findFirst(),
findNext()
public int[][] findAllOrder()
throws chemaxon.sss.search.SearchException
setOrderSensitiveSearch(true) instead
findAll(), but returns hits in every possible order.
chemaxon.sss.search.SearchExceptionpublic 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[][] get2DHit()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||