Package chemaxon.descriptors
Class CustomDescriptor
- java.lang.Object
-
- chemaxon.descriptors.MolecularDescriptor
-
- chemaxon.descriptors.CustomDescriptor
-
- All Implemented Interfaces:
Cloneable
@PublicAPI public class CustomDescriptor extends MolecularDescriptor
TheCustomDescriptor
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 otherMolecularDescriptor
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
class are supported and can be optimized.Metrics
- Since:
- JChem 2.3
-
-
Field Summary
Fields Modifier and Type Field Description protected float[]
floatDescr
storage for the floating point descriptorsprotected int[]
intDescr
storage for the integer or binary descriptors-
Fields inherited from class chemaxon.descriptors.MolecularDescriptor
params
-
-
Constructor Summary
Constructors Constructor Description CustomDescriptor()
Creates 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.CustomDescriptor(CustomDescriptor cd)
Copy constructor.CustomDescriptor(String params)
Creates a new instance of CustomDescriptor according to the parameters given.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the descriptor: sets all cells to store zero value.CustomDescriptor
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
getAsymmetricEuclidean(CustomDescriptor f)
Calculates the asymmetric Euclidean distance.int
getBit(int cell)
float[]
getDefaultDissimilarityMetricThresholds()
Gets the default dissimilarity threshold values for all dissimilarity metrics defined.float
getDissimilarity(MolecularDescriptor descr)
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[]
getDissimilarityMetrics()
Gets the dissimilarity metric names.float
getEuclidean(CustomDescriptor f)
Calculates the Euclidean distance.float
getFloat(int cell)
int
getInt(int cell)
String
getName()
Gets the name of theCustomDescriptor
object.String
getParametersClassName()
Gets the name of the parameters class corresponding to the descriptor.float
getScaledTanimoto(CustomDescriptor f)
Gets the Tanimoto dissimilarity coefficient.String
getShortName()
Gets the short name of the descriptor.float
getTanimoto(CustomDescriptor f)
Gets the Tanimoto dissimilarity coefficient.float
getWeightedAsymmetricEuclidean(CustomDescriptor f)
Calculates the weighted asymmetric Euclidean distance.float
getWeightedEuclidean(CustomDescriptor f)
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.String
toDecimalString()
Converts the descriptor into a readable string of decimal numbers (float or integer, depending on descriptor type).float[]
toFloatArray()
Creates the float array representation of aCustomDescriptor
object.String
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, newInstanceSupplier, setParameters, setScreeningConfiguration, toBinaryString
-
-
-
-
Constructor Detail
-
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
public CustomDescriptor(CDParameters params)
Creates a new instance of CustomDescriptor according to the parameters given.- Parameters:
params
- parameter configuration
-
CustomDescriptor
public CustomDescriptor(String params)
Creates a new instance of CustomDescriptor according to the parameters given.- Parameters:
params
- parameter configuration (XML) string
-
CustomDescriptor
public CustomDescriptor(CustomDescriptor cd)
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 Detail
-
clone
public CustomDescriptor clone()
Creates a new instance with identical internal state.- Specified by:
clone
in classMolecularDescriptor
- Returns:
- the newly copied object
-
getName
public String 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
public String getShortName()
Gets the short name of the descriptor.- Overrides:
getShortName
in classMolecularDescriptor
- Returns:
- the short name used in text outputs (tables etc.)
-
getParametersClassName
public String getParametersClassName()
Gets the name of the parameters class corresponding to the descriptor.- Overrides:
getParametersClassName
in classMolecularDescriptor
- Returns:
- the name of the parameters class
-
setParameters
public void setParameters(CDParameters parameters)
Sets parameters, allocates internal storage if needed and clears the descriptor.- Parameters:
parameters
- descriptor parameters
-
setParameters
public void setParameters(String parameters) throws MDParametersException
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
public String 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
public String 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
public void fromString(String descr) throws ParseException
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
public String[] 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
public float getTanimoto(CustomDescriptor f)
Gets the Tanimoto dissimilarity coefficient.- Parameters:
f
- the descriptor form which distance is measured- Returns:
- dissimilarity coefficient
-
getScaledTanimoto
public float getScaledTanimoto(CustomDescriptor f)
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
public float getEuclidean(CustomDescriptor f)
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
public float getAsymmetricEuclidean(CustomDescriptor f)
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
public float getWeightedEuclidean(CustomDescriptor f)
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
public float getWeightedAsymmetricEuclidean(CustomDescriptor f)
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
public float getDissimilarity(MolecularDescriptor descr)
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
public float getDissimilarity(MolecularDescriptor descr, int metricIndex)
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:
MDParameters
,PFParameters
-
-