@PublicAPI public class MDSimilarity extends java.lang.Object implements chemaxon.license.Licensable
Performs similarity comparisons between MDSets
(see MDSet
(for example set of
chemical fingerprints and/or pharmacophore fingerprints). Comparisons may be
performed, when all the query descriptor sets to which molecular descriptor
sets will be compared are added, the metrics to be used are set and filtering
options are also set. If filtering thresholds are applied then they should be
also given.
After a comparison results may be retrieved by calling methods
getDissimilarityCoeff()
or getDissimilarityCoeffs()
.
Typical usage:
MDSimilarity similarity = MDSimilarity(); // Add queries from MDReader similarity.addQueries( queryReader ); // Setup metrics and thresholds for ( int d = 0; d < descriptorCount; d++ ) { for ( int m = 0; m < metricIndices[ d ].length; m++ ) { similarity.useMetric( d, metricIndices[ d ][ m ], thresholds[ d ][ m ]); } } // Setup filtering if ( andMetrics ) similarity.passWithAllMetrics(); else similarity.passWithOneMetric(); if ( andDescriptors ) similarity.passWithAllDescriptors(); else similarity.passWithOneDescriptor(); // Setup result writer (table writer in this case) MDSimilarityTableWriter twr = new MDSimilarityTableWriter( outputStream, precision ); if ( !verboseSet ) { twr.setVerbosity( verbose ); twr.setVerboseFrequency( verboseFreq ); verboseSet = true; } twr.setPrintId( generateId ); if ( idTagName != null ) { twr.setPrintNaturalId( true ); twr.setNaturalIdName( idTagName ); } twr.setPrecision( precision ); similarity.addResultWriter( twr ); // Perform comparisons, results are written into the specified result writer similarity.compare( targetReader );
Constructor and Description |
---|
MDSimilarity()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addQueries(MDReader queryReader)
Adds new query molecules as their set of descriptors from a chemical
descriptor reader.
|
void |
addQueries(MDSet[] queries)
Adds new query molecules as their set of descriptors from an array.
|
void |
addQuery(MDSet query)
Adds a new query molecule as its set of descriptors.
|
void |
addResultWriter(MDSimilarityResultWriter rwr)
Adds a
MDSimilarityResultWriter object. |
boolean |
compare(int mdIndex,
int metricIndex,
MDSet target)
Compares a target descriptor against all queries added prior to the call
of this method using the given metric of the given descriptor.
|
int |
compare(MDReader targetReader)
Compares a list of target descriptor sets (read by a molecular descriptor
reader) against all queries added prior to the call of this method the
same way as
compareQueries( MolecularDescriptor target ) but
for each target. |
boolean |
compare(MDSet target)
Compares a target descriptor set (for instance from a database)
against all queries added prior to the call of this method.
|
float |
getDissimilarityCoeff(int queryIndex,
int mdIndex,
int metricIndex)
Retrieves query dissimilarity coefficients (one at a time) of the last
compareQueries() or compare() method called. |
float[][] |
getDissimilarityCoeffs(int queryIndex)
Retrieves query dissimilarity coefficients with all metrics and one query of
the last
compareQueries() or compare() method
called. |
float[] |
getDissimilarityCoeffs(int queryIndex,
int mdIndex)
Retrieves query dissimilarity coefficients with all metrics and one descriptor of
the last
compareQueries() or compare() method
called. |
int |
getNrOfQueries()
Gets the number of queries that have already been added.
|
int |
getNrOfUsedMetrics(int mdIndex)
Return the number of metrics used with the given molecular descriptor
in similarity calculations.
|
MDSet |
getQuery(int queryIndex)
Gets a query.
|
boolean |
isComponentWise()
Checks the component-wise flag.
|
boolean |
isLicensed() |
boolean |
isPassWithAllDescriptors()
Tells whether filtering of target descriptor sets is set to pass only if
each descriptor in the set passes.
|
boolean |
isPassWithAllMetrics()
Tells whether filtering of target descriptor sets is set to pass only if
dissimilarity calculated with each metric used with the descriptor
is under the required threshold.
|
boolean |
isPassWithOneDescriptor()
Tells whether filtering of target descriptor sets is set to pass if
at least one descriptor in the set passes.
|
boolean |
isPassWithOneMetric()
Tells whether filtering of target descriptor sets is set to pass if
dissimilarity calculated with at least one metric used with the descriptor
is under the required threshold.
|
boolean |
isUsedMetric(int mdIndex,
int metricIndex)
Return if the given metric is used with the given molecular descriptor
in similarity calculations.
|
void |
passWithAllDescriptors()
In the following searches the descriptor set of a target molecule passes the
comparison with a query descriptor set, if all descriptors of
the set have passed the corresponding comparisons.
|
void |
passWithAllMetrics()
In the following searches a target molecule's molecular descriptor
passes the comparison with a corresponding query descriptor,
if all dissimilarity coefficients (distances calculated with each metric)
between these descriptors are under the previously given threshold.
|
void |
passWithOneDescriptor()
In the following searches the descriptor set of a target molecule passes the
comparison with a query descriptor set, if at least one
descriptor of the set have passed the corresponding comparisons.
|
void |
passWithOneMetric()
In the following searches a target molecule's molecular descriptor
passes the comparison with a corresponding query descriptor,
if at least one dissimilarity coefficient between these descriptors is under
the previously given threshold.
|
void |
setComponentWise(boolean componentWise)
Sets
MDSet evaluation mode. |
void |
setLicenseEnvironment(java.lang.String env) |
void |
setThreshold(float threshold)
Sets threshold for descriptor set mode.
|
float |
threshold(int mdIndex,
int metricIndex)
Return the acceptance threshold of the given metric for the given
molecular descriptor.
|
void |
useMetric(int mdIndex,
int metricIndex)
Use the specified metric for the specified molecular descriptor
with the dissimilarity threshold stored in the corresponding parameters
settings.
|
void |
useMetric(int mdIndex,
int metricIndex,
float threshold)
Use the specified metric for the specified molecular descriptor along
with the given dissimilarity threshold.
|
public MDSimilarity()
public void setComponentWise(boolean componentWise)
MDSet
evaluation mode. Default mode is composite
(descriptor set) mode, when one dissimilarity value is calculated for
each descriptor set (using selected/default metrics per components and
calculating the weighted sum of these dissimilairty values). In
component-wise mode each component of a descriptor set yield one
dissimilarity value and these values are kept independent in screening
(ie. they are not summed).componentWise
- indicates component-wise evaluation model]public void addResultWriter(MDSimilarityResultWriter rwr)
MDSimilarityResultWriter
object. A MDSimilarity
instance can have an arbitrary number and type of such
MDSimilarityResultWriter
s and all are envoked (in the same
order as they were added) after each target MDSet
has been
processed.rwr
- a result writer objectpublic void addQuery(MDSet query)
query
- Query descriptor set, it is not cloned.public void addQueries(MDSet[] queries)
queries
- Array of query descriptor sets, it is not cloned.public void addQueries(MDReader queryReader) throws MDReaderException
queryReader
- Molecular descriptor set reader of the queries.MDReaderException
- when failed reading the next descriptor setpublic MDSet getQuery(int queryIndex)
queryIndex
- The index of the query (in order of addition) from 0 to getNrOfQueries() - 1
(both inclusive).public int getNrOfQueries()
public void setThreshold(float threshold)
threshold
- similarity thresholdpublic void useMetric(int mdIndex, int metricIndex, float threshold)
mdIndex
- Index of the molecular descriptor in the set.metricIndex
- Index of the metric.threshold
- Maximum dissimilarity allowed.public void useMetric(int mdIndex, int metricIndex)
mdIndex
- Index of the molecular descriptor in the set.metricIndex
- Index of the metric.public boolean isUsedMetric(int mdIndex, int metricIndex)
mdIndex
- Index of the molecular descriptor in the set.metricIndex
- Index of the metric.public int getNrOfUsedMetrics(int mdIndex)
mdIndex
- Index of the molecular descriptor in the set.public float threshold(int mdIndex, int metricIndex)
mdIndex
- Index of the molecular descriptor in the set.metricIndex
- Index of the metric.public boolean isComponentWise()
public void passWithAllMetrics()
public boolean isPassWithAllMetrics()
public void passWithOneMetric()
public boolean isPassWithOneMetric()
public void passWithAllDescriptors()
public boolean isPassWithAllDescriptors()
public void passWithOneDescriptor()
public boolean isPassWithOneDescriptor()
public boolean compare(int mdIndex, int metricIndex, MDSet target) throws java.lang.RuntimeException
queryDissimilarityCoeffs()
after compareQueries()
is performed. useMetric()
.mdIndex
- Index of the molecular descriptor.metricIndex
- Index of the metric.target
- Target descriptor set.java.lang.RuntimeException
- in case of invalid configurationpublic boolean compare(MDSet target) throws java.lang.RuntimeException
queryDissimilarityCoeffs()
after compareQueries()
is performed. useMetric()
.target
- Target descriptor set.java.lang.RuntimeException
- in case of invalid configurationpublic int compare(MDReader targetReader) throws MDReaderException, java.lang.RuntimeException
compareQueries( MolecularDescriptor target )
but
for each target. MDSimilarityResultWriter
interface. open()
procedure
of MDSimilarityResultWriter
is executed, then after processing
each target the procedure write()
is invoked, after the
processing has ended the procedure close()
is invoked.targetReader
- Reader of target descriptor sets.MDReaderException
- when failed reading the next descriptor setjava.lang.RuntimeException
- in case of invalid configurationpublic float getDissimilarityCoeff(int queryIndex, int mdIndex, int metricIndex)
compareQueries()
or compare()
method called.queryIndex
- Index of the query molecule. Query molecules are
numbered from 0 to nQueries() - 1, in the same order
as added with addQuery().mdIndex
- Index of molecular descriptor component in the set.metricIndex
- Index of the metric.public float[] getDissimilarityCoeffs(int queryIndex, int mdIndex)
compareQueries()
or compare()
method
called.queryIndex
- Index of the query molecule. Query molecules are
numbered from 0 to nQueries() - 1, in the same order
as added with addQuery().mdIndex
- Index of molecular descriptor component in the set.public float[][] getDissimilarityCoeffs(int queryIndex)
compareQueries()
or compare()
method
called.queryIndex
- Index of the query molecule. Query molecules are
numbered from 0 to nQueries() - 1, in the same order
as added with addQuery().public boolean isLicensed()
isLicensed
in interface chemaxon.license.Licensable
public void setLicenseEnvironment(java.lang.String env)
setLicenseEnvironment
in interface chemaxon.license.Licensable