|
|||||||||
| 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:
setQuery()
is not implemented yet for RgMolecules either.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 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 |
|---|
MRV_OUTPUT_LEVEL, preMatchLength, preMatchQueryAtoms, preMatchTargetAtoms, searchOptions |
| 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_NONE, CHIRALITYSUPPORT_SELECTED, CIS, CTUMASK, CTUNKNOWN, CTUNSPEC, DBS_ALL, DBS_MARKED, DBS_NONE, ENDO, EXO, PARITY_ALLENE, PARITY_EITHER, PARITY_EVEN, PARITY_MASK, PARITY_ODD, PARITY_TETRAHEDRAL, PARITY_UNSPEC, STGRP_ABS, STGRP_AND, STGRP_NONE, STGRP_OR, SYN, TRANS |
| Constructor Summary | |
|---|---|
MolSearch()
Constructs a MolSearch object. |
|
| Method Summary | |
|---|---|
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 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()
Delete all comparator from the search object. |
void |
clearMatch()
Clears the extra prerequisites of the structure search specified using addMatch calls. |
protected boolean |
filter(SearchHit hit)
Returns true if the hit is accepted by the filteringExpression. |
SearchHit[] |
findAllHits()
Looks for all matching patterns in the molecule. |
SearchHit |
findFirstHit()
Looks for the first matching pattern in the target molecule. |
SearchHit |
findNextHit()
Looks for the next matching pattern in the target molecule. |
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 |
getQuery()
Retrieves the query structure stored in the MolSearch object. |
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()
Gets whether searching is included in the user licence. |
boolean |
isMatching()
Checks if the query structure matches a substructure in the molecule. |
void |
removeComparator(MolComparator mc)
Delete a comparator from the search object. |
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 |
setLicenseEnvironment(java.lang.String env)
Set the license to be used by the search object. |
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 |
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 chemaxon.sss.search.Search |
|---|
areMatchingBondTypes, areMatchingBondTypes, findAll, findAllGroups, findFirst, findFirstGroup, findNext, findNextGroup, getAtomStereo, getMatchCount, getQueryAsString, getQueryToPrint, getSearchOptions, getTargetAsString, getTargetToPrint, isMatchCountBetween, isMatchCountInRelation, isVerbose, logException, setSearchOptions, setVerbose |
| 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
protected boolean isOrigTargetMayBeMarkush
| Constructor Detail |
|---|
public MolSearch()
| Method Detail |
|---|
public void setTarget(Molecule mol)
setTarget in interface chemaxon.util.search.MolSearchersetTarget 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 Molecule getTarget()
getTarget in class Searchpublic void setQuery(Molecule mol)
setQuery in interface chemaxon.util.search.MolSearchersetQuery 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 void setQuery(java.lang.String queryString)
queryString - 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)
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 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)
mc - comparator 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()
MolComparator,
addComparator(MolComparator),
clearComparators(),
SearchOptions.deleteAllUserComparators()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.SearchExceptionSearch.findFirst(),
Search.findNext(),
Search.findAll()
public SearchHit findFirstHit()
throws chemaxon.sss.search.SearchException
findFirstHit in class Searchnull if there is not hit
chemaxon.sss.search.SearchExceptionfindNextHit(),
findAllHits(),
Search.findNext(),
Search.findAll(),
Search.findFirstGroup(),
Search.findNextGroup(),
Search.findAllGroups(),
isMatching(),
getMatchingQuery()
public SearchHit findNextHit()
throws chemaxon.sss.search.SearchException
findFirstHit() call is not necessary prior to a findNextHit() call.)
findNextHit in class Searchnull if there is no more hit
chemaxon.sss.search.SearchExceptionfindFirstHit(),
findAllHits(),
Search.findFirst(),
Search.findAll(),
Search.findFirstGroup(),
Search.findNextGroup(),
Search.findAllGroups(),
isMatching(),
getMatchingQuery()
public SearchHit[] findAllHits()
throws chemaxon.sss.search.SearchException
findAllHits in class Searchnull if there are no hits.
chemaxon.sss.search.SearchExceptionfindFirstHit(),
findNextHit(),
isMatching(),
Search.findFirst(),
Search.findNext(),
Search.findFirstGroup(),
Search.findNextGroup(),
Search.findAllGroups()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(SearchHit 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 void setOrigTargetMayBeMarkush(boolean value)
value - if true indicates that any bonds appeared only after
tautomer generation.public void setLicenseEnvironment(java.lang.String env)
setLicenseEnvironment in interface chemaxon.license.Licensablepublic boolean isLicensed()
isLicensed in interface chemaxon.license.Licensabletrue if searching is included in the license,
false otherwise
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||