Package chemaxon.descriptors
Class CustomDescriptor
java.lang.Object
chemaxon.descriptors.MolecularDescriptor
chemaxon.descriptors.CustomDescriptor
- All Implemented Interfaces:
Cloneable
The
CustomDescriptor
class implements a generic molecular
descriptor class which supports third party or use defined descriptors.
Such descriptors can be used throughout the entire JChem system as any other
MolecularDescriptor
with only one exception: they cannot be
generated by this class, they must be provided
by the user of this class. CustomDescriptor
supports the
management (storage/retrival) and dissimilarity calculations of such
descriptors. These descriptors can have three distinct types: float, int or
binary, their dimension is not limited. All metrics implemented in the
Metrics
class are supported
and can be optimized.- Since:
- JChem 2.3
-
Field Summary
Modifier and TypeFieldDescriptionprotected float[]
storage for the floating point descriptorsprotected int[]
storage for the integer or binary descriptorsFields inherited from class chemaxon.descriptors.MolecularDescriptor
params
-
Constructor Summary
ConstructorDescriptionCreates a new, empty instance of CustomDescriptor without allocating internal storage for its value.CustomDescriptor
(int type, int length) Creates a new, empty instance of CustomDescriptor and allocates internal storage to store values.CustomDescriptor
(CDParameters params) Creates a new instance of CustomDescriptor according to the parameters given.Copy constructor.CustomDescriptor
(String params) Creates a new instance of CustomDescriptor according to the parameters given. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the descriptor: sets all cells to store zero value.clone()
Creates a new instance with identical internal state.void
fromData
(byte[] dbRepr) Builds aCustomDescriptor
from an external data format, created by a previous call totoData()
.void
fromFloatArray
(float[] descr) Builds a molecular descriptor from its float array representation.void
fromString
(String descr) Builds a descriptor from its string representation created bytoString()
.float
Calculates the asymmetric Euclidean distance.int
getBit
(int cell) float[]
Gets the default dissimilarity threshold values for all dissimilarity metrics defined.float
Calculates the dissimilarity between two pharmacophore fingerprints using the default distance measure.float
getDissimilarity
(MolecularDescriptor descr, int metricIndex) Calculates the dissimilarity between two descriptors using the specified parametrized dissimilarity metric.String[]
Gets the dissimilarity metric names.float
Calculates the Euclidean distance.float
getFloat
(int cell) int
getInt
(int cell) getName()
Gets the name of theCustomDescriptor
object.Gets the name of the parameters class corresponding to the descriptor.float
Gets the Tanimoto dissimilarity coefficient.Gets the short name of the descriptor.float
Gets the Tanimoto dissimilarity coefficient.float
Calculates the weighted asymmetric Euclidean distance.float
Calculates the weighted Euclidean distance.void
set
(int cell, float value) Sets the value of one cell of the descriptor.void
set
(int cell, float[] values) Sets values of the descriptor.void
set
(int cell, int value) Sets the value of one cell of the descriptor.void
set
(int cell, int[] values) Sets values of the descriptor.void
setParameters
(CDParameters parameters) Sets parameters, allocates internal storage if needed and clears the descriptor.void
setParameters
(String parameters) Sets the parameters of an already createdCustomDescriptor
object.byte[]
toData()
Converts aCustomDescriptor
object into a byte array.Converts the descriptor into a readable string of decimal numbers (float or integer, depending on descriptor type).float[]
Creates the float array representation of aCustomDescriptor
object.toString()
Converts the descriptor into a readable string.Methods inherited from class chemaxon.descriptors.MolecularDescriptor
generate, generate, getAtomSetColors, getAtomSetIndexes, getAtomSetNames, getDefaultMetricIndex, getDefaultThreshold, getDissimilarityMetricIndex, getLowerBound, getMetricIndex, getMetricName, getMetricName, getNumberOfMetrics, getNumberOfWeights, getParameters, getThreshold, getThreshold, main, needsConfig, newInstance, newInstance, newInstanceFromXML, setParameters, setScreeningConfiguration, toBinaryString
-
Field Details
-
floatDescr
protected float[] floatDescrstorage for the floating point descriptors -
intDescr
protected int[] intDescrstorage for the integer or binary descriptors
-
-
Constructor Details
-
CustomDescriptor
public CustomDescriptor()Creates a new, empty instance of CustomDescriptor without allocating internal storage for its value. -
CustomDescriptor
public CustomDescriptor(int type, int length) Creates a new, empty instance of CustomDescriptor and allocates internal storage to store values.- Parameters:
type
- type of each cell of the descriptor (binary, int, float)length
- size (dimension) of the descriptor
-
CustomDescriptor
Creates a new instance of CustomDescriptor according to the parameters given.- Parameters:
params
- parameter configuration
-
CustomDescriptor
Creates a new instance of CustomDescriptor according to the parameters given.- Parameters:
params
- parameter configuration (XML) string
-
CustomDescriptor
Copy constructor. An identical copy of theCustomDescriptor
object passed is created. The original and the copy share the sameCDParameters
object.- Parameters:
cd
- descriptor object to be copied
-
-
Method Details
-
clone
Creates a new instance with identical internal state.- Specified by:
clone
in classMolecularDescriptor
- Returns:
- the newly copied object
-
getName
Gets the name of theCustomDescriptor
object. This name is not the same as the class name, it is nicer, more readable and meaningful for end-users too.- Overrides:
getName
in classMolecularDescriptor
- Returns:
- the nice, external name for
CCustomDescriptor
class objects
-
getShortName
Gets the short name of the descriptor.- Overrides:
getShortName
in classMolecularDescriptor
- Returns:
- the short name used in text outputs (tables etc.)
-
getParametersClassName
Gets the name of the parameters class corresponding to the descriptor.- Overrides:
getParametersClassName
in classMolecularDescriptor
- Returns:
- the name of the parameters class
-
setParameters
Sets parameters, allocates internal storage if needed and clears the descriptor.- Parameters:
parameters
- descriptor parameters
-
setParameters
Sets the parameters of an already createdCustomDescriptor
object.- Specified by:
setParameters
in classMolecularDescriptor
- Parameters:
parameters
- parameter settings for the descriptor- Throws:
MDParametersException
- any XML error
-
toData
public byte[] toData()Converts aCustomDescriptor
object into a byte array. This format can be reffered to as an "external representation" since it servers for storing fingerprints in databases.
Use thefromData()
method to build the object from this "external" representation.- Specified by:
toData
in classMolecularDescriptor
- Returns:
- byte array representation of the descriptor object
-
fromData
public void fromData(byte[] dbRepr) Builds aCustomDescriptor
from an external data format, created by a previous call totoData()
.- Specified by:
fromData
in classMolecularDescriptor
- Parameters:
dbRepr
- "external" representation of CustomDescriptor
-
set
public void set(int cell, float[] values) Sets values of the descriptor.- Parameters:
cell
- the index of the first cell (dimension) to be modifiedvalues
- new values to be stored
-
set
public void set(int cell, float value) Sets the value of one cell of the descriptor.- Parameters:
cell
- the index of the first cell to be modifiedvalue
- new value to be stored
-
set
public void set(int cell, int[] values) Sets values of the descriptor. This method is used in the case of integer and binary descriptors.- Parameters:
cell
- the index of the first cell (dimension) to be modifiedvalues
- new values to be stored
-
set
public void set(int cell, int value) Sets the value of one cell of the descriptor.- Parameters:
cell
- the index of the first cell to be modifiedvalue
- new value to be stored
-
getBit
public int getBit(int cell) -
getInt
public int getInt(int cell) -
getFloat
public float getFloat(int cell) -
clear
public void clear()Clears the descriptor: sets all cells to store zero value. -
toString
Converts the descriptor into a readable string. This is the default external text format of anyCustomDescriptor
.- Specified by:
toString
in classMolecularDescriptor
- Returns:
- string representation of the descriptor
-
toDecimalString
Converts the descriptor into a readable string of decimal numbers (float or integer, depending on descriptor type).- Specified by:
toDecimalString
in classMolecularDescriptor
- Returns:
- string representation of the descriptor
-
fromString
Builds a descriptor from its string representation created bytoString()
.- Specified by:
fromString
in classMolecularDescriptor
- Parameters:
descr
- a custom descriptor string of decimal values- Throws:
ParseException
-
toFloatArray
public float[] toFloatArray()Creates the float array representation of aCustomDescriptor
object. This array contains all values of the descriptor (including all zeros) in the elements of the array.- Specified by:
toFloatArray
in classMolecularDescriptor
- Returns:
- float array of the descriptor cells
-
fromFloatArray
public void fromFloatArray(float[] descr) Builds a molecular descriptor from its float array representation.- Specified by:
fromFloatArray
in classMolecularDescriptor
- Parameters:
descr
- descriptor represented in a float array
-
getDissimilarityMetrics
Gets the dissimilarity metric names.- Specified by:
getDissimilarityMetrics
in classMolecularDescriptor
- Returns:
- the metrics array
-
getDefaultDissimilarityMetricThresholds
public float[] getDefaultDissimilarityMetricThresholds()Gets the default dissimilarity threshold values for all dissimilarity metrics defined.- Specified by:
getDefaultDissimilarityMetricThresholds
in classMolecularDescriptor
- Returns:
- array of dissimilarity threshold values
-
getTanimoto
Gets the Tanimoto dissimilarity coefficient.- Parameters:
f
- the descriptor form which distance is measured- Returns:
- dissimilarity coefficient
-
getScaledTanimoto
Gets the Tanimoto dissimilarity coefficient. Both scale factor and the scaling hypothesis is stored in the correspondingCDParameters
object.- Parameters:
f
- the descriptor form which distance is measured- Returns:
- dissimilarity coefficient
-
getEuclidean
Calculates the Euclidean distance. The dissimilarity coefficient returned ranges from 0 to MAX_FLOAT, this coefficient is not normalized.- Parameters:
f
- another fingerprint from which the distance is measured- Returns:
- euclidean distance of the two descriptors
-
getAsymmetricEuclidean
Calculates the asymmetric Euclidean distance. This metric is often referred to as directed Euclidean. The dissimilarity coefficient returned ranges from 0 to MAX_FLOAT, this coefficient is not normalized. Asymmetry factor is stored in the correspondingCDParameters
object.- Parameters:
f
- another fingerprint from which the distance is measured- Returns:
- asymmetric euclidean distance of the two descriptors
-
getWeightedEuclidean
Calculates the weighted Euclidean distance. Weights are taken from the associatedCDParameters
object.- Parameters:
f
- a fingerprint from which the distance is measured- Returns:
- weighted euclidean distance of the two descriptors
-
getWeightedAsymmetricEuclidean
Calculates the weighted asymmetric Euclidean distance. Weights and asymmetry ratio are taken from the associatedCDParameters
object.- Parameters:
f
- a fingerprint from which the distance is measured- Returns:
- weighted asymmetric euclidean distance of the two descriptors
-
getDissimilarity
Calculates the dissimilarity between two pharmacophore fingerprints using the default distance measure.- Specified by:
getDissimilarity
in classMolecularDescriptor
- Parameters:
descr
- the other descriptor- Returns:
- dissimilarity ratio
-
getDissimilarity
Calculates the dissimilarity between two descriptors using the specified parametrized dissimilarity metric.- Specified by:
getDissimilarity
in classMolecularDescriptor
- Parameters:
descr
- the descriptor from which the distance is measuredmetricIndex
- index of the parametrized metric to be used- Returns:
- the dissimilarity ratio
- See Also:
-