Class Tanimoto

java.lang.Object
org.openscience.cdk.similarity.Tanimoto

public class Tanimoto extends Object
Calculates the Tanimoto coefficient for a given pair of two fingerprint bitsets or real valued feature vectors. The Tanimoto coefficient is one way to quantitatively measure the "distance" or similarity of two chemical structures.

You can use the FingerPrinter class to retrieve two fingerprint bitsets. We assume that you have two structures stored in cdk.Molecule objects. A tanimoto coefficient can then be calculated like:

   BitSet fingerprint1 = Fingerprinter.getBitFingerprint(molecule1);
   BitSet fingerprint2 = Fingerprinter.getBitFingerprint(molecule2);
   float tanimoto_coefficient = Tanimoto.calculate(fingerprint1, fingerprint2);
  

The FingerPrinter assumes that hydrogens are explicitely given, if this is desired!

Note that the continuous Tanimoto coefficient does not lead to a metric space

Author:
steinbeck
Keywords:
jaccard, similarity, tanimoto
Created on:
2005-10-19
  • Field Details

  • Method Details

    • calculate

      public static float calculate(BitSet bitset1, BitSet bitset2) throws CDKException
      Evaluates Tanimoto coefficient for two bit sets.

      Parameters:
      bitset1 - A bitset (such as a fingerprint) for the first molecule
      bitset2 - A bitset (such as a fingerprint) for the second molecule
      Returns:
      The Tanimoto coefficient
      Throws:
      CDKException - if bitsets are not of the same length
    • calculate

      public static double calculate(IBitFingerprint fingerprint1, IBitFingerprint fingerprint2)
      Evaluates Tanimoto coefficient for two IBitFingerprint.

      Parameters:
      fingerprint1 - fingerprint for the first molecule
      fingerprint2 - fingerprint for the second molecule
      Returns:
      The Tanimoto coefficient
      Throws:
      IllegalArgumentException - if bitsets are not of the same length
    • calculate

      public static float calculate(double[] features1, double[] features2) throws CDKException
      Evaluates the continuous Tanimoto coefficient for two real valued vectors.

      Parameters:
      features1 - The first feature vector
      features2 - The second feature vector
      Returns:
      The continuous Tanimoto coefficient
      Throws:
      CDKException - if the features are not of the same length
    • calculate

      public static float calculate(Map<String,Integer> features1, Map<String,Integer> features2)
      Evaluate continuous Tanimoto coefficient for two feature, count fingerprint representations.

      Note that feature/count type fingerprints may be of different length. Uses Tanimoto method from 10.1021/ci800326z

      Parameters:
      features1 - The first feature map
      features2 - The second feature map
      Returns:
      The Tanimoto coefficient
    • calculate

      public static double calculate(ICountFingerprint fp1, ICountFingerprint fp2)
      Evaluate continuous Tanimoto coefficient for two feature, count fingerprint representations.

      Note that feature/count type fingerprints may be of different length. Uses Tanimoto method from 10.1021/ci800326z

      Parameters:
      fp1 - The first fingerprint
      fp2 - The second fingerprint
      Returns:
      The Tanimoto coefficient
      See Also:
    • method1

      public static double method1(ICountFingerprint fp1, ICountFingerprint fp2)
      Calculates Tanimoto distance for two count fingerprints using method 1. The feature/count type fingerprints may be of different length. Uses Tanimoto method from [Andreas Steffen, Thierry Kogej, Christian Tyrchan and Ola Engkvist. J. Chem. Inf. Model.. 2009. 49].
      Parameters:
      fp1 - count fingerprint 1
      fp2 - count fingerprint 2
      Returns:
      a Tanimoto distance
    • method2

      public static double method2(ICountFingerprint fp1, ICountFingerprint fp2)
      Calculates Tanimoto distance for two count fingerprints using method 2 [J.A. Grant, J.A. Haigh, B.T. Pickup, A. Nicholls and R.A. Sayle. J. Chem. Inf. Model.. 2006. 46].
      Parameters:
      fp1 - count fingerprint 1
      fp2 - count fingerprint 2
      Returns:
      a Tanimoto distance