chemaxon.descriptors
Class ReactionFingerprint

java.lang.Object
  extended by chemaxon.descriptors.MolecularDescriptor
      extended by chemaxon.descriptors.ReactionFingerprint
All Implemented Interfaces:
java.lang.Cloneable

public class ReactionFingerprint
extends MolecularDescriptor

ReactionFingerprint class.

Since:
JChem 3.2
Version:
5.1.2 09/24/2008
Author:
Zsolt Mohacsi

Field Summary
protected  int brightness
          number of bits set in the fingerprint (sometimes this is called the darkness, but that seems to be less pausible)
protected  int[] fp
          storage for the fingerprint
 
Fields inherited from class chemaxon.descriptors.MolecularDescriptor
params
 
Constructor Summary
ReactionFingerprint()
          Creates a new, empty instance of ReactionFingerprint without allocating internal storage.
ReactionFingerprint(ReactionFingerprint rfp)
          Copy constructor.
ReactionFingerprint(RFParameters params)
          Creates a new instance of ReactionFingerprint according to the parameters given.
ReactionFingerprint(java.lang.String params)
          Creates a new instance of ReactionFingerprint according to the parameters given.
 
Method Summary
 void clear()
          Clears the fingerprint: sets all bins to store zero value.
 ReactionFingerprint clone()
          Creates a copy with identical internal state.
 void fromData(byte[] dbRepr)
          Builds a fingerprint from an external data format, created by a previous call to toData().
 void fromFloatArray(float[] descr)
          Builds fingerprint from its float array representation.
 void fromString(java.lang.String cfp)
          Builds a fingerprint from its string representation created by toString().
 java.lang.String[] generate(Molecule m)
          Creates the ReactionFingerprint descriptor for the given Molecule.
 int getBrightness()
          Gets the brightness of the fingerprint.
static int[] getChemicalHashedFingerprint(int[] reactionFingerprint, int length)
          Creates chemical hashed fingerpint from reaction fingerprint.
 float getCoarseReactionTanimoto(ReactionFingerprint f)
          Returns the tanimoto distance of the reaction centers.
 int getCommonBitCount(ReactionFingerprint f)
           
 float[] getDefaultDissimilarityMetricThresholds()
          Gets the default dissimilarity threshold values for all dissimilarity metrics defined.
 int getDefaultMetricIndex()
          Gets the index of the default metric.
 float getDefaultThreshold(int metricIndex)
          Gets a metric dependent default threshold value.
 float getDissimilarity(MolecularDescriptor fp2)
          Calculates the dissimilarity between two reaction fingerprints using the default distance measure.
 float getDissimilarity(MolecularDescriptor fp2, int metricIndex)
          Calculates the dissimilarity between two reaction fingerprints using the specified distance metric.
 java.lang.String[] getDissimilarityMetrics()
          Gets the dissimilarity metric names
 java.lang.String[] getDissimilarityMetricsParamDefault()
          Gets the dissimilarity metric parameter names -> no parameters.
 java.lang.String[] getDissimilarityMetricsParamHelp()
          Gets the dissimilarity metric parameter names -> no parameters.
 java.lang.String[] getDissimilarityMetricsParamNames()
          Gets the dissimilarity metric parameter names -> no parameters.
 int[] getDissimilarityMetricsParamNum()
          Gets the dissimilarity metric parameter number -> no parameters.
 java.lang.String[] getDissimilarityMetricsParamRanges()
          Gets the dissimilarity metric parameter ranges -> no parameters.
 float getLowerBound(MolecularDescriptor fp2)
          Calculates the lower bound estimate of the dissimilarity from the given fingerprint.
 float getMediumReactionTanimoto(ReactionFingerprint f)
          Returns the tanimoto distance of the reaction centers and their neighbouring atoms and bonds.
 java.lang.String getName()
          Gets the nice name of the ReactionFingerprint descriptor object.
 java.lang.String getParametersClassName()
          Gets the name of the parameters class corresponding to the descriptor.
 float getProductTanimoto(ReactionFingerprint f)
          Returns the tanimoto distance of the product sides.
 float getReactantTanimoto(ReactionFingerprint f)
          Returns the tanimoto distance of the reactant sides.
 java.lang.String getShortName()
          Gets the short name of the descriptor.
 float getStrictReactionTanimoto(ReactionFingerprint f)
          Returns the tanimoto distance of the reaction centers, their immediate neighbour atoms and bonds, and the neighbours' neighbouring atoms and bonds.
 boolean isReactionMappingIncomplete()
          Returns true if reaction molecule was not mapped completely during reaction fingerprint generation.
 boolean isSubSetOf(ReactionFingerprint f)
           
static void main(java.lang.String[] argv)
           
 void setParameters(MDParameters parameters)
          Sets parameters, allocates internal storage if needed and cleans the descriptor.
 void setParameters(java.lang.String parameters)
          Sets the parameters of an already created ReactionFingerprint object.
 java.lang.String toBinaryString()
          Converts the fingerprint into a 0,1 string.
 byte[] toData()
          Converts a reaction fingerprint object into a byte array.
 java.lang.String toDecimalString()
          Converts the fingerprint into a tab separated string.
 float[] toFloatArray()
          Creates the float array representation of the fingerprint.
 java.lang.String toString()
          Converts the fingerprint into a readable string.
 
Methods inherited from class chemaxon.descriptors.MolecularDescriptor
generate, getAtomSetColors, getAtomSetIndexes, getAtomSetNames, getDissimilarityMetricIndex, getMetricIndex, getMetricName, getMetricName, getNumberOfMetrics, getNumberOfWeights, getParameters, getThreshold, getThreshold, needsConfig, newInstance, newInstance, newInstanceFromXML, setScreeningConfiguration
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fp

protected int[] fp
storage for the fingerprint


brightness

protected int brightness
number of bits set in the fingerprint (sometimes this is called the darkness, but that seems to be less pausible)

Constructor Detail

ReactionFingerprint

public ReactionFingerprint()
Creates a new, empty instance of ReactionFingerprint without allocating internal storage.


ReactionFingerprint

public ReactionFingerprint(RFParameters params)
Creates a new instance of ReactionFingerprint according to the parameters given.

Parameters:
params - parameters used in fingerprint generation and handling

ReactionFingerprint

public ReactionFingerprint(java.lang.String params)
Creates a new instance of ReactionFingerprint according to the parameters given.

Parameters:
params - parameter settings

ReactionFingerprint

public ReactionFingerprint(ReactionFingerprint rfp)
Copy constructor. An identical copy of the reaction fingerprint passed is created. The old and the new instances share the same RFParameters object.

Parameters:
rfp - fingerprint to be copied
Method Detail

clone

public ReactionFingerprint clone()
Creates a copy with identical internal state. The new instances share the same RFParameters object with the copied one.

Specified by:
clone in class MolecularDescriptor
Returns:
the newly created object

getName

public java.lang.String getName()
Gets the nice name of the ReactionFingerprint descriptor object. This name is not the same as the class name: it is nicer, and more meaningful for end-users.

Overrides:
getName in class MolecularDescriptor
Returns:
the nice, external name for ReactionFingerprint descriptor class objects

getShortName

public java.lang.String getShortName()
Gets the short name of the descriptor. This name appears in text outputs.

Overrides:
getShortName in class MolecularDescriptor
Returns:
the short name used in text outputs (tables etc.)

getParametersClassName

public java.lang.String getParametersClassName()
Gets the name of the parameters class corresponding to the descriptor.

Overrides:
getParametersClassName in class MolecularDescriptor
Returns:
the name of the parameters class

getBrightness

public int getBrightness()
Gets the brightness of the fingerprint. Actually, sometimes this is called the darkness. To be precise, this methods gets the numbers of 1 (one) bits in the fingerprint.

Returns:
number of bits set to 1

setParameters

public void setParameters(MDParameters parameters)
Sets parameters, allocates internal storage if needed and cleans the descriptor.

Overrides:
setParameters in class MolecularDescriptor
Parameters:
parameters - fingerprint parameters

setParameters

public void setParameters(java.lang.String parameters)
                   throws chemaxon.descriptors.MDParametersException
Sets the parameters of an already created ReactionFingerprint object.

Specified by:
setParameters in class MolecularDescriptor
Parameters:
parameters - parameter settings for the descriptor
Throws:
chemaxon.descriptors.MDParametersException - any XML error

toData

