@PublicAPI public abstract class MolecularDescriptor extends java.lang.Object implements java.lang.Cloneable
MolecularDescriptor
class models all kinds of structural keys, fingerprints (hashed,
pharmacophoric), MDL keys and many others which can be implemented in derived
classes, some of these are implemented in JChem.
For the sake of generality the MolecularDescriptor
class does
not introduce operations that manipulate descriptors on "atomic"
level, that is, cells (or bins) of descriptors cannot be accessed either for
reading or for writing. This is because cells in various chemical descriptors
can have different type (for example bit, integer or floating point value).
MolecularDescriptor
derivatives
are not supported, though for the sake of efficiency no extra type checking
is introduced (other than provided by the language itself).
MolecularDescriptor
subclasses may have different representations (for instance integer
array vs. float array).Modifier and Type | Field and Description |
---|---|
protected MDParameters |
params
Parameter settings related to the descriptor.
|
Constructor and Description |
---|
MolecularDescriptor()
Default constructor, creates an empty object.
|
MolecularDescriptor(MDParameters parameters)
Creates a new
MolecularDescriptor with the given
parameters. |
MolecularDescriptor(MolecularDescriptor c)
Copy constructor, creates am identical copy of the
MolecularDescriptor passed as a parameter. |
Modifier and Type | Method and Description |
---|---|
abstract MolecularDescriptor |
clone()
Creates a new instance with identical internal state.
|
abstract void |
fromData(byte[] dbRepr)
Builds a
MolecularDescriptor object from its external
(database) representation. |
abstract void |
fromFloatArray(float[] descr)
Builds a molecular descriptor from its float array representation.
|
abstract void |
fromString(java.lang.String descr)
Builds a molecular descriptor from its string representation.
|
java.lang.String[] |
generate(Molecule m)
Creates the descriptor for the given Molecule.
|
java.lang.String[] |
generate(java.lang.String molRepr)
Creates the descriptor for the given Molecule.
|
java.awt.Color[] |
getAtomSetColors()
Determines the coloring of atoms.
|
int[] |
getAtomSetIndexes(Molecule m)
Gets the individual atom color indexes.
|
java.lang.String[] |
getAtomSetNames() |
abstract 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.
|
abstract float |
getDissimilarity(MolecularDescriptor other)
Calculates the dissimilarity ratio between two
MolecularDescriptor
objects using the default metric. |
abstract float |
getDissimilarity(MolecularDescriptor other,
int parametrizedMetricIndex)
Calculates the dissimilarity between two
MolecularDescriptor
objects using the specified metric, apart from that it is the same as
getDissimilarity( final MolecularDescriptor other ) . |
int |
getDissimilarityMetricIndex(java.lang.String metricName)
Gets the internal index of the given metric.
|
abstract java.lang.String[] |
getDissimilarityMetrics()
Gets the dissimilarity metric names in an array.
|
float |
getLowerBound(MolecularDescriptor other)
Calculates an estimate for the minimum value of the distance
using the default distance metric.
|
int |
getMetricIndex(java.lang.String metricName)
Gets the index of the given parameterized metric.
|
java.lang.String |
getMetricName()
Gets the name of the current parameterized metric.
|
java.lang.String |
getMetricName(int metricIndex)
Gets the name of a metric specified parameterized metric by its index.
|
java.lang.String |
getName()
Gets the name of the descriptor.
|
int |
getNumberOfMetrics()
Gets the number of parameterized metrics available for the particular
descriptor.
|
int |
getNumberOfWeights(java.lang.String dissimilarityMetricName)
Gets the number of weight factors used by the specified metric.
|
MDParameters |
getParameters()
Gets the parameters associated with the object.
|
java.lang.String |
getParametersClassName()
Gets the name of the parameters class corresponding to the descriptor
(prefixed with the package name as getClass().getName() would return).
|
java.lang.String |
getShortName()
Gets the short name of the descriptor.
|
float |
getThreshold()
Gets threshold value of the current parameterized metric.
|
float |
getThreshold(int metricIndex)
Gets a metric dependent default threshold value.
|
static void |
main(java.lang.String[] args) |
boolean |
needsConfig()
Indicates if class takes parameters from configuration file.
|
static MolecularDescriptor |
newInstance(java.lang.String descriptorTypeName)
Creates a MolecularDescriptor specified by its name.
|
static MolecularDescriptor |
newInstance(java.lang.String descriptorTypeName,
java.lang.String parameters)
Creates a MolecularDescriptor specified by its name and xml parameter.
|
static MolecularDescriptor |
newInstanceFromXML(java.lang.String parameters)
Creates a new MolecularDescriptor instance according to the given parameter string.
|
static com.google.common.base.Supplier<MolecularDescriptor> |
newInstanceSupplier(java.lang.String descriptorTypeName)
Creates a
Supplier of the specified molecular descriptor. |
void |
setParameters(MDParameters parameters)
Sets the parameters for an already created
MolecularDescriptor . |
abstract void |
setParameters(java.lang.String parameters)
Sets the parameters for an already created
MolecularDescriptor . |
void |
setScreeningConfiguration(java.lang.String config)
Sets the screening configuration.
|
java.lang.String |
toBinaryString()
Creates the binary string representation of a
MolecularDescriptor
object. |
abstract byte[] |
toData()
Converts the internal (memory) representation of a
MolecularDescriptor instance into an external format that
can be stored in a database. |
abstract java.lang.String |
toDecimalString()
Creates the string representation of a
MolecularDescriptor
object. |
abstract float[] |
toFloatArray()
Creates the float array representation of a
MolecularDescriptor
object. |
abstract java.lang.String |
toString()
Creates the string representation of a
MolecularDescriptor
object. |
protected MDParameters params
MolecularDescriptor
class with the same parameter setting
share a common MDParameter
object, however
MolecularDescriptor
objects having different parameters
are also allowed in the same application.
MDParameters
can be specialized with inheritance, thus
classes derived from MolecularDescriptor
are recommended
to derive their own MDParameters
sub-clusses.public MolecularDescriptor(MDParameters parameters)
MolecularDescriptor
with the given
parameters.parameters
- parameter settings of the descriptor to be createdpublic MolecularDescriptor()
public MolecularDescriptor(MolecularDescriptor c)
MolecularDescriptor
passed as a parameter.c
- a MolecularDescriptor
to be copiedpublic static final MolecularDescriptor newInstance(java.lang.String descriptorTypeName, java.lang.String parameters)
descriptorTypeName
- predefined type name or class name
If the name doesn't match any of the predefined names,
it's assumed that it's a class name
parameters xml parameter configurationpublic static final com.google.common.base.Supplier<MolecularDescriptor> newInstanceSupplier(java.lang.String descriptorTypeName)
Supplier
of the specified molecular descriptor.
See newInstance(String)
.public static final MolecularDescriptor newInstance(java.lang.String descriptorTypeName)
descriptorTypeName
- predefined type name or class name
If the name does not match any of the predefined names,
it is assumed to be a class namepublic static final MolecularDescriptor newInstanceFromXML(java.lang.String parameters)
parameters
- XML configuration stringpublic abstract MolecularDescriptor clone()
clone
in class java.lang.Object
public java.lang.String getName()
public java.lang.String getShortName()
public java.lang.String getParametersClassName()
public void setParameters(MDParameters parameters)
MolecularDescriptor
.parameters
- parameter settings of the descriptor to be createdpublic abstract void setParameters(java.lang.String parameters) throws MDParametersException
MolecularDescriptor
.parameters
- parameter settings of the descriptor. If it is null or empty,
then the default settings will be used.MDParametersException
public MDParameters getParameters()
public boolean needsConfig()
public void setScreeningConfiguration(java.lang.String config) throws MDParametersException
config
- screening configuration stringMDParametersException
public abstract byte[] toData()
MolecularDescriptor
instance into an external format that
can be stored in a database.public abstract void fromData(byte[] dbRepr)
MolecularDescriptor
object from its external
(database) representation.dbRepr
- an array generated by toData()
public abstract java.lang.String toString()
MolecularDescriptor
object. This string value is stored in SDfiles, though the use of this
string is not limited to this purpose. Typically, this string is compact,
for instance zero values are not necessarily printed.toString
in class java.lang.Object
public abstract java.lang.String toDecimalString()
MolecularDescriptor
object. This string value contains all values of the descriptor
(including all zeros), values are separated by tabs.public java.lang.String toBinaryString()
MolecularDescriptor
object.public abstract void fromString(java.lang.String descr) throws java.text.ParseException
descr
- descriptor string, previously generated by toString()
java.text.ParseException
public abstract float[] toFloatArray()
MolecularDescriptor
object. This array contains all values of the descriptor
(including all zeros) in the elements of the array.public abstract void fromFloatArray(float[] descr)
descr
- descriptor represented in a float array
(e.g. generated by toFloatArray()
)public java.lang.String[] generate(Molecule m) throws MDGeneratorException
MDGeneratorException
- when failed to generate descriptorpublic java.lang.String[] generate(java.lang.String molRepr) throws MDGeneratorException
molRepr
- String representation of the molecule eg.: smilesMDGeneratorException
- when failed to generate descriptorpublic java.awt.Color[] getAtomSetColors()
getAtomSetColors()
to obtain the current coloring
scheme.
Typically, the coloring scheme is defined in the MDParameters
object associated with the MolecularDescriptor
object.public java.lang.String[] getAtomSetNames()
public int[] getAtomSetIndexes(Molecule m)
MolecularDescriptor
. Prior to this method,
getAtomSetColors()
has to be called to obtain a color array.
This method returns a per atom color index array and the returned
indexes refer to to the color array returned by getAtomSetColors
.m
- a molecule to assign atom colors topublic abstract java.lang.String[] getDissimilarityMetrics()
public abstract float[] getDefaultDissimilarityMetricThresholds()
public int getDissimilarityMetricIndex(java.lang.String metricName) throws java.lang.IllegalArgumentException
metricName
- name of a metricjava.lang.IllegalArgumentException
public int getNumberOfWeights(java.lang.String dissimilarityMetricName) throws java.lang.IllegalArgumentException
MolecularDescriptor
class or its derived classes, but not
to parameterized metric.dissimilarityMetricName
- name as returned by
getDissimilarityMetrics()
java.lang.IllegalArgumentException
- if the given parameter is not a valid
metric namepublic int getNumberOfMetrics()
public int getMetricIndex(java.lang.String metricName) throws java.lang.IllegalArgumentException
metricName
- name of a metricjava.lang.IllegalArgumentException
- when given metric name is not validpublic float getDefaultThreshold(int metricIndex)
metricIndex
- index of a parameterized metricpublic float getThreshold(int metricIndex)
metricIndex
- index of a parameterized metricpublic float getThreshold()
public java.lang.String getMetricName()
public java.lang.String getMetricName(int metricIndex)
metricIndex
- metric indexpublic int getDefaultMetricIndex()
MolecularDescriptor
.public abstract float getDissimilarity(MolecularDescriptor other)
MolecularDescriptor
objects using the default metric.
Default metric is set in the corresponding MDParameters
object.
In the case of asymmetric distances swapping the two descriptors can
make a big difference.other
- a descriptor, to which the dissimilarity ratio is measuredpublic abstract float getDissimilarity(MolecularDescriptor other, int parametrizedMetricIndex)
MolecularDescriptor
objects using the specified metric, apart from that it is the same as
getDissimilarity( final MolecularDescriptor other )
.other
- a descriptor, to which the dissimilarity ratio is measuredparametrizedMetricIndex
- the index of the parameterized metric to usedMDParameters
,
PFParameters
public float getLowerBound(MolecularDescriptor other)
public static void main(java.lang.String[] args)