chemaxon.sss.search
Class Search

java.lang.Object
  extended bychemaxon.sss.search.Search
All Implemented Interfaces:
SearchConstants, StereoConstants
Direct Known Subclasses:
MolSearch

public abstract class Search
extends java.lang.Object
implements StereoConstants, SearchConstants

Parent of all structural search classes

Author:
Szilard Dorant, Szabolcs Csepregi

Field Summary
protected  int preMatchLength
          The number of used items in preMatchTargetAtoms and preMatchQueryAtoms arrays.
protected  int[] preMatchQueryAtoms
          Array to store query atoms of pairs set by addMatch().
protected  int[] preMatchTargetAtoms
          Array to store target atoms of pairs set by addMatch().
protected  MolSearchOptions searchOptions
          Object to store all search parameters.
 
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
 
Fields inherited from interface chemaxon.sss.SearchConstants
ABS_STEREO_ALWAYS_ON, ABS_STEREO_CHIRAL_FLAG, ABS_STEREO_TABLE_OPTION, CHARGE_MATCHING_DEFAULT, CHARGE_MATCHING_EXACT, CHARGE_MATCHING_IGNORE, DEFAULT_DISSIMILARITY_THRESHOLD, DEFAULT_SIMILARITY_THRESHOLD, DISSIMILARITY, EXACT, EXACT_FRAGMENT, EXACT_FRAGMENT_OFF, EXACT_FRAGMENT_ON, HCOUNT_MATCHING_AUTO, HCOUNT_MATCHING_EQUAL, HCOUNT_MATCHING_GREATER_OR_EQUAL, 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_ORIGINAL, MARKUSH_HIT_SUPERGRAPH, 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, REGULAR_SEARCH, 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_UNDEF_R, VAGUE_BOND_DEFAULT, VAGUE_BOND_LEVEL1, VAGUE_BOND_LEVEL2, VAGUE_BOND_LEVEL3, VAGUE_BOND_LEVEL4, VAGUE_BOND_OFF, VALENCE_MATCHING_IGNORE, VALENCE_MATCHING_ON
 
Constructor Summary
Search()
           
 
Method Summary
 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 boolean areMatchingBondTypes(int q, int t)
          Tests if a query bond matches the target.
protected static boolean areMatchingBondTypes(int q, int t, boolean exactMatch)
          Tests if a query bond matches the target.
 void clearMatch()
          Clears the extra prerequisites of the structure search specified using addMatch calls.
abstract  int[][] findAll()
          Looks for all matching patterns in the molecule.
abstract  int[] findFirst()
          Looks for the first matching pattern in the target molecule.
abstract  int[] findNext()
          Looks for the next matching pattern in the target molecule.
protected static int getAtomStereo(MolAtom atom, int parity)
          Determine the stereo type of an atom
 int getDoubleBondStereoMatchingMode()
           
 int getHCountMatching()
           
 int getMatchCount()
          The number of times the query molecule appears in the target molecule.
 Molecule getMatchingQuery()
          Returns the query which produced the hit vector of the last findNext(), findFirst() or findAll() result.
 int getOption(int option)
          Deprecated. Since 5.0 Please use getters instead.
abstract  Molecule getQuery()
          Retrieves the query structure stored in the MolSearch object.
protected  java.lang.String getQueryAsString()
          For internal purposes only.
protected  Molecule getQueryToPrint()
          For internal purposes only.
 MolSearchOptions getSearchOptions()
          Returns the SearchOptions object associated with this Search object.
 int getSearchType()
          Returns the currently set global search operation mode.
abstract  Molecule getTarget()
          Retrieves the target molecule
protected  java.lang.String getTargetAsString()
          For internal purposes only.
protected  Molecule getTargetToPrint()
          For internal purposes only.
 boolean isExactAtomMatching()
          Deprecated. since 2.2
 boolean isExactBondMatching()
          Indicates whether bond types should match exacly - looking for query bonds target.
 boolean isExactChargeMatching()
          Deprecated. since JChem 3.2 Please use SearchOptions.getChargeMatching() (SearchOptions.getChargeMatching()) instead.
 boolean isExactIsotopeMatching()
          Deprecated. since JChem 3.2 Please use SearchOptions.getIsotopeMatching() (SearchOptions.getIsotopeMatching()) instead.
 boolean isExactQueryAtomMatching()
          Returns whether exact matching of query atom information is set.
 boolean isExactRadicalMatching()
          Deprecated. since JChem 3.2 Please use SearchOptions.getRadicalMatching() (SearchOptions.getRadicalMatching()) instead.
 boolean isExactStereoMatching()
          Returns the exact stereo matching option.
 boolean isMatchCountBetween(int hitLimitLow, boolean isLowerLimitIncluded, int hitLimitHigh, boolean isHigherLimitIncluded)
          Decides questions like "does the query match the target between 2 and 5 times (inclusively)" Makes this efficiently, which means it only searches for the number of hits necessary to decide the question.
 boolean isMatchCountInRelation(java.lang.String relation, int hitLimit)
          Decides questions like "does the query match the target at least 3 times", "[] up to 5 times", "[] exactly once".
abstract  boolean isMatching()
          Checks if the query structure matches a substructure in the molecule.
protected  boolean isOrderSensitiveSearch()
          Indicates whether the search is order sensitive
protected  boolean isPerfectSearchType()
           
 boolean isQueryAbsoluteStereo()
          Deprecated. since JChem 5.0.1 Please use MolSearchOptions.isQueryAbsoluteStereo() instead.
 boolean isSubgraphSearch()
          Returns the subgraph searh option.
 boolean isTargetAbsoluteStereo()
          Deprecated. since JChem 5.0.1 Please use MolSearchOptions.isTargetAbsoluteStereo() instead.
 boolean isTautomerSearch()
          Indicates if tautomers of the query should be enumerated for search.
 boolean isVerbose()
          For debugging purposes only.
 void setDoubleBondStereoMatchingMode(int mode)
          Sets how double bond cis/trans stereo information should match during the search.
 void setExactAtomMatching(boolean value)
          Deprecated. since 2.2.
 void setExactBondMatching(boolean value)
          Specifies whether bond types should match exacly - looking for query bonds target.
 void setExactChargeMatching(boolean isExact)
          Deprecated. since JChem 3.2 Please use SearchOptions.setChargeMatching(...) (SearchOptions.setChargeMatching(int)) instead.
 void setExactIsotopeMatching(boolean isExact)
          Deprecated. since JChem 3.2 Please use SearchOptions.setIsotopeMatching(...) (SearchOptions.setIsotopeMatching(int)) instead.
 void setExactQueryAtomMatching(boolean isExact)
          Sets whether exact query atom matching should be used or not.
 void setExactRadicalMatching(boolean isExact)
          Deprecated. since JChem 3.2 Please use SearchOptions.setRadicalMatching(...) (SearchOptions.setRadicalMatching(int)) instead.
 void setExactStereoMatching(boolean value)
          If true, equality is needed in stereochemistry.
 void setHCountMatching(int HCountMatching)
          Sets the H count matching mode.
 void setOption(int option, int value)
          Deprecated. Since 5.0 Please use setters instead.
 void setOptions(int[] newOptions)
          Rapidly sets all needed search options.
 void setOrderSensitiveSearch(boolean orderSensitiveSearch)
          Specifies whether the same set of target atoms found in a different order should be considered as a different hit.
abstract  void setQuery(Molecule mol)
          Specifies the query structure.
abstract  void setQuery(Molecule mol, int[] exclude)
          Specifies the query structure to be tested.
 void setQueryAbsoluteStereo(boolean queryAbsoluteStereo)
          Deprecated. since JChem 5.0.1 Please use MolSearchOptions.setQueryAbsoluteStereo(boolean) instead.
 void setSearchOptions(SearchOptions options)
          Copies all search parameters from options to the current search object.
 void setSearchType(int searchType)
          Sets different search options according to a predefined search type.
 void setStereoCareChecking(boolean isStereoCareChecking)
          Deprecated. since 2.2. Please use setDoubleBondStereoMatchingMode(int) instead.
 void setStereoSearch(boolean isStereoSearch)
          If true, then stereo information is considered during searching, otherwise all stereo information is ignored.
 void setSubgraphSearch(boolean value)
          Specifies the matching mode for topology search
abstract  void setTarget(Molecule mol)
          Specifies the target molecule to be tested.
abstract  void setTarget(Molecule mol, int[] exclude)
          Specifies the target molecule to be tested.
 void setTargetAbsoluteStereo(boolean targetAbsoluteStereo)
          Deprecated. since JChem 5.0.1 Please use MolSearchOptions.setTargetAbsoluteStereo(boolean) instead.
 void setTautomerSearch(boolean value)
          Sets if tautomers of the query should be enumerated for search.
 void setVerbose(boolean verbose)
          For debugging purposes only.
abstract  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

searchOptions

protected final MolSearchOptions searchOptions
Object to store all search parameters.


preMatchQueryAtoms

protected int[] preMatchQueryAtoms
Array to store query atoms of pairs set by addMatch().


preMatchTargetAtoms

protected int[] preMatchTargetAtoms
Array to store target atoms of pairs set by addMatch().


preMatchLength

protected int preMatchLength
The number of used items in preMatchTargetAtoms and preMatchQueryAtoms arrays.

Constructor Detail

Search

public Search()
Method Detail

isQueryAbsoluteStereo

public boolean isQueryAbsoluteStereo()
Deprecated. since JChem 5.0.1 Please use MolSearchOptions.isQueryAbsoluteStereo() instead.

Returns whether the chiral flag is ignored or not for the query molecule.

Returns:
true, if chiral centers in the query molecule are regarded as absolute stereo, ignoring the chiral flag. If the molecule contains any enhanced stereo labels, this flag has no effect.

setQueryAbsoluteStereo

public void setQueryAbsoluteStereo(boolean queryAbsoluteStereo)
Deprecated. since JChem 5.0.1 Please use MolSearchOptions.setQueryAbsoluteStereo(boolean) instead.

Sets whether the chiral flag should be ignored or not for the query molecule.

Parameters:
queryAbsoluteStereo - if true, chiral centers in the query molecule are regarded as absolute stereo, ignoring the chiral flag. If the molecule contains any enhanced stereo labels, this flag has no effect.

isTargetAbsoluteStereo

public boolean isTargetAbsoluteStereo()
Deprecated. since JChem 5.0.1 Please use MolSearchOptions.isTargetAbsoluteStereo() instead.

Returns whether the chiral flag is ignored or not for the target molecule.

Returns:
true, if chiral centers in the target molecule are regarded as absolute stereo, ignoring the chiral flag. If the molecule contains any enhanced stereo labels, this flag has no effect.

setTargetAbsoluteStereo

public void setTargetAbsoluteStereo(boolean targetAbsoluteStereo)
Deprecated. since JChem 5.0.1 Please use MolSearchOptions.setTargetAbsoluteStereo(boolean) instead.

Sets whether the chiral flag should be ignored or not for the target molecule.

Parameters:
targetAbsoluteStereo - if true, chiral centers in the target molecule are regarded as absolute stereo, ignoring the chiral flag. If the molecule contains any enhanced stereo labels, this flag has no effect.

isExactRadicalMatching

public boolean isExactRadicalMatching()
Deprecated. since JChem 3.2 Please use SearchOptions.getRadicalMatching() (SearchOptions.getRadicalMatching()) instead.

Returns whether exact matching of radical information is set. If false(default), a query atom without radical information will match to a target atom with a free radical. Otherwise, they won't match.

Since:
JChem 2.2

setExactRadicalMatching

public void setExactRadicalMatching(boolean isExact)
Deprecated. since JChem 3.2 Please use SearchOptions.setRadicalMatching(...) (SearchOptions.setRadicalMatching(int)) instead.

Sets whether exact radical matching should be used or not. See Search.isExactRadicalMatching.

Since:
JChem 2.2

isExactIsotopeMatching

public boolean isExactIsotopeMatching()
Deprecated. since JChem 3.2 Please use SearchOptions.getIsotopeMatching() (SearchOptions.getIsotopeMatching()) instead.

Returns whether exact matching of isotope information is set. If false(default), a query atom without isotope information will match to an isotopic target atom. Otherwise, they won't match.

Since:
JChem 2.2

setExactIsotopeMatching

public void setExactIsotopeMatching(boolean isExact)
Deprecated. since JChem 3.2 Please use SearchOptions.setIsotopeMatching(...) (SearchOptions.setIsotopeMatching(int)) instead.

Sets whether exact isotope matching should be used or not. See Search.isExactIsotopeMatching.

Since:
JChem 2.2

isExactChargeMatching

public boolean isExactChargeMatching()
Deprecated. since JChem 3.2 Please use SearchOptions.getChargeMatching() (SearchOptions.getChargeMatching()) instead.

Returns whether exact matching of charge information is set. If false(default), a query atom without charge information will match to a charged target atom. Otherwise, they won't match.

Since:
JChem 2.2

setExactChargeMatching

public void setExactChargeMatching(boolean isExact)
Deprecated. since JChem 3.2 Please use SearchOptions.setChargeMatching(...) (SearchOptions.setChargeMatching(int)) instead.

Sets whether exact charge matching should be used or not. See Search.isExactChargeMatching.

Since:
JChem 2.2

isExactQueryAtomMatching

public boolean isExactQueryAtomMatching()
Returns whether exact matching of query atom information is set. If true, query information (e.g. atom list, any atom, number of hydrogens, aromaticity, etc.) in atoms will not be evaluated, but rather exact matching of these information is required. It is useful for searching in query databases. Default is false.

