|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.util.ErrorHandler
chemaxon.jchem.db.JChemSearch
public class JChemSearch
JavaBean for structure searching in structure tables of relational databases.
Example for using the class:
searcher = new JChemSearch();
searcher.setQueryStructure("c1cnccc1Cl");
searcher.setConnectionHandler(conHandler);
searcher.setStructureTable("cduser.structures");
searchOptions = new JChemSearchOptions();
searchOptions.setSearchType(JChemSearch.SIMILARITY);
searchOptions.setDissimilarityThreshold(0.8);
searchOptions.setMaxResultCount(100);
searchOptions.setMaxTime(60000);
searcher.setSearchOptions(searchOptions);
searcher.setRunMode(JChemSearch.RUN_MODE_SYNCH_COMPLETE);
searcher.run();
| Nested Class Summary | |
|---|---|
static class |
JChemSearch.DissimilarityMetrics
Class for presenting the available dissimilarity metrics for similarity search. |
| Field Summary | |
|---|---|
static int |
APPEND_TO_RESULT_TABLE
Constant for the generation of result tables. |
static int |
CREATE_OR_REPLACE_RESULT_TABLE
Constant for the generation of result tables. |
static int |
NO_ORDERING
Constant for ordering the result. |
static int |
NO_RESULT_TABLE
Constant for the generation of result tables. |
static int |
ORDERING_BY_FILTER_ID_LIST
Constant for ordering the result. |
static int |
ORDERING_BY_ID
Constant for ordering the result. |
static int |
ORDERING_BY_ID_OR_SIMILARITY
Constant for ordering the result. |
static int |
RUN_MODE_ASYNCH_COMPLETE
Runs the search in a new thread; run() or
setRunning(boolean) return immediately. |
static int |
RUN_MODE_ASYNCH_PROGRESSIVE
Runs the search in a new thread; run() or
setRunning(boolean) return immediately. |
static int |
RUN_MODE_SYNCH_COMPLETE
The "runner" methods ( run() or setRunning(boolean)
return only after all hits has been found. |
| Fields inherited from class chemaxon.util.ErrorHandler |
|---|
CLASS_NOT_FOUND_ERROR, DATABASE_SEARCH_ERROR, exception, ILLEGAL_ACCESS_ERROR, INSTANTIATION_ERROR, IO_ERROR, MAX_SEARCH_FREQUENCY_EXCEEDED_ERROR, MOL_FORMAT_ERROR, NO_ERROR, PROPERTY_NOT_SET_ERROR, SQL_ERROR, UNIDENTIFIED_ERROR |
| Constructor Summary | |
|---|---|
JChemSearch()
Creates new JChemSearch class |
|
JChemSearch(java.lang.String indexedTable,
java.lang.String indexedColumn)
For internal use only. |
|
| Method Summary | |
|---|---|
void |
cleanResults()
Cleans stored search results. |
static void |
clearCache()
Clears the cache that stores fingerprints and structures. |
int[] |
getAvailableNewHits(int arraySize)
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE. |
static java.util.Hashtable |
getCachedTables()
Gets the names and sizes of tables currently in the cache. |
java.lang.String |
getCacheError()
For checking for cache errors. |
java.sql.Connection |
getConnection()
Getter for property connection. |
ConnectionHandler |
getConnectionHandler()
Getter for property connectionHandler. |
int |
getCurrentId()
Getter for property currentId. |
float[] |
getDissimilarity()
Getter for dissimilarity results. |
float |
getDissimilarity(int index)
Indexed getter for property dissimilarity. |
static JChemSearch.DissimilarityMetrics |
getDissimilarityMetrics(ConnectionHandler ch,
java.lang.String tableName)
Returns the available dissimilarity metrics for the given table. |
java.lang.Throwable |
getException()
Getter for property exception. |
Molecule[] |
getHitsAsMolecules(int[] idList,
HitColoringAndAlignmentOptions options,
java.util.ArrayList dataFieldNames,
java.util.ArrayList dataFieldValues)
Returns hits ready for display. |
RgDecompResults |
getHitsAsRgDecomp(int[] hits,
int attachmentType)
Returns hits as result of r-group decomposition according to the original query. |
int |
getNextHit()
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE. |
int |
getOrder()
Getter for property order. |
java.lang.String |
getProgressMessage()
Getter for property progressMessage. |
java.lang.String |
getQueryStructure()
Getter for property queryStructure. |
int |
getResult(int index)
Indexed getter for property results. |
int |
getResultCount()
Getter for property resultCount. |
int[] |
getResults()
Returns an int array containing the
cd_id values of found compounds. |
java.lang.String |
getResultTable()
Getter for property resultTable. |
int |
getResultTableMode()
Getter for property resultTableMode. |
int |
getRunMode()
Retruns the current run mode. |
int |
getScreenedCount()
Gets the number of screeened structures. |
long |
getScreeningTime()
Gets the screening time. |
JChemSearchOptions |
getSearchOptions()
Returns the SearchOptions object associated with this Search object. |
long |
getSearchTime()
Gets the total search time. |
java.lang.String |
getStructureTable()
Getter for property structureTable. |
int |
getTimeout()
Gets the current timout setting. |
boolean |
hasMoreHits()
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE. |
boolean |
isInfoToStdError()
Getter for property infoToStdError. |
boolean |
isLicensed()
|
boolean |
isMaxResultCountReached()
Getter for property maxResultCountReached. |
boolean |
isMaxTimeReached()
Getter for property maxTimeReached. |
boolean |
isRunning()
Getter for property running. |
boolean |
isStructureCaching()
Getter for property structureCaching. |
void |
run()
Starts searching. |
void |
setCacheExpirationTime(double hours)
Sets the expiration time for the structure cache. |
void |
setConnectionHandler(ConnectionHandler connectionHandler)
Sets the database connection. |
void |
setFilterIDList(int[] ids)
Specifies a list of cd_id's that are allowed to be included in the result set. |
void |
setFilterIDNotList(int[] ids)
Specifies a list of cd_id's that should not to be included in the result set. |
void |
setInfoToStdError(boolean infoToStdError)
Setter for property infoToStdError. |
void |
setLicenseEnvironment(java.lang.String env)
|
void |
setMaxCacheSize(int maxCacheSizeMB)
Sets the desired cache memory allocation policy. |
void |
setMinNonCachedMemory(int minNonCachedMemoryMB)
Sets the desired cache memory allocation policy. |
void |
setNumberOfProcessingThreads(int threads)
Sets the number of processing threads. |
void |
setOrder(int order)
Setter for property order. |
void |
setQueryFingerprint(int[] queryFp)
|
void |
setQueryStructure(Molecule queryMol)
Sets the query structure. |
void |
setQueryStructure(java.lang.String queryStructure)
Setter for property queryStructure. |
void |
setRegCode(long code)
Sets the registration code. |
void |
setResultTable(java.lang.String resultTable)
Setter for property resultTable. |
void |
setResultTableMode(int resultTableMode)
Setter for property resultTableMode. |
void |
setRunMode(int runMode)
Specifies whether the search is performed synchronously or asychronously and if performed asynchronously, whether the hits can be obtained as soon as they are found or only after the search has completed. |
void |
setRunning(boolean run)
Setter for property running. |
void |
setSearchOptions(JChemSearchOptions options)
Sets search parameters. |
void |
setStructureTable(java.lang.String structureTable)
Setter for property structureTable. |
void |
setThreadPriority(int priority)
Sets the priority of the processing threads. |
void |
setTimeout(int seconds)
Sets the timeout value in seconds. |
void |
waitUntilSearchComplete()
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE. |
| Methods inherited from class chemaxon.util.ErrorHandler |
|---|
checkError, checkException, getError, getErrorMessage, getStackTrace |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_RESULT_TABLE
public static final int CREATE_OR_REPLACE_RESULT_TABLE
public static final int APPEND_TO_RESULT_TABLE
public static final int NO_ORDERING
public static final int ORDERING_BY_ID
cd_id values (Value=1)
public static final int ORDERING_BY_ID_OR_SIMILARITY
cd_id values otherwise (Value=2)
public static final int ORDERING_BY_FILTER_ID_LIST
filterIDList
public static final int RUN_MODE_SYNCH_COMPLETE
run() or setRunning(boolean)
return only after all hits has been found.
public static final int RUN_MODE_ASYNCH_COMPLETE
run() or
setRunning(boolean) return immediately.
public static final int RUN_MODE_ASYNCH_PROGRESSIVE
run() or
setRunning(boolean) return immediately. The methods
hasMoreHits(), getNextHit() and
getAvailableNewHits(int) can be used retrieve hits as soon as
they become available. SearchOptions.setSearchType(int)),
JChemSearchOptions.setReturnsNonHits(boolean))
NO_ORDERING (setOrder(int)).
| Constructor Detail |
|---|
public JChemSearch()
public JChemSearch(java.lang.String indexedTable,
java.lang.String indexedColumn)
| Method Detail |
|---|
public java.lang.String getQueryStructure()
public void setQueryStructure(java.lang.String queryStructure)
null or
empty string, then the search returns all molecules.NOTE for Daylight formats:
If search type is SearchConstants.DUPLICATE, SearchConstants.SUPERSTRUCTURE or
SearchConstants.SIMILARITY, treats SMILES/SMARTS input strings as
SMILES, otherwise as SMARTS.
queryStructure - New value of property queryStructure.public void setQueryStructure(Molecule queryMol)
null, then the search returns
all molecules.
queryMol - the query structure.public void setQueryFingerprint(int[] queryFp)
public java.lang.String getStructureTable()
public void setStructureTable(java.lang.String structureTable)
structureTable - New value of property structureTable.public java.lang.Throwable getException()
getException in class ErrorHandlerpublic java.lang.String getCacheError()
null in case of normal execution.public static java.util.Hashtable getCachedTables()
public void setFilterIDList(int[] ids)
ids - the cd_id values in an arraypublic void setFilterIDNotList(int[] ids)
ids - the cd_id values in an array
public static JChemSearch.DissimilarityMetrics getDissimilarityMetrics(ConnectionHandler ch,
java.lang.String tableName)
throws java.sql.SQLException
ch - ConnaectionHandler with live connectiontableName - the name of the JChem structure table
null if no metrics are available
- Throws:
java.sql.SQLException- Since:
- JChem 3.2
- See Also:
JChemSearchOptions.setDissimilarityMetric(String),
MolecularDescriptor.getDefaultDissimilarityMetricThresholds(),
MolecularDescriptor.getDissimilarityMetrics(),
MolecularDescriptor.getDefaultMetricIndex(),
MolecularDescriptor.getMetricName(int)public boolean isStructureCaching()
public boolean isInfoToStdError()
public void setInfoToStdError(boolean infoToStdError)
false)
infoToStdError - New value of property infoToStdError.public ConnectionHandler getConnectionHandler()
public void setConnectionHandler(ConnectionHandler connectionHandler)
connectionHandler - a ConnectionHandler object conaining a live connection
to the databasepublic java.sql.Connection getConnection()
public int getRunMode()
setRunMode(int)public void setRunMode(int runMode)
RUN_MODE_SYNCH_COMPLETE
runMode - public void setSearchOptions(JChemSearchOptions options)
options - search options. Will be copied, modification of the
original object does not affect future searches unless
this method is called again.getSearchOptions()public JChemSearchOptions getSearchOptions()
setSearchOptions(JChemSearchOptions)public int getOrder()
public void setOrder(int order)
order - New value of property order.
Acceptable values:
NO_ORDERING,
ORDERING_BY_ID, and
ORDERING_BY_ID_OR_SIMILARITY
(default).
If an "ORDER BY" clause is used in
filter query, and no
inverse hit list is requested,
this setting is ignored, and the "ORDER BY" clause takes precedence.
public java.lang.String getResultTable()
public void setResultTable(java.lang.String resultTable)
cd_id
of hits. In the case of searching similar structures, the similarity
value is also stored in column similarity.
resultTable - New value of property resultTable.setResultTableMode,
getResultpublic int getResultTableMode()
public void setResultTableMode(int resultTableMode)
NO_RESULT_TABLE
Don't store the results in a table. (Value=0)
CREATE_OR_REPLACE_RESULT_TABLE
Create a result table. If a table with the same name exists,
replace it with the new one. (Value=1)
APPEND_TO_RESULT_TABLE
Append to an existing result table. Create a new one if it
doesn't exist (Value=2)
NO_RESULT_TABLE)
resultTableMode - New value of property resultTableMode.setResultTablepublic void setMaxCacheSize(int maxCacheSizeMB)
minFreeMem is not set to 0,
the program tries to determine the maximum amount of memory available
for allocation by calling the garbage collector and determinig the
available memory.
maxCacheSizeMB - the maximum amount of memory the cache allowed to
utitlize in megabytes.
Set -1 for auto-detection (default):
maxCacheSize = available_memory - minFreeMemsetMinNonCachedMemory(int)public void setMinNonCachedMemory(int minNonCachedMemoryMB)
maxCacheSize is set
to -1 (auto-detect),
the program tries to determine the maximum amount of memory available
for allocation by calling the garbage collector and determinig the
available memory.
minNonCachedMemoryMB - the minimum amount of memory that
should be left free for future non-cache allocations in megabytes.
setMaxCacheSize(int)public void setCacheExpirationTime(double hours)
hours - the time in hours. The default value is 96.
Set to 0 for no expiration.setMaxCacheSize(int),
setMinNonCachedMemory(int)public void setNumberOfProcessingThreads(int threads)
threads - the number of threads.public void setThreadPriority(int priority)
setRunMode(int) is set to
either RUN_MODE_ASYNCH_COMPLETE or
RUN_MODE_ASYNCH_PROGRESSIVE.
priority - the priority ranging 1 (Thread.MIN_PRIORITY)
to 10 (Thread.MAX_PRIORITY).Thread.MIN_PRIORITY).public int getResult(int index)
cd_id value of the found compound specified by
index.
If result table is generated,
getResult throws NullPointerException.
index - Index of the property.
index.setResultTablepublic int[] getResults()
int array containing the
cd_id values of found compounds.
If a result table is generated in the database,
it returns null.
public void cleanResults()
public float getDissimilarity(int index)
index and the query structure.
If searching has not been finished yet or if a result table is generated,
getDissimilarity throws NullPointerException.
index - Index of the property.
index.setResultTablepublic float[] getDissimilarity()
getDissimilarity throws NullPointerException.
setResultTablepublic java.lang.String getProgressMessage()
public int getCurrentId()
public boolean isMaxResultCountReached()
public boolean isMaxTimeReached()
public int getResultCount()
public void setTimeout(int seconds)
isRunning() must be constantly called within the specified time
interval, otherwise the search stops. Useful if the user no longer
monitors the search process, e.g. closes the browser window.
seconds - the timeout in seconds. Set to 0 to disable (default).setRunMode(int)public int getTimeout()
setTimeout(int)public boolean isRunning()
public void setRunning(boolean run)
throws java.sql.SQLException,
MolFormatException,
java.io.IOException,
DatabaseSearchException,
PropertyNotSetException
true and the search has not been started yet,
then searching is unleashed.
If it is set to false and a search is running, the
the process will be stopped.
(Default: false)
run - New value of property run.
java.sql.SQLException
MolFormatException
java.io.IOException
DatabaseSearchException
PropertyNotSetException
public void run()
throws java.sql.SQLException,
MolFormatException,
java.io.IOException,
DatabaseSearchException,
PropertyNotSetException
setRunning(true)
java.sql.SQLException
MolFormatException
java.io.IOException
DatabaseSearchException
PropertyNotSetExceptionpublic static void clearCache()
public int getScreenedCount()
public long getScreeningTime()
public long getSearchTime()
public RgDecompResults getHitsAsRgDecomp(int[] hits,
int attachmentType)
throws chemaxon.sss.search.SearchException,
MolFormatException,
java.sql.SQLException
RgDecompResults.getScaffold())
RgDecompResults.getLigandsNumber())
RgDecompResults.getIncludedIds())
RgDecompResults.getSkippedIds())
RgDecompResults.getHitsAsMarkush())
RgDecompResults.getHitsAsRgDecomp())
RgDecompResults.getHitsAsTable())
Format of the table (first row is header row, following rows contain
targets, 1 hit/target):
[query]: molecule R1 R2 R3 ... --------------------------------------------------------- [target1]: molecule1 ligand1.1 ligand1.2 ligand1.3 [target2]: molecule2 ligand2.1 ligand2.2 ligand2.3As an example see decomposition table
hits - cd_ids of target structuresattachmentType - Type of visualization of attachment of ligands.
chemaxon.sss.search.SearchException
MolFormatException
java.sql.SQLExceptionRgDecompResults,
Decomposition.ATTACHMENT_NONE,
Decomposition.ATTACHMENT_POINT,
Decomposition.ATTACHMENT_MAP,
Decomposition.ATTACHMENT_LABEL,
Decomposition.ATTACHMENT_ATOM,
Decomposition.ATTACHMENT_RLABEL
public Molecule[] getHitsAsMolecules(int[] idList,
HitColoringAndAlignmentOptions options,
java.util.ArrayList dataFieldNames,
java.util.ArrayList dataFieldValues)
throws java.sql.SQLException,
java.io.IOException,
chemaxon.sss.search.SearchException,
chemaxon.enumeration.supergraph.SupergraphException,
PropertyNotSetException,
DatabaseSearchException
idList - the cd_id list of hits to be retrieved.options - the options for coloring and alignment.
If null the structures will be displayed in their original
form.dataFieldNames - fields of the jchem table that should be fetched
together with the structure or null.dataFieldValues - an empty ArrayList required or can be
null.
The fetched values will be stored in this object as Object[] elements.
SearchConstants.SUPERSTRUCTURE
search mode, always the query structure is returned, the target subgraph
is colored.
java.sql.SQLException
java.io.IOException
chemaxon.sss.search.SearchException
chemaxon.enumeration.supergraph.SupergraphException
PropertyNotSetException
DatabaseSearchExceptionpublic void setRegCode(long code)
code - the code. If not 0, overrides the value
found in the property table.public boolean isLicensed()
isLicensed in interface chemaxon.license.Licensablepublic void setLicenseEnvironment(java.lang.String env)
setLicenseEnvironment in interface chemaxon.license.Licensable
public boolean hasMoreHits()
throws java.lang.InterruptedException
RUN_MODE_ASYNCH_PROGRESSIVE. true if there are more hits to retrieve with
getNextHit() or getAvailableNewHits(int),
false otherwise.
true if there are more hits to retrieve with
getNextHit() or getAvailableNewHits(int),
false otherwise.
java.lang.InterruptedException
public int getNextHit()
throws java.lang.InterruptedException
RUN_MODE_ASYNCH_PROGRESSIVE.
java.lang.InterruptedException - if the calling thread was interrupted while waiting for the
next available hit.
public int[] getAvailableNewHits(int arraySize)
throws java.lang.InterruptedException,
DatabaseSearchException
RUN_MODE_ASYNCH_PROGRESSIVE. arraySize new hits.
arraySize -
arraySize new hits.
java.lang.InterruptedException - if the calling thread was interrupted while waiting.
DatabaseSearchException
public void waitUntilSearchComplete()
throws java.lang.InterruptedException
RUN_MODE_ASYNCH_PROGRESSIVE.
java.lang.InterruptedException - if the calling thread was interrupted while waiting.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||