chemaxon.jchem.db
Class JChemSearch

java.lang.Object
  extended by chemaxon.util.ErrorHandler
      extended by chemaxon.jchem.db.JChemSearch
All Implemented Interfaces:
TableTypeConstants, chemaxon.license.Licensable, SearchConstants, java.io.Serializable

public class JChemSearch
extends ErrorHandler
implements java.io.Serializable, SearchConstants, TableTypeConstants, chemaxon.license.Licensable

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();
 

Author:
Ferenc Csizmadia, Szilard Dorant
See Also:
Serialized Form

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
 
Fields inherited from interface chemaxon.sss.SearchConstants
ABS_STEREO_ALWAYS_ON, ABS_STEREO_CHIRAL_FLAG, ABS_STEREO_TABLE_OPTION, ATTACHED_DATA_MATCH_EXACT, ATTACHED_DATA_MATCH_GENERAL, ATTACHED_DATA_MATCH_IGNORE, CHARGE_MATCHING_DEFAULT, CHARGE_MATCHING_EXACT, CHARGE_MATCHING_IGNORE, DEFAULT_DISSIMILARITY_THRESHOLD, DEFAULT_SIMILARITY_THRESHOLD, DISSIMILARITY, DUPLICATE, EXACT, EXACT_FRAGMENT, EXACT_FRAGMENT_OFF, EXACT_FRAGMENT_ON, FULL, FULL_FRAGMENT, HCOUNT_MATCHING_AUTO, HCOUNT_MATCHING_EQUAL, HCOUNT_MATCHING_GREATER_OR_EQUAL, HIT_EXCLUDEDQ, HIT_LP, HIT_MULTICENTER, HIT_NON_R, HIT_R, HIT_R_EMPTY_MATCH, HIT_UNMAPABLE, IMPLICIT_H_MATCHING_DEFAULT, IMPLICIT_H_MATCHING_DISABLED, IMPLICIT_H_MATCHING_ENABLED, ISOTOPE_MATCHING_DEFAULT, ISOTOPE_MATCHING_EXACT, ISOTOPE_MATCHING_IGNORE, KEEP_QUERY_ORDER, MARKUSH_AROM_FINAL_CHECK, MARKUSH_AROM_NO_FINAL_CHECK, MARKUSH_AROM_OFF, MARKUSH_DISABLED, MARKUSH_ENABLED, MARKUSH_HIT_INNER, MARKUSH_HIT_ORIGINAL, MATCH_COUNT_BETWEEN, MATCH_COUNT_RELATION, MIX_SGROUP_MATCHING_OFF, MIX_SGROUP_MATCHING_ON, NO_ABAS, NO_SCREEN, OPTION_CHARGE_MATCHING, OPTION_EXACT_FRAGMENT, OPTION_ISOTOPE_MATCHING, OPTION_KEEP_QUERY_ORDER, OPTION_MARKUSH_AROM, OPTION_MARKUSH_ENABLED, OPTION_MARKUSH_HIT, OPTION_MIX_SGROUP_MATCHING, OPTION_RADICAL_MATCHING, OPTION_STEREO_MODEL, OPTION_TAUTOMER_SEARCH, OPTION_VAGUE_BOND, OPTION_VALENCE_MATCHING, PERFECT, R_NODE_PLACEHOLDER, RADICAL_MATCHING_DEFAULT, RADICAL_MATCHING_EXACT, RADICAL_MATCHING_IGNORE, REARRANGE_QUERY, SEARCH_MODE_NAMES, SEARCH_OPTIONS_LENGTH, SIMILARITY, STEREO_DIASTEREOMER, STEREO_EXACT, STEREO_IGNORE, STEREO_MODEL_COMPREHENSIVE, STEREO_MODEL_DEFAULT, STEREO_MODEL_GLOBAL, STEREO_MODEL_LOCAL, STEREO_SPECIFIC, SUBSTRUCTURE, SUPERSTRUCTURE, TAUTOMER_SEARCH_OFF, TAUTOMER_SEARCH_ON, 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, VALENCE_MATCHING_IGNORE, VALENCE_MATCHING_ON
 