Since:
JChem 2.2

setExactQueryAtomMatching

public void setExactQueryAtomMatching(boolean isExact)
Sets whether exact query atom matching should be used or not. See Search.isExactQueryAtomMatching.

Since:
JChem 2.2

setTarget

public abstract void setTarget(Molecule mol)
Specifies the target molecule to be tested.

Parameters:
mol - the target molecule.

setTarget

public abstract void setTarget(Molecule mol,
                               int[] exclude)
Specifies the target molecule to be tested.

Parameters:
mol - the target molecule.
exclude - index of atoms to exclude

getTarget

public abstract Molecule getTarget()
Retrieves the target molecule

Returns:
the Molecule to search on

setQuery

public abstract void setQuery(Molecule mol)
Specifies the query structure.

Parameters:
mol - the query structure.

setQuery

public abstract void setQuery(Molecule mol,
                              int[] exclude)
Specifies the query structure to be tested.

Parameters:
mol - the query molecule.
exclude - index of atoms to exclude

getQuery

public abstract Molecule getQuery()
Retrieves the query structure stored in the MolSearch object.

Returns:
Molecule to search for

setStereoSearch

public void setStereoSearch(boolean isStereoSearch)
If true, then stereo information is considered during searching, otherwise all stereo information is ignored. (Default: true)


setStereoCareChecking

public void setStereoCareChecking(boolean isStereoCareChecking)
Deprecated. since 2.2. Please use setDoubleBondStereoMatchingMode(int) instead.

If true, cis/trans information is only considered for "Stereo Search" marked double bonds.
If the query is created from Smiles, set this option to false if you would like to perform double bond stereo searches. This method has to be called before specifying the molecule and the query structure. (Default: true)


setDoubleBondStereoMatchingMode

public void setDoubleBondStereoMatchingMode(int mode)
Sets how double bond cis/trans stereo information should match during the search.

Parameters:
mode - The following options can be used: Replaces setStereoCareChecking(boolean)
Since:
JChem 2.2

getDoubleBondStereoMatchingMode

public int getDoubleBondStereoMatchingMode()
Returns:
the matching mode relating to double bond stereo.
Since:
JChem 2.2
See Also:
setDoubleBondStereoMatchingMode(int)

setOrderSensitiveSearch

public void setOrderSensitiveSearch(boolean orderSensitiveSearch)
Specifies whether the same set of target atoms found in a different order should be considered as a different hit.
For example the 3-atom query molecule fits 2 positions on the target:
Hit 1: [1;3;5]
Hit 2: [5;3;1]
If orderSensitiveSearch is true, both cases are returned, otherwise only one of them (the one found first).

Parameters:
orderSensitiveSearch - set this to true to get results in every possible order

isOrderSensitiveSearch

protected boolean isOrderSensitiveSearch()
Indicates whether the search is order sensitive

Returns:
if hits are returned in every possible order
See Also:
setOrderSensitiveSearch(boolean)

isSubgraphSearch

public boolean isSubgraphSearch()
Returns the subgraph searh option.

Returns:
false if substructure matching, true if whole structure matching

setSubgraphSearch

public void setSubgraphSearch(boolean value)
Specifies the matching mode for topology search

Parameters:
value - false for substructure matching, true for whole structure matching

isExactAtomMatching

public boolean isExactAtomMatching()
Deprecated. since 2.2

Returns the topology matching option.

Returns:
false if matching elements and evaluating atom queries, true if matching all atom types even query atoms.
See Also:
isExactChargeMatching(), isExactIsotopeMatching(), isExactQueryAtomMatching(), isExactRadicalMatching()

setExactAtomMatching

public void setExactAtomMatching(boolean value)
Deprecated. since 2.2.

Specifies the matching mode for topology search Also sets setExactRadicalMatching, setExactIsotopeMatching, setExactChargeMatching and setExactQueryAtomMatching to value.

Parameters:
value - false for matching elements and evaluating atom queries, true for matching all atom types even query atoms

isExactStereoMatching

public boolean isExactStereoMatching()
Returns the exact stereo matching option. If true, equality is needed in stereochemistry. ("All stereo info is exactly the same.") It mainly has an effect when the query has no stereo information: it only matches non-stereo target. Similarly, a query with a wiggly tetrahedral center will only match wiggly tetrahedral center, and not specific R and S configurations. If false, non-stereo query matches both nonstereo and stereo target.

By default, this setting is false for all search types except for PERFECT search, where it is true. This setting has no effect if stereoSearch == false.

Returns:
the exact-stereo setting
See Also:
setStereoSearch(boolean)

setExactStereoMatching

public void setExactStereoMatching(boolean value)
If true, equality is needed in stereochemistry. ("All stereo info is exactly the same.") It mainly has an effect when the query has no stereo information: it only matches non-stereo target. Similarly, a query with a wiggly tetrahedral center will only match wiggly tetrahedral center, and not specific R and S configurations. If false, non-stereo query matches both nonstereo and stereo target.

By default, this setting is false for all search types except for PERFECT search, where it is true. This setting has no effect if stereoSearch == false.

Parameters:
value - the exact-stereo setting
See Also:
setStereoSearch(boolean)

isExactBondMatching

public boolean isExactBondMatching()
Indicates whether bond types should match exacly - looking for query bonds target.

Returns:
true if bond types must match exactly. Default value is false

setExactBondMatching

public void setExactBondMatching(boolean value)
Specifies whether bond types should match exacly - looking for query bonds target.

Parameters:
value - if set to true, bond types must match exactly. For example "single or double" matches only "single or double", but matches neither "single" or "double". Default value is false

setSearchType

public void setSearchType(int searchType)
Sets different search options according to a predefined search type. For full explanation see JChem Query Guide. Acceptable values: SearchConstants.NO_SCREEN, SearchConstants.NO_ABAS, SearchConstants.SUBSTRUCTURE (default), SearchConstants.SUPERSTRUCTURE (no query features allowed), SearchConstants.SIMILARITY, and SearchConstants.EXACT. SearchConstants.PERFECT. SearchConstants.EXACT_FRAGMENT.

WARNING: This method may affect other search settings, therefore if other search options are adjusted, this method should be called first! For affected search options, see links below.

Parameters:
searchType - the predefined search type
See Also:
setExactAtomMatching(boolean), setExactBondMatching(boolean), setExactChargeMatching(boolean), setExactIsotopeMatching(boolean), setExactQueryAtomMatching(boolean), setExactRadicalMatching(boolean), setExactStereoMatching(boolean), setStereoSearch(boolean), setSubgraphSearch(boolean), setOption(int, int), SearchConstants.OPTION_CHARGE_MATCHING, SearchConstants.OPTION_ISOTOPE_MATCHING, SearchConstants.OPTION_RADICAL_MATCHING, SearchConstants.OPTION_VALENCE_MATCHING

getSearchType

public int getSearchType()
Returns the currently set global search operation mode.

Returns:
The last set value.
Since:
JChem 3.2
See Also:
setSearchType(int)

isPerfectSearchType

protected boolean isPerfectSearchType()
Returns:
whether this search is a PERFECT search or not.

isMatching

public abstract boolean isMatching()
                            throws chemaxon.sss.search.SearchException
Checks if the query structure matches a substructure in the molecule.

Returns:
true if the query was found.
Throws:
chemaxon.sss.search.SearchException

findFirst

public abstract int[] findFirst()
                         throws chemaxon.sss.search.SearchException
Looks for the first matching pattern in the target molecule. If the search object was previously used, this method re-initializes the search process, and starts returning the hits from the beginning.

Returns:
an array containing the atom indexes of the target atoms that match the query atoms (in the order of the appropriate query atoms) or null if there are no hits.

Special atom indices:

  • In case of explicit query H atoms matching to implied H atoms in the target, a negative number is returned. The absolute value of this number equals with the atom index of the heavy atom bearing the implicit hydrogen, or Integer.MIN_VALUE in case of 0 heavy atom index.
  • The same method is used for explicit LP (lone pair) atoms in the query. The hit contains the negated number of the target heavy atom with the matching lone pair, or Integer.MIN_VALUE for 0 index.
  • Multicenter atoms (e.g. of multicenter coordinate bonds) are not returned, the match array always contains Integer.MIN_VALUE+2 for these atoms.
  • For R-group queries, only the scaffold atoms are included in the match array, except when hitIncludesRNodes parameter is set. See MolSearchOptions.setHitIncludesRNodes(boolean)
  • Excluded atoms (see setTarget(chemaxon.struc.Molecule,int[])) will not appear in the match array at all (their appropriate indices are left out).
  • When the query contains link nodes, the returned array may contain more indices than the query atoms. In this case the extra atom indices appear at the end and method getMatchingQuery() can be used to get the most specific matching form of the query.
  • All Superatom S-groups are treated as expanded during the search, so atom indices are returned accordingly.
Throws:
chemaxon.sss.search.SearchException
See Also:
findNext(), findAll(), isMatching(), getMatchingQuery()

findNext

public abstract int[] findNext()
                        throws chemaxon.sss.search.SearchException