public byte[] toData()
Converts a reaction fingerprint object into a byte array. This format can be reffered to as an "external representation" since it servers as the data format for storing fingerprints in databases..
Use the fromData() method to build the fingerprint from this "external" representation.

Specified by:
toData in class MolecularDescriptor
Returns:
byte array representation of the fingerprint object

fromData

public void fromData(byte[] dbRepr)
Builds a fingerprint from an external data format, created by a previous call to toData().

Specified by:
fromData in class MolecularDescriptor
Parameters:
dbRepr - "external" representation of ReactionFingerprint

clear

public final void clear()
Clears the fingerprint: sets all bins to store zero value.


toString

public final java.lang.String toString()
Converts the fingerprint into a readable string. This is the default external text format of the fingerprint, which can also be stored into an SDfile.

Specified by:
toString in class MolecularDescriptor
Returns:
string representation of the fingerprint

toDecimalString

public final java.lang.String toDecimalString()
Converts the fingerprint into a tab separated string.

Specified by:
toDecimalString in class MolecularDescriptor
Returns:
string representation of the fingerprint

toBinaryString

public java.lang.String toBinaryString()
Converts the fingerprint into a 0,1 string.

Overrides:
toBinaryString in class MolecularDescriptor
Returns:
binary string representation of the fingerprint

fromString

public final void fromString(java.lang.String cfp)
                      throws java.text.ParseException
Builds a fingerprint from its string representation created by toString().

Specified by:
fromString in class MolecularDescriptor
Parameters:
cfp - fingerprint string
Throws:
java.text.ParseException

toFloatArray

public final float[] toFloatArray()
Creates the float array representation of the fingerprint. This array contains all values of the fingerprint (including all zeros) in the elements of the array.

Specified by:
toFloatArray in class MolecularDescriptor
Returns:
a float array representation of the fingerprint

fromFloatArray

public void fromFloatArray(float[] descr)
                    throws java.lang.RuntimeException
Builds fingerprint from its float array representation. Typically used when a hypothesis is created.

Specified by:
fromFloatArray in class MolecularDescriptor
Parameters:
descr - fingerprint represented in a float array (e.g. generated by toFloatArray())
Throws:
java.lang.RuntimeException

generate

public java.lang.String[] generate(Molecule m)
                            throws chemaxon.descriptors.MDGeneratorException
Creates the ReactionFingerprint descriptor for the given Molecule. Calls the generator created by the corresponding MDParameters class.

Overrides:
generate in class MolecularDescriptor
Returns:
property names set in the molecule passed during generation
Throws:
chemaxon.descriptors.MDGeneratorException - when failed to generate descriptor

isReactionMappingIncomplete

public boolean isReactionMappingIncomplete()
Returns true if reaction molecule was not mapped completely during reaction fingerprint generation. Should be called after generate(Molecule).

Returns:
true if the reaction molecule was not mapped completely
Since:
JChem 5.1.2

getDissimilarityMetrics

public java.lang.String[] getDissimilarityMetrics()
Gets the dissimilarity metric names

Specified by:
getDissimilarityMetrics in class MolecularDescriptor
Returns:
the metrics array

getDissimilarityMetricsParamNum

public int[] getDissimilarityMetricsParamNum()
Gets the dissimilarity metric parameter number -> no parameters.

Returns:
the metrics array

getDissimilarityMetricsParamNames

public java.lang.String[] getDissimilarityMetricsParamNames()
Gets the dissimilarity metric parameter names -> no parameters.

Returns:
the metrics array

getDissimilarityMetricsParamRanges

public java.lang.String[] getDissimilarityMetricsParamRanges()
Gets the dissimilarity metric parameter ranges -> no parameters.

Returns:
the metrics array

getDissimilarityMetricsParamDefault

public java.lang.String[] getDissimilarityMetricsParamDefault()
Gets the dissimilarity metric parameter names -> no parameters.

Returns:
the metrics array

getDissimilarityMetricsParamHelp

public java.lang.String[] getDissimilarityMetricsParamHelp()
Gets the dissimilarity metric parameter names -> no parameters.

Returns:
the metrics array

getDefaultDissimilarityMetricThresholds

public float[] getDefaultDissimilarityMetricThresholds()
Gets the default dissimilarity threshold values for all dissimilarity metrics defined.

Specified by:
getDefaultDissimilarityMetricThresholds in class MolecularDescriptor
Returns:
array of dissimilarity threshold values

getDefaultMetricIndex

public int getDefaultMetricIndex()
Gets the index of the default metric. In the case of PharmacophoreFingerprint this is Tanimoto.

Overrides:
getDefaultMetricIndex in class MolecularDescriptor
Returns:
metric index of the default metric

getDefaultThreshold

public float getDefaultThreshold(int metricIndex)
Gets a metric dependent default threshold value. Ideally, this value should be based on statistics, though the actual value is not too critical, since these are only used in user interfaces to simplify the use of applications for beginners.

Overrides:
getDefaultThreshold in class MolecularDescriptor
Parameters:
metricIndex - index of a parametrized metric

getCommonBitCount

public int getCommonBitCount(ReactionFingerprint f)

getReactantTanimoto

public float getReactantTanimoto(ReactionFingerprint f)
Returns the tanimoto distance of the reactant sides.

Parameters:
f - the distance from f is calculated
Returns:
the tanimoto distance (dissimilarity coefficient)

getProductTanimoto

public float getProductTanimoto(ReactionFingerprint f)
Returns the tanimoto distance of the product sides.

Parameters:
f - the distance from f is calculated
Returns:
the tanimoto distance (dissimilarity coefficient)

getCoarseReactionTanimoto

public float getCoarseReactionTanimoto(ReactionFingerprint f)
Returns the tanimoto distance of the reaction centers. The direction of the reaction is considered.

Parameters:
f - the distance from f is calculated
Returns:
the tanimoto distance (dissimilarity coefficient)

getMediumReactionTanimoto

public float getMediumReactionTanimoto(ReactionFingerprint f)
Returns the tanimoto distance of the reaction centers and their neighbouring atoms and bonds. The direction of the reaction is considered.

Parameters:
f - the distance from f is calculated
Returns:
the tanimoto distance (dissimilarity coefficient)

getStrictReactionTanimoto

public float getStrictReactionTanimoto(ReactionFingerprint f)
Returns the tanimoto distance of the reaction centers, their immediate neighbour atoms and bonds, and the neighbours' neighbouring atoms and bonds. The direction of the reaction is considered.

Parameters:
f - the distance from f is calculated
Returns:
the tanimoto distance (dissimilarity coefficient)

getDissimilarity

public float getDissimilarity(MolecularDescriptor fp2)
Calculates the dissimilarity between two reaction fingerprints using the default distance measure.

Specified by:
getDissimilarity in class MolecularDescriptor
Parameters:
fp2 - the other reaction fingerprint
Returns:
dissimilarity ratio

getDissimilarity

public float getDissimilarity(MolecularDescriptor fp2,
                              int metricIndex)
Calculates the dissimilarity between two reaction fingerprints using the specified distance metric. The index of the required metric can be obtained by calling getMetricIndex( String metricName ) .
New metrics implemented by this class have to be added at the end of the existing ones.

Specified by:
getDissimilarity in class MolecularDescriptor
Parameters:
fp2 - the reaction fingerprint from which the distance is measured
metricIndex - index of the metric to be used
Returns:
the dissimilarity ratio
See Also:
MDParameters, PFParameters

getLowerBound

public float getLowerBound(MolecularDescriptor fp2)
Calculates the lower bound estimate of the dissimilarity from the given fingerprint. In the case of ReactionFingerprint a good estimate for the minimum distance cannot be obtained efficiently (that is, significantly faster than calculating the proper distance) therefore 0 is returned. This trivial distance bound estimation will lead to calling getDistance.

Overrides:
getLowerBound in class MolecularDescriptor
Parameters:
fp2 - reaction fingerprint from which distance is measured
Returns:
estimate of the minimum distance

isSubSetOf

public boolean isSubSetOf(ReactionFingerprint f)

getChemicalHashedFingerprint

public static int[] getChemicalHashedFingerprint(int[] reactionFingerprint,
                                                 int length)
Creates chemical hashed fingerpint from reaction fingerprint.

Parameters:
reactionFingerprint - the fingeprint as was generated by ReactionFingerprint, may contain additional data (e.g. structural keys) at the end
length - the length of the FP part in integers to consider (the remainder will be ignored, e.g. structural keys)
Returns:
the chemical hashed fingerprint of the total reaction

main

public static void main(java.lang.String[] argv)