Fields inherited from interface chemaxon.jchem.db.TableTypeConstants
FP_DEFAULT_BITS_PER_PATTERN, FP_DEFAULT_LENGTH_IN_INTS, FP_DEFAULT_PATTERN_LENGTH, MYSQL_DEFAULT_TABLE_TYPE, MYSQL_FORCE_INNO_DB, MYSQL_FORCE_MYISAM, TABLE_TYPE_ANY_STRUCTURES, TABLE_TYPE_DEFAULT, TABLE_TYPE_EXPLANATIONS, TABLE_TYPE_IS_NOT_SUPPORTED, TABLE_TYPE_MARKUSH_LIBRARIES, TABLE_TYPE_MOLECULES, TABLE_TYPE_NAMES, TABLE_TYPE_QUERY_STRUCTURES, TABLE_TYPE_REACTIONS
 
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

NO_RESULT_TABLE

public static final int NO_RESULT_TABLE
Constant for the generation of result tables. Meaning: Don't store the results in a table. (Value=0)

See Also:
Constant Field Values

CREATE_OR_REPLACE_RESULT_TABLE

public static final int CREATE_OR_REPLACE_RESULT_TABLE
Constant for the generation of result tables. Meaning: Create a result table. If a table with same name exists, replace it with the new one. (Value=2)

See Also:
Constant Field Values

APPEND_TO_RESULT_TABLE

public static final int APPEND_TO_RESULT_TABLE
Constant for the generation of result tables. Meaning: Append to an existing result table. Create a new one if it doesn't exist (Value=3)

See Also:
Constant Field Values

NO_ORDERING

public static final int NO_ORDERING
Constant for ordering the result. Meaning: Don't order the result (Value=0)

See Also:
Constant Field Values

ORDERING_BY_ID

public static final int ORDERING_BY_ID
Constant for ordering the result. Meaning: Order the result according to the cd_id values (Value=1)

See Also:
Constant Field Values

ORDERING_BY_ID_OR_SIMILARITY

public static final int ORDERING_BY_ID_OR_SIMILARITY
Constant for ordering the result. Meaning: Order the result according to the calculated dissimilarity in the case of dissimilarity searching, use the cd_id values otherwise (Value=2)

See Also:
Constant Field Values

ORDERING_BY_FILTER_ID_LIST

public static final int ORDERING_BY_FILTER_ID_LIST
Constant for ordering the result. Meaning: Order the result according to the filterIDList

See Also:
Constant Field Values

RUN_MODE_SYNCH_COMPLETE

public static final int RUN_MODE_SYNCH_COMPLETE
The "runner" methods (run() or setRunning(boolean) return only after all hits has been found.

Since:
JChem 5.0
See Also:
Constant Field Values

RUN_MODE_ASYNCH_COMPLETE

public static final int RUN_MODE_ASYNCH_COMPLETE
Runs the search in a new thread; run() or setRunning(boolean) return immediately.

Since:
JChem 5.0
See Also:
Constant Field Values

RUN_MODE_ASYNCH_PROGRESSIVE

public static final int RUN_MODE_ASYNCH_PROGRESSIVE
Runs the search in a new thread; run() or setRunning(boolean) return immediately. The methods hasMoreHits(), getNextHit() and getAvailableNewHits(int) can be used retrieve hits as soon as they become available.
This mode doesn't support

Since:
JChem 5.0
See Also:
Constant Field Values
Constructor Detail

JChemSearch

public JChemSearch()
Creates new JChemSearch class


JChemSearch

public JChemSearch(java.lang.String indexedTable,
                   java.lang.String indexedColumn)
For internal use only.

Method Detail

getQueryStructure

public java.lang.String getQueryStructure()
Getter for property queryStructure.

Returns:
Value of property queryStructure.

setQueryStructure

public void setQueryStructure(java.lang.String queryStructure)
Setter for property queryStructure. The query structure may be in MDL Molfile, Smiles or other format recognized by JChem. If the specified value is 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.

Parameters:
queryStructure - New value of property queryStructure.

setQueryStructure

public void setQueryStructure(Molecule queryMol)
Sets the query structure. If the specified value is null, then the search returns all molecules.

Parameters:
queryMol - the query structure.

setQueryFingerprint

public void setQueryFingerprint(int[] queryFp)

getStructureTable

public java.lang.String getStructureTable()
Getter for property structureTable.

Returns:
Value of property structureTable.

setStructureTable

public void setStructureTable(java.lang.String structureTable)
Setter for property structureTable. It specifies the name of the table to be searched for structures containing the query.

Parameters:
structureTable - New value of property structureTable.

getException

public java.lang.Throwable getException()
Getter for property exception. The ancestor's method is overloaded to allow handling exceptions occuring in the searching thread.

Overrides:
getException in class ErrorHandler
Returns:
Value of property exception.

getCacheError

public java.lang.String getCacheError()
For checking for cache errors. Should be called after the search is finished.

Returns:
the error text, or null in case of normal execution.
Since:
JChem 3.0

getCachedTables

public static java.util.Hashtable getCachedTables()
Gets the names and sizes of tables currently in the cache.

Returns:
the names and allocated memory size in bytes as key - value (String - Long) pairs.
Since:
JChem 3.0

setFilterIDList

public void setFilterIDList(int[] ids)
Specifies a list of cd_id's that are allowed to be included in the result set. Useful for narrowing the result of a previous search.

Parameters:
ids - the cd_id values in an array
Since:
JChem 3.1

setFilterIDNotList

public void setFilterIDNotList(int[] ids)
Specifies a list of cd_id's that should not to be included in the result set.

Parameters:
ids - the cd_id values in an array
Since:
JChem 3.1.2

getDissimilarityMetrics

public static JChemSearch.DissimilarityMetrics getDissimilarityMetrics(ConnectionHandler ch,
                                                                       java.lang.String tableName)
                                                                throws java.sql.SQLException
Returns the available dissimilarity metrics for the given table.

Parameters:
ch - ConnaectionHandler with live connection
tableName - the name of the JChem structure table
Returns:
the information about the available metrics, or 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)

isStructureCaching

public boolean isStructureCaching()
Getter for property structureCaching.

Returns:
Value of property structureCaching.

isInfoToStdError

public boolean isInfoToStdError()
Getter for property infoToStdError.

Returns:
Value of property infoToStdError.

setInfoToStdError

public void setInfoToStdError(boolean infoToStdError)
Setter for property infoToStdError. If set to true, information useful for testing will be written in the servlet server's error log file. (Default: false)

Parameters:
infoToStdError - New value of property infoToStdError.

getConnectionHandler

public ConnectionHandler getConnectionHandler()
Getter for property connectionHandler.

Returns:
Value of property connectionHandler.

setConnectionHandler

public void setConnectionHandler(ConnectionHandler connectionHandler)
Sets the database connection.

Parameters:
connectionHandler - a ConnectionHandler object conaining a live connection to the database

getConnection

public java.sql.Connection getConnection()
Getter for property connection.

Returns:
Value of property connection.

getRunMode

public int getRunMode()
Retruns the current run mode.

Returns:
the current run mode.
Since:
JChem 5.0
See Also:
setRunMode(int)

setRunMode

public 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. Accepted values: The default run mode is RUN_MODE_SYNCH_COMPLETE

Parameters:
runMode -
Since:
JChem 5.0

setSearchOptions

public void setSearchOptions(JChemSearchOptions options)
Sets search parameters.

Parameters:
options - search options. Will be copied, modification of the original object does not affect future searches unless this method is called again.
Since:
JChem 5.0
See Also:
getSearchOptions()

getSearchOptions

public JChemSearchOptions getSearchOptions()
Returns the SearchOptions object associated with this Search object. The object returned is linked with this Search object, so modifications in the returned SearchOptions object will change directly the behaviour of this Search object.

Since:
JChem 5.0
See Also:
setSearchOptions(JChemSearchOptions)

getOrder

public int getOrder()
Getter for property order.

Returns:
Value of property order.

setOrder

public void setOrder(int order)
Setter for property order. Determines the order of the result.

Parameters:
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.


getResultTable

public java.lang.String getResultTable()
Getter for property resultTable.

Returns:
Value of property resultTable.

setResultTable

public void setResultTable(java.lang.String resultTable)
Setter for property resultTable. Sets the result table that will contain the cd_id of hits. In the case of searching similar structures, the similarity value is also stored in column similarity.

Parameters:
resultTable - New value of property resultTable.
See Also:
setResultTableMode, getResult

getResultTableMode

public int getResultTableMode()
Getter for property resultTableMode.

Returns:
Value of property resultTableMode.

setResultTableMode

public void setResultTableMode(int resultTableMode)
Setter for property resultTableMode. It instructs the searcher about the way of handling the result table. Modes: (Default: NO_RESULT_TABLE)

Parameters:
resultTableMode - New value of property resultTableMode.
See Also:
setResultTable

setMaxCacheSize

public void setMaxCacheSize(int maxCacheSizeMB)
Sets the desired cache memory allocation policy.
NOTE: the setting takes effect during the very first search in the running JVM, after that the call has no effect. If set to -1 (auto-detect) or 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.
NOTE: Under Java Runtime Environment 1.3.1 or older the available memory size cannot be determined. In this case JChem allocates cache for tables until it detects OutOfMemoryError during loading.

Parameters:
maxCacheSizeMB - the maximum amount of memory the cache allowed to utitlize in megabytes. Set -1 for auto-detection (default):
maxCacheSize = available_memory - minFreeMem
Since:
JChem 3.0
See Also:
setMinNonCachedMemory(int)

setMinNonCachedMemory

public void setMinNonCachedMemory(int minNonCachedMemoryMB)
Sets the desired cache memory allocation policy.
NOTE: the setting takes effect during the very first search in the running JVM, after that the call has no effect. If not set to 0 or 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.
NOTE: Under Java Runtime Environment 1.3.1 or older the available memory size cannot be determined. In this case JChem allocates cache for tables until it detects OutOfMemoryError during loading.

Parameters:
minNonCachedMemoryMB - the minimum amount of memory that should be left free for future non-cache allocations in megabytes.
Set to 0 if not specified.
Set to -1 for auto-detection (default):
  • 10 % of all available space for future allocations
  • Not smaller, than 20 MB
  • Nor bigger, than 100 MB
Since:
JChem 3.0
See Also:
setMaxCacheSize(int)

setCacheExpirationTime

public void setCacheExpirationTime(double hours)
Sets the expiration time for the structure cache. At the start of each search all tables are purged from cache that were searched before the specified time period. Naturally the currently searched table is never purged.

Parameters:
hours - the time in hours. The default value is 96. Set to 0 for no expiration.
Since:
JChem 3.0
See Also:
setMaxCacheSize(int), setMinNonCachedMemory(int)

setNumberOfProcessingThreads

public void setNumberOfProcessingThreads(int threads)
Sets the number of processing threads.

Parameters:
threads - the number of threads.
If set to 0, the number of threads will be equal to the number of logical processors available for the Java Vitual Machine (default).
NOTE: Under Java Runtime Environment 1.3.1 or older the number of processors cannot be determined. In this case the default number of threads is 16.
Since:
JChem 3.0

setThreadPriority

public void setThreadPriority(int priority)
Sets the priority of the processing threads. Only effective, if setRunMode(int) is set to either RUN_MODE_ASYNCH_COMPLETE or RUN_MODE_ASYNCH_PROGRESSIVE.

Parameters:
priority - the priority ranging 1 (Thread.MIN_PRIORITY) to 10 (Thread.MAX_PRIORITY).
The default and recommended setting is 1 (Thread.MIN_PRIORITY).
NOTE: if all other threads are not constantly calculating, a low priority setting will not slow down the search process, and it will help user interfaces to be responsive.
Since:
JChem 3.0

getResult

public int getResult(int index)
Indexed getter for property results. Returns a cd_id value of the found compound specified by index. If result table is generated, getResult throws NullPointerException.

Parameters:
index - Index of the property.
Returns:
Value of the property at index.
See Also:
setResultTable

getResults

public int[] getResults()
Returns an int array containing the cd_id values of found compounds. If a result table is generated in the database, it returns null.


cleanResults

public void cleanResults()
Cleans stored search results. Can be called to save memory while keeping the JChemSearch object. since JChem 3.0


getDissimilarity

public float getDissimilarity(int index)
Indexed getter for property dissimilarity. Returns the calculated dissimilarity value of the found compound specified by index and the query structure. If searching has not been finished yet or if a result table is generated, getDissimilarity throws NullPointerException.

Parameters:
index - Index of the property.
Returns:
Value of the property at index.
See Also:
setResultTable

getDissimilarity

public float[] getDissimilarity()
Getter for dissimilarity results. Returns the calculated dissimilarity values calculated for the last query strucutre. If searching has not been finished yet or if a result table is generated, getDissimilarity throws NullPointerException.

Returns:
the dissimilarity results.
See Also:
setResultTable

getProgressMessage

public java.lang.String getProgressMessage()
Getter for property progressMessage. It returns a message that shows the state of the search. It can be used for showing the progress of the search.

Returns:
Value of property progressMessage.

getCurrentId

public int getCurrentId()
Getter for property currentId. It returns the current cd_id of molecule being searched. It can be used for showing the progress of the search.

Returns:
Value of property currentId.

isMaxResultCountReached

public boolean isMaxResultCountReached()
Getter for property maxResultCountReached. It returns true if the search was stopped because the number of hits had reached the maximum value, false otherwise.

Returns:
Value of property maxResultCountReached.

isMaxTimeReached

public boolean isMaxTimeReached()
Getter for property maxTimeReached. It returns true if the search stopped because the time that passed since the start of the searched had reached the maximum value, false otherwise.

Returns:
Value of property maxTimeReached.

getResultCount

public int getResultCount()
Getter for property resultCount. It returns the number of hits found by the search.

Returns:
Value of property resultCount.

setTimeout

public void setTimeout(int seconds)
Sets the timeout value in seconds. If the search is run in a thread, 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.

Parameters:
seconds - the timeout in seconds. Set to 0 to disable (default).
Since:
JChem 3.0
See Also:
setRunMode(int)

getTimeout

public int getTimeout()
Gets the current timout setting.

Returns:
the current timeout setting.
Since:
JChem 3.0
See Also:
setTimeout(int)

isRunning

public boolean isRunning()
Getter for property running.

Returns:
Value of property running.

setRunning

public void setRunning(boolean run)
                throws java.sql.SQLException,
                       MolFormatException,
                       java.io.IOException,
                       DatabaseSearchException,
                       PropertyNotSetException
Setter for property running. If it is set to 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)

Parameters:
run - New value of property run.
Throws:
java.sql.SQLException
MolFormatException
java.io.IOException
DatabaseSearchException
PropertyNotSetException

run

public void run()
         throws java.sql.SQLException,
                MolFormatException,
                java.io.IOException,
                DatabaseSearchException,
                PropertyNotSetException
Starts searching. Same as setRunning(true)

Throws:
java.sql.SQLException
MolFormatException
java.io.IOException
DatabaseSearchException
PropertyNotSetException

clearCache

public static void clearCache()
Clears the cache that stores fingerprints and structures.


getScreenedCount

public int getScreenedCount()
Gets the number of screeened structures.

Returns:
the number of screened structures

getScreeningTime

public long getScreeningTime()
Gets the screening time.

Returns:
the screening time in milliseconds

getSearchTime

public long getSearchTime()
Gets the total search time.

Returns:
the search time in milliseconds (includes screening time)

getHitsAsRgDecomp

public RgDecompResults getHitsAsRgDecomp(int[] hits,
                                         int attachmentType)
                                  throws chemaxon.sss.search.SearchException,
                                         MolFormatException,
                                         java.sql.SQLException
Returns hits as result of r-group decomposition according to the original query. Various results are returned in one RgDecompResults object: More details about r-group decomposition can be found here. For more sophisticated usages (e.g. all hits of query in a specific target) see our RGroupDecomposition API documentation.

Parameters:
hits - cd_ids of target structures
attachmentType - Type of visualization of attachment of ligands.
Returns:
An RGDecompResults object.
Throws:
chemaxon.sss.search.SearchException
MolFormatException
java.sql.SQLException
Since:
JChem 5.3
See Also:
RgDecompResults, Decomposition.ATTACHMENT_NONE, Decomposition.ATTACHMENT_POINT, Decomposition.ATTACHMENT_MAP, Decomposition.ATTACHMENT_LABEL, Decomposition.ATTACHMENT_ATOM, Decomposition.ATTACHMENT_RLABEL

getHitsAsMolecules

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
Returns hits ready for display. If hit alignment or coloring is needed, the graph search must be repeated for the selected structures to obtain the atom indexes fo hits. (Storing this data would consume too much memory for large hit sets) If alignment mode has been set to rotate, and query has 0 dimension, it will be cleaned in 2d. If alignment mode has been set to partial clean, this option will be changed to rotate in this case.

Parameters:
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.
Returns:
the hits as Molecules, colored and aligned if needed. If coloring is specified in case of SearchConstants.SUPERSTRUCTURE search mode, always the query structure is returned, the target subgraph is colored.
Throws:
java.sql.SQLException
java.io.IOException
chemaxon.sss.search.SearchException
chemaxon.enumeration.supergraph.SupergraphException
PropertyNotSetException
DatabaseSearchException
Since:
JChem 5.0

setRegCode

public void setRegCode(long code)
Sets the registration code. FOR INTERNAL USE.
Should be called before the very first search.

Parameters:
code - the code. If not 0, overrides the value found in the property table.
Since:
JChem 3.1

isLicensed

public boolean isLicensed()
Specified by:
isLicensed in interface chemaxon.license.Licensable

setLicenseEnvironment

public void setLicenseEnvironment(java.lang.String env)
Specified by:
setLicenseEnvironment in interface chemaxon.license.Licensable

hasMoreHits

public boolean hasMoreHits()
                    throws java.lang.InterruptedException
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE.
Returns true if there are more hits to retrieve with getNextHit() or getAvailableNewHits(int), false otherwise.

Returns:
true if there are more hits to retrieve with getNextHit() or getAvailableNewHits(int), false otherwise.
Throws:
java.lang.InterruptedException
Since:
JChem 5.0

getNextHit

public int getNextHit()
               throws java.lang.InterruptedException
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE.
Returns the next available hit. Waits until at least one is available or throws NoSuchElementException, there are no more hits to return.

Returns:
the next available hit. Waits until at least one is available or throws NoSuchElementException, there are no more hits to return.
Throws:
java.lang.InterruptedException - if the calling thread was interrupted while waiting for the next available hit.
Since:
JChem 5.0

getAvailableNewHits

public int[] getAvailableNewHits(int arraySize)
                          throws java.lang.InterruptedException,
                                 DatabaseSearchException
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE.
Returns all new hits available at the time of return, but at least arraySize new hits.

Parameters:
arraySize -
Returns:
all new hits available at the time of return, but at least arraySize new hits.
Throws:
java.lang.InterruptedException - if the calling thread was interrupted while waiting.
DatabaseSearchException
Since:
JChem 5.0

waitUntilSearchComplete

public void waitUntilSearchComplete()
                             throws java.lang.InterruptedException
Used with run mode = RUN_MODE_ASYNCH_PROGRESSIVE.
Waits until after the search has completed.

Throws:
java.lang.InterruptedException - if the calling thread was interrupted while waiting.
Since:
JChem 5.0