Looks for the next matching pattern in the target molecule. If the search object was not used previously, it also initializes the search. (So findFirst() call is not necessary prior to a findNext() call.)

Returns:
an array containing the atom indexes of the target atoms that match the query atoms (in the order of the appropriate query atoms) or null if there are no more hits.

Special atom indices:

  • In case of explicit query H atoms matching to implied H atoms in the target, a negative number is returned. The absolute value of this number equals with the atom index of the heavy atom bearing the implicit hydrogen, or Integer.MIN_VALUE in case of 0 heavy atom index.
  • The same method is used for explicit LP (lone pair) atoms in the query. The hit contains the negated number of the target heavy atom with the matching lone pair, or Integer.MIN_VALUE for 0 index.
  • Multicenter atoms (e.g. of multicenter coordinate bonds) are not returned, the match array always contains Integer.MIN_VALUE+2 for these atoms.
  • For R-group queries, only the scaffold atoms are included in the match array, except when hitIncludesRNodes parameter is set. See MolSearchOptions.setHitIncludesRNodes(boolean)
  • Excluded atoms (see setTarget(chemaxon.struc.Molecule,int[])) will not appear in the match array at all (their appropriate indices are left out).
  • When the query contains link nodes, the returned array may contain more indices than the query atoms. In this case the extra atom indices appear at the end and method getMatchingQuery() can be used to get the most specific matching form of the query.
  • All Superatom S-groups are treated as expanded during the search, so atom indices are returned accordingly.
Throws:
chemaxon.sss.search.SearchException
See Also:
findFirst(), findAll(), isMatching(), getMatchingQuery()

findAll

public abstract int[][] findAll()
                         throws chemaxon.sss.search.SearchException
Looks for all matching patterns in the molecule.

Returns:
an array containing the matches as arrays or null 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:

  • In case of explicit query H atoms matching to implied H atoms in the target, a negative number is returned. The absolute value of this number equals with the atom index of the heavy atom bearing the implicit hydrogen, or Integer.MIN_VALUE in case of 0 heavy atom index.
  • The same method is used for explicit LP (lone pair) atoms in the query. The hit contains the negated number of the target heavy atom with the matching lone pair, or Integer.MIN_VALUE for 0 index.
  • Multicenter atoms (e.g. of multicenter coordinate bonds) are not returned, the match array always contains Integer.MIN_VALUE+2 for these atoms.
  • For R-group queries, only the scaffold atoms are included in the match array, except when hitIncludesRNodes parameter is set. See MolSearchOptions.setHitIncludesRNodes(boolean)
  • Excluded atoms (see setTarget(chemaxon.struc.Molecule,int[])) will not appear in the match array at all (their appropriate indices are left out).
  • When the query contains link nodes, the returned array may contain more indices than the query atoms. The extra atom indices are contained at the end.
  • All Superatom S-groups are treated as expanded during the search, so atom indices are returned accordingly.
Throws:
chemaxon.sss.search.SearchException
See Also:
isMatching(), findFirst(), findNext()

areMatchingBondTypes

public static boolean areMatchingBondTypes(int q,
                                           int t)
Tests if a query bond matches the target.

Parameters:
t - type of target bond
q - type of query bond
Returns:
true, if target fits query

areMatchingBondTypes

protected static boolean areMatchingBondTypes(int q,
                                              int t,
                                              boolean exactMatch)
Tests if a query bond matches the target.

Parameters:
t - type of target bond
q - type of query bond
exactMatch - if true, query bonds are matching the same query bond only
Returns:
true, if target fits query

getAtomStereo

protected static int getAtomStereo(MolAtom atom,
                                   int parity)
Determine the stereo type of an atom

Parameters:
atom - atom to determine its stereo type
parity - parityof the atom
Returns:
one of the following constants:
  • ATOMSTEREO_NONE : no stereo specific information
  • ATOMSTEREO_EITHER : "either" stereo information, parity independent
  • ATOMSTEREO_SPECIFIC: specific stereo information, parity dependent

addMatch

public void addMatch(int queryAtom,
                     int targetAtom)
Specifies an extra prerequisite of the structure search that queryAtom must match to targetAtom only. If this is impossible, the search methods will report no matching. The use of this method makes the search more effective than checking the hits afterwards.

Several addMatch() calls represent conditions connected by boolean operator AND.

The effect of all addMatch() calls can be canceled by clearMatch().


addMatch

public 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. If this is impossible, the search methods will report no matching. The use of this method makes the search more effective than checking the hits afterwards.

Several addMatch() calls represent conditions connected by boolean operator AND.

The effect of all addMatch() calls can be canceled by clearMatch().

Since:
JChem 2.2

clearMatch

public void clearMatch()
Clears the extra prerequisites of the structure search specified using addMatch calls.

Since:
JChem 2.2

getHCountMatching

public int getHCountMatching()
Returns:
the H count matching mode. (Default is HCOUNT_MATCHING_AUTO.)
See Also:
setHCountMatching(int), SearchConstants.HCOUNT_MATCHING_AUTO, SearchConstants.HCOUNT_MATCHING_EQUAL, SearchConstants.HCOUNT_MATCHING_GREATER_OR_EQUAL

setHCountMatching

public void setHCountMatching(int HCountMatching)
Sets the H count matching mode. Default is HCOUNT_MATCHING_AUTO.

Parameters:
HCountMatching - possible values:
See Also:
SearchConstants.HCOUNT_MATCHING_AUTO, SearchConstants.HCOUNT_MATCHING_EQUAL, SearchConstants.HCOUNT_MATCHING_GREATER_OR_EQUAL

isMatchCountInRelation

public boolean isMatchCountInRelation(java.lang.String relation,
                                      int hitLimit)
                               throws chemaxon.sss.search.SearchException
Decides questions like "does the query match the target at least 3 times", "[] up to 5 times", "[] exactly once". Makes this efficiently, which means it only searches for the number of hits necessary to decide the question.

Example:

isMatchCountInRelation("<", 2) - true if the query can be found in the target less than two times.

Parameters:
relation - The relational operation of the question. This operation will be used to compare the number of hits to hitLimit. Available values:
"=" - tests equality to hitLimit.
"<" - returns true if the number of found hits is less than hitLimit.
"<=" - less than or equality
">" - greater than
">=" - greater than or equality
hitLimit - The limit for the number of hits.
Returns:
"actual number of hits (of query in target)" <relation> hitLimit
Throws:
chemaxon.sss.search.SearchException - if encountered during the search.
See Also:
getMatchCount()

isMatchCountBetween

public boolean isMatchCountBetween(int hitLimitLow,
                                   boolean isLowerLimitIncluded,
                                   int hitLimitHigh,
                                   boolean isHigherLimitIncluded)
                            throws chemaxon.sss.search.SearchException
Decides questions like "does the query match the target between 2 and 5 times (inclusively)" Makes this efficiently, which means it only searches for the number of hits necessary to decide the question.

Example:

isMatchCountBetween(2, true, 4, true) - true if the query can be found in the target exactly 2, 3 or 4 times.

isMatchCountBetween(2, false, 4, false) - true if the query can be found in the target exactly 3 times.

Parameters:
hitLimitLow - The lower limit for the number of hits.
isLowerLimitIncluded - If true, equality is allowed with hitLimitLow.
hitLimitHigh - The upper limit for the number of hits. If you pass Integer.MAX_VALUE, it will be treated as infinity. (I.e. only the lower limit is applied.)
isHigherLimitIncluded - If true, equality is allowed with hitLimitHigh.
Returns:
Whether the "actual number of hits (of query in target)" is between hitLimitLow and hitLimitHigh, inclusively.
Throws:
chemaxon.sss.search.SearchException - if encountered during the search.
See Also:
getMatchCount()

getMatchCount

public int getMatchCount()
                  throws chemaxon.sss.search.SearchException
The number of times the query molecule appears in the target molecule.

If you would like to decide a simple relation regarding this number, you should consider method isMatchCountInRelation( String, int), because it is more efficient than this method.

Returns:
the above occurrence number.
Throws:
chemaxon.sss.search.SearchException - If encountered during the search.
See Also:
isMatchCountInRelation(java.lang.String, int)

isVerbose

public boolean isVerbose()
For debugging purposes only.


setVerbose

public void setVerbose(boolean verbose)
For debugging purposes only.


stop

public abstract void stop()
Tries to stop the running search as fast as possible. (E.g. used in another thread.)


setOption

public void setOption(int option,
                      int value)
Deprecated. Since 5.0 Please use setters instead.

Sets search options.

Parameters:
option - Option identifier to be set.
value - Value of option to be set.
See Also:
SearchConstants.OPTION_KEEP_QUERY_ORDER, SearchConstants.OPTION_EXACT_FRAGMENT, SearchConstants.OPTION_MARKUSH_HIT, SearchConstants.OPTION_TAUTOMER_SEARCH, SearchConstants.OPTION_ISOTOPE_MATCHING, SearchConstants.OPTION_CHARGE_MATCHING, SearchConstants.OPTION_VALENCE_MATCHING, SearchConstants.OPTION_RADICAL_MATCHING, SearchConstants.OPTION_MARKUSH_ENABLED, SearchConstants.OPTION_VAGUE_BOND, SearchConstants.OPTION_MARKUSH_AROM, SearchConstants.OPTION_MIX_SGROUP_MATCHING, SearchConstants.OPTION_STEREO_MODEL, SearchOptions.setKeepQueryOrder(boolean), SearchOptions.setExactFragment(boolean), SearchOptions.setTautomerSearch(boolean), SearchOptions.setIsotopeMatching(int), SearchOptions.setChargeMatching(int), SearchOptions.setValenceMatching(boolean), SearchOptions.setRadicalMatching(int), SearchOptions.setVagueBondLevel(int), SearchOptions.setMixSgroupMatching(boolean), SearchOptions.setStereoModel(int), SearchOptions.setImplicitHMatching(int), SearchOptions.setReactionUnpairedMapMatching(boolean), MolSearchOptions.setMarkushHitSupergraph(boolean), MolSearchOptions.setMarkushEnabled(boolean), MolSearchOptions.setMarkushArom(int)

getOption

public final int getOption(int option)
Deprecated. Since 5.0 Please use getters instead.

Gets a search option.

Parameters:
option - Option identifier to be asked for.
Returns:
the setting of the given option
See Also:
SearchConstants.OPTION_KEEP_QUERY_ORDER, SearchConstants.OPTION_EXACT_FRAGMENT, SearchConstants.OPTION_MARKUSH_HIT, SearchConstants.OPTION_TAUTOMER_SEARCH, SearchConstants.OPTION_ISOTOPE_MATCHING, SearchConstants.OPTION_CHARGE_MATCHING, SearchConstants.OPTION_VALENCE_MATCHING, SearchConstants.OPTION_RADICAL_MATCHING, SearchConstants.OPTION_MARKUSH_ENABLED, SearchConstants.OPTION_VAGUE_BOND, SearchConstants.OPTION_MARKUSH_AROM, SearchConstants.OPTION_MIX_SGROUP_MATCHING, SearchConstants.OPTION_STEREO_MODEL, SearchOptions.isKeepQueryOrder(), SearchOptions.isExactFragment(), SearchOptions.isTautomerSearch(), SearchOptions.getIsotopeMatching(), SearchOptions.getChargeMatching(), SearchOptions.isValenceMatching(), SearchOptions.getRadicalMatching(), SearchOptions.getVagueBondLevel(), SearchOptions.isMixSgroupMatching(), SearchOptions.getStereoModel(), SearchOptions.getImplicitHMatching(), SearchOptions.isReactionUnpairedMapMatching(), MolSearchOptions.isMarkushHitSupergraph(), MolSearchOptions.isMarkushEnabled(), MolSearchOptions.getMarkushArom()

setOptions

public void setOptions(int[] newOptions)
Rapidly sets all needed search options.

Parameters:
newOptions - Option array to copy.

getMatchingQuery

public Molecule getMatchingQuery()
Returns the query which produced the hit vector of the last findNext(), findFirst() or findAll() result.

Returns:
The query or null if the query is not initialized yet or no searching operations were performed.
Since:
JChem 3.1.2

getSearchOptions

public MolSearchOptions 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 the behaviour of this Search object also!

Returns:
the current search settings as a SearchOptions object.
Since:
JChem 5.0
See Also:
setSearchOptions(SearchOptions)

setSearchOptions

public void setSearchOptions(SearchOptions options)
Copies all search parameters from options to the current search object.

Parameters:
options - search options to copy.
Since:
JChem 5.0
See Also:
getSearchOptions()

setTautomerSearch

public void setTautomerSearch(boolean value)
Sets if tautomers of the query should be enumerated for search.

Parameters:
value - set to true to enable enumeration of the tautomers of the query for search. The default is false.
Since:
JChem 5.0

isTautomerSearch

public boolean isTautomerSearch()
Indicates if tautomers of the query should be enumerated for search.

Returns:
wheather tautomers of the query are enumerated for search.
Since:
JChem 5.0
See Also:
setTautomerSearch(boolean)

getQueryToPrint

protected Molecule getQueryToPrint()
For internal purposes only.

Returns:
the query to be displayed for debug purposes only.

getTargetToPrint

protected Molecule getTargetToPrint()
For internal purposes only.

Returns:
the target to be displayed for debug purposes only.

getTargetAsString

protected java.lang.String getTargetAsString()
For internal purposes only.

Returns:
the target to be displayed for debug purposes only.

getQueryAsString

protected java.lang.String getQueryAsString()
For internal purposes only.

Returns:
the query to be displayed for debug purposes only.