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
FieldsModifier 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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionvoidclear()Clears the descriptor: sets all cells to store zero value.clone()Creates a new instance with identical internal state.voidfromData(byte[] dbRepr) Builds aCustomDescriptorfrom an external data format, created by a previous call totoData().voidfromFloatArray(float[] descr) Builds a molecular descriptor from its float array representation.voidfromString(String descr) Builds a descriptor from its string representation created bytoString().floatCalculates the asymmetric Euclidean distance.intgetBit(int cell) float[]Gets the default dissimilarity threshold values for all dissimilarity metrics defined.floatCalculates the dissimilarity between two pharmacophore fingerprints using the default distance measure.floatgetDissimilarity(MolecularDescriptor descr, int metricIndex) Calculates the dissimilarity between two descriptors using the specified parametrized dissimilarity metric.String[]Gets the dissimilarity metric names.floatCalculates the Euclidean distance.floatgetFloat(int cell) intgetInt(int cell) getName()Gets the name of theCustomDescriptorobject.Gets the name of the parameters class corresponding to the descriptor.floatGets the Tanimoto dissimilarity coefficient.Gets the short name of the descriptor.floatGets the Tanimoto dissimilarity coefficient.floatCalculates the weighted asymmetric Euclidean distance.floatCalculates the weighted Euclidean distance.voidset(int cell, float value) Sets the value of one cell of the descriptor.voidset(int cell, float[] values) Sets values of the descriptor.voidset(int cell, int value) Sets the value of one cell of the descriptor.voidset(int cell, int[] values) Sets values of the descriptor.voidsetParameters(CDParameters parameters) Sets parameters, allocates internal storage if needed and clears the descriptor.voidsetParameters(String parameters) Sets the parameters of an already createdCustomDescriptorobject.byte[]toData()Converts aCustomDescriptorobject 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 aCustomDescriptorobject.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, 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 theCustomDescriptorobject passed is created. The original and the copy share the sameCDParametersobject.- Parameters:
cd- descriptor object to be copied
-
-
Method Details
-
clone
Creates a new instance with identical internal state.- Specified by:
clonein classMolecularDescriptor- Returns:
- the newly copied object
-
getName
Gets the name of theCustomDescriptorobject. This name is not the same as the class name, it is nicer, more readable and meaningful for end-users too.- Overrides:
getNamein classMolecularDescriptor- Returns:
- the nice, external name for
CCustomDescriptorclass objects
-
getShortName
Gets the short name of the descriptor.- Overrides:
getShortNamein classMolecularDescriptor- Returns:
- the short name used in text outputs (tables etc.)
-
getParametersClassName
Gets the name of the parameters class corresponding to the descriptor.- Overrides:
getParametersClassNamein 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 createdCustomDescriptorobject.- Specified by:
setParametersin classMolecularDescriptor- Parameters:
parameters- parameter settings for the descriptor- Throws:
MDParametersException- any XML error
-
toData
public byte[] toData()Converts aCustomDescriptorobject 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:
toDatain classMolecularDescriptor- Returns:
- byte array representation of the descriptor object
-
fromData
public void fromData(byte[] dbRepr) Builds aCustomDescriptorfrom an external data format, created by a previous call totoData().- Specified by:
fromDatain 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:
toStringin 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:
toDecimalStringin classMolecularDescriptor- Returns:
- string representation of the descriptor
-
fromString
Builds a descriptor from its string representation created bytoString().- Specified by:
fromStringin classMolecularDescriptor- Parameters:
descr- a custom descriptor string of decimal values- Throws:
ParseException
-
toFloatArray
public float[] toFloatArray()Creates the float array representation of aCustomDescriptorobject. This array contains all values of the descriptor (including all zeros) in the elements of the array.- Specified by:
toFloatArrayin 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:
fromFloatArrayin classMolecularDescriptor- Parameters:
descr- descriptor represented in a float array
-
getDissimilarityMetrics
Gets the dissimilarity metric names.- Specified by:
getDissimilarityMetricsin classMolecularDescriptor- Returns:
- the metrics array
-
getDefaultDissimilarityMetricThresholds
public float[] getDefaultDissimilarityMetricThresholds()Gets the default dissimilarity threshold values for all dissimilarity metrics defined.- Specified by:
getDefaultDissimilarityMetricThresholdsin 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 correspondingCDParametersobject.- 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 correspondingCDParametersobject.- 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 associatedCDParametersobject.- 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 associatedCDParametersobject.- 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:
getDissimilarityin classMolecularDescriptor- Parameters:
descr- the other descriptor- Returns:
- dissimilarity ratio
-
getDissimilarity
Calculates the dissimilarity between two descriptors using the specified parametrized dissimilarity metric.- Specified by:
getDissimilarityin 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:
-