@PublicAPI public class ChemicalFingerprint extends MolecularDescriptor
ChemicalFingerprint
class implements topological fingerprints as a
type of MolecularDescriptor
s. Such fingerprints encode the
topological connection between atoms of the chemical graph. Though such
encoding loses information, still it preserves enough to allow fast
comparisons of chemical structures without their direct structural comparison
but instead involving their topological fingerprints. CFParameters params = new CFParameters( "config.xml" ); CF fp = new CF( params ); // always use an MDSet object, even if it has one component only MDSet ds = new MDSet(); ds.addDescriptor( pfp ); // create an input source reader that takes molecules from a smiles file MDFileReader src = new MDFileReader( "input.smiles" ); src.setIdTagName( "CGX_ID" ); // just an example // process input: get the fingerprints from the input source and do sg while ( src.next( ds ) ) { // scr generates the descriptor! do_something( ds ); } src.close();
Modifier and Type | Field and Description |
---|---|
protected int |
brightness
number of bits set in the fingerprint
(sometimes this is called
the darkness, but that seems to be less pausible)
|
protected int[] |
fp
storage for the fingerprint
|
params
Constructor and Description |
---|
ChemicalFingerprint()
Creates a new, empty instance of ChemicalFingerprint without allocating internal
storage.
|
ChemicalFingerprint(CFParameters params)
Creates a new instance of ChemicalFingerprint according to the parameters given.
|
ChemicalFingerprint(ChemicalFingerprint cfp)
Copy constructor.
|
ChemicalFingerprint(java.lang.String params)
Creates a new instance of ChemicalFingerprint according to the
parameters given.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the fingerprint: sets all bins to store zero value.
|
ChemicalFingerprint |
clone()
Creates a new instance with identical internal state.
|
void |
fromData(byte[] dbRepr)
Builds a fingerprint from an external data format, created by a previous
call to
toData() . |
void |
fromFloatArray(float[] descr)
Builds fingerprint from its float array representation.
|
void |
fromString(java.lang.String cfp)
Builds a fingerprint from its string representation created by
toString() . |
java.lang.String[] |
generate(Molecule m)
Creates the ChemicalFingerprint descriptor for the given Molecule.
|
java.util.List<java.lang.String> |
getAliasNames()
Simple test function for engineering purposes, comment it out from
released version.
|
float |
getAsymmetricEuclidean(ChemicalFingerprint f)
Calculates the asymmetric Euclidean distance.
|
int |
getBrightness()
Gets the brightness of the fingerprint.
|
int |
getCommonBitCount(ChemicalFingerprint f) |
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.
|
float |
getDissimilarity(MolecularDescriptor fp2)
Calculates the dissimilarity between two chemical fingerprints using
the default distance measure.
|
float |
getDissimilarity(MolecularDescriptor fp2,
int metricIndex)
Calculates the dissimilarity between two chemical fingerprints using
the specified distance metric.
|
java.lang.String[] |
getDissimilarityMetrics()
Gets the dissimilarity metric names
|
float |
getEuclidean(ChemicalFingerprint f)
Calculates the Euclidean distance.
|
float |
getLowerBound(java.lang.Object fp2)
Calculates the lower bound estimate of the dissimilarity from the given
fingerprint.
|
java.lang.String |
getName()
Gets the name of the ChemicalFingerprint object.
|
java.lang.String |
getParametersClassName()
Gets the name of the parameters class corresponding to the descriptor.
|
java.lang.String |
getShortName()
Gets the short name of the descriptor.
|
float |
getTanimoto(ChemicalFingerprint f)
Calculates the Tanimoto metric.
|
float |
getTversky(ChemicalFingerprint f)
Calculates the Tversky !!DISSIMILARITY!! index: (1-(commonly used tversky))
|
float |
getWeightedAsymmetricEuclidean(ChemicalFingerprint f)
Calculates the weighted asymmetric Euclidean distance.
|
float |
getWeightedEuclidean(ChemicalFingerprint f)
Calculates the weighted Euclidean distance.
|
boolean |
isSubSetOf(ChemicalFingerprint f)
Checks if this fingerprint is a subset of another fingerprint that is
passed as method parameter.
|
void |
setParameters(MDParameters parameters)
Sets parameters, allocates internal storage if needed and cleans
the descriptor.
|
void |
setParameters(java.lang.String parameters)
Sets the parameters of an already created
ChemicalFingerprint object. |
java.lang.String |
toBinaryString()
Converts the fingerprint into a 0,1 string.
|
byte[] |
toData()
Converts a chemical fingerprint object into a byte array.
|
java.lang.String |
toDecimalString()
Converts the fingerprint into a tab separated string.
|
float[] |
toFloatArray()
Creates the float array representation of the fingerprint.
|
java.lang.String |
toString()
Converts the fingerprint into a readable string.
|
generate, getAtomSetColors, getAtomSetIndexes, getAtomSetNames, getDissimilarityMetricIndex, getLowerBound, getMetricIndex, getMetricName, getMetricName, getNumberOfMetrics, getNumberOfWeights, getParameters, getThreshold, getThreshold, main, needsConfig, newInstance, newInstance, newInstanceFromXML, newInstanceSupplier, setScreeningConfiguration
protected int[] fp
protected int brightness
public ChemicalFingerprint()
public ChemicalFingerprint(CFParameters params)
params
- parameters used in fingerprint generation and handlingpublic ChemicalFingerprint(java.lang.String params)
params
- parameter settingspublic ChemicalFingerprint(ChemicalFingerprint cfp)
CFParameters
object.cfp
- fingerprint to be copiedpublic ChemicalFingerprint clone()
clone
in class MolecularDescriptor
public java.lang.String getName()
getName
in class MolecularDescriptor
public java.lang.String getShortName()
getShortName
in class MolecularDescriptor
public java.lang.String getParametersClassName()
getParametersClassName
in class MolecularDescriptor
public int getBrightness()
public void setParameters(MDParameters parameters)
setParameters
in class MolecularDescriptor
parameters
- fingerprint parameterspublic void setParameters(java.lang.String parameters) throws MDParametersException
ChemicalFingerprint
object.setParameters
in class MolecularDescriptor
parameters
- parameter settings for the descriptorMDParametersException
- any XML errorpublic byte[] toData()
fromData()
method to build the fingerprint from
this "external" representation.toData
in class MolecularDescriptor
public void fromData(byte[] dbRepr)
toData()
.fromData
in class MolecularDescriptor
dbRepr
- "external" representation of ChemicalFingerprintpublic final void clear()
public final java.lang.String toString()
toString
in class MolecularDescriptor
public final java.lang.String toDecimalString()
toDecimalString
in class MolecularDescriptor
public java.lang.String toBinaryString()
toBinaryString
in class MolecularDescriptor
public final void fromString(java.lang.String cfp) throws java.text.ParseException
toString()
.fromString
in class MolecularDescriptor
cfp
- fingerprint stringjava.text.ParseException
public final float[] toFloatArray()
toFloatArray
in class MolecularDescriptor
public void fromFloatArray(float[] descr) throws java.lang.RuntimeException
fromFloatArray
in class MolecularDescriptor
descr
- fingerprint represented in a float array
(e.g. generated by toFloatArray()
)java.lang.RuntimeException
public java.lang.String[] generate(Molecule m) throws MDGeneratorException
MDParameters
class.generate
in class MolecularDescriptor
MDGeneratorException
- when failed to generate descriptorpublic java.lang.String[] getDissimilarityMetrics()
getDissimilarityMetrics
in class MolecularDescriptor
public float[] getDefaultDissimilarityMetricThresholds()
getDefaultDissimilarityMetricThresholds
in class MolecularDescriptor
public int getDefaultMetricIndex()
getDefaultMetricIndex
in class MolecularDescriptor
public float getDefaultThreshold(int metricIndex)
getDefaultThreshold
in class MolecularDescriptor
metricIndex
- index of a parameterized metricpublic int getCommonBitCount(ChemicalFingerprint f)
public float getTanimoto(ChemicalFingerprint f)
f
- the distance from f
is calculatedpublic float getTversky(ChemicalFingerprint f)
f
- the distance from f
is calculatedpublic float getEuclidean(ChemicalFingerprint f)
f
- the distance from f
is calculatedpublic float getWeightedEuclidean(ChemicalFingerprint f)
f
- the distance from f
is calculatedpublic float getAsymmetricEuclidean(ChemicalFingerprint f)
f
- the distance from f
is calculatedpublic float getWeightedAsymmetricEuclidean(ChemicalFingerprint f)
f
- the distance from f
is calculatedpublic float getDissimilarity(MolecularDescriptor fp2)
getDissimilarity
in class MolecularDescriptor
fp2
- the other pahrmacophore fingerprintpublic float getDissimilarity(MolecularDescriptor fp2, int metricIndex)
getMetricIndex
( String metricName )
. getDissimilarity
in class MolecularDescriptor
fp2
- the chemical fingerprint from which the distance
is measuredmetricIndex
- index of the metric to be usedMDParameters
,
PFParameters
public float getLowerBound(java.lang.Object fp2)
ChemicalFingerprint a good estimate for the minimum distance
cannot be obtained efficiently (that is, significantly faster than
calculating the proper distance) therefore 0 is returned. This trivial
distance bound estimation will lead to calling getDistance
.
fp2
- chemical fingerprint from which distance is measuredpublic boolean isSubSetOf(ChemicalFingerprint f)
f
- a descriptor which is supposed to be a supersetpublic java.util.List<java.lang.String> getAliasNames()