Class CustomDescriptor

java.lang.Object
chemaxon.descriptors.MolecularDescriptor
chemaxon.descriptors.CustomDescriptor
All Implemented Interfaces:
Cloneable

@PublicApi public class CustomDescriptor extends MolecularDescriptor
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 Details

    • floatDescr

      protected float[] floatDescr
      storage for the floating point descriptors
    • intDescr

      protected int[] intDescr
      storage 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

      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 the CustomDescriptor object passed is created. The original and the copy share the same CDParameters object.
      Parameters:
      cd - descriptor object to be copied
  • Method Details

    • clone

      public CustomDescriptor clone()
      Creates a new instance with identical internal state.
      Specified by:
      clone in class MolecularDescriptor
      Returns:
      the newly copied object
    • getName

      public String getName()
      Gets the name of the CustomDescriptor 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 class MolecularDescriptor
      Returns:
      the nice, external name for CCustomDescriptor class objects
    • getShortName

      public String getShortName()
      Gets the short name of the descriptor.
      Overrides:
      getShortName in class MolecularDescriptor
      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 class MolecularDescriptor
      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 created CustomDescriptor object.
      Specified by:
      setParameters in class MolecularDescriptor
      Parameters:
      parameters - parameter settings for the descriptor
      Throws:
      MDParametersException - any XML error
    • toData

      public byte[] toData()
      Converts a CustomDescriptor object into a byte array. This format can be reffered to as an "external representation" since it servers for storing fingerprints in databases.
      Use the fromData() method to build the object from this "external" representation.
      Specified by:
      toData in class MolecularDescriptor
      Returns:
      byte array representation of the descriptor object
    • fromData

      public void fromData(byte[] dbRepr)
      Builds a CustomDescriptor from an external data format, created by a previous call to toData().
      Specified by:
      fromData in class MolecularDescriptor
      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 modified
      values - 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 modified
      value - 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 modified
      values - 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 modified
      value - 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 any CustomDescriptor.
      Specified by:
      toString in class MolecularDescriptor
      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 class MolecularDescriptor
      Returns:
      string representation of the descriptor
    • fromString

      public void fromString(String descr) throws ParseException
      Builds a descriptor from its string representation created by toString().
      Specified by:
      fromString in class MolecularDescriptor
      Parameters:
      descr - a custom descriptor string of decimal values
      Throws:
      ParseException
    • toFloatArray

      public float[] toFloatArray()
      Creates the float array representation of a CustomDescriptor object. This array contains all values of the descriptor (including all zeros) in the elements of the array.
      Specified by:
      toFloatArray in class MolecularDescriptor
      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 class MolecularDescriptor
      Parameters:
      descr - descriptor represented in a float array
    • getDissimilarityMetrics

      public String[] getDissimilarityMetrics()
      Gets the dissimilarity metric names.
      Specified by:
      getDissimilarityMetrics in class MolecularDescriptor
      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
    • 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 corresponding CDParameters 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 corresponding CDParameters 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 associated CDParameters 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 associated CDParameters 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 class MolecularDescriptor
      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 class MolecularDescriptor
      Parameters:
      descr - the descriptor from which the distance is measured
      metricIndex - index of the parametrized metric to be used
      Returns:
      the dissimilarity ratio
      See Also: