Class CountFingerprint

java.lang.Object
de.unijena.cheminf.fragment.fingerprint.CountFingerprint
All Implemented Interfaces:
Serializable, org.openscience.cdk.fingerprint.ICountFingerprint

public class CountFingerprint extends Object implements org.openscience.cdk.fingerprint.ICountFingerprint
The CountFingerprint class implements the CDK interface ICountFingerprint. ICountFingerprint provides useful methods to obtain information about the calculated count fingerprint. Instead of using the IntArrayCountFingerprint that implements the CDK interface ICountFingerprint, a new CountFingerprint class has been created here that also implements the ICountFingerprint interface. The IntArrayCountFingerprint class assumes hashed count fingerprints, while here they are key-based count fingerprints, so it is necessary to create the CountFingerprint class to treat the fingerprints as key-based fingerprints.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CountFingerprint(String[] anArrayOfFragments, HashMap<Integer,Integer> aPositionToFrequencyMap)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    count(String aSmiles)
    Method returns the frequency in the count fingerprint for a given SMILES string.
    int
    getCount(int index)
    For an index specified within the fingerprint size, the corresponding frequency is returned.
    int
    getCountForHash(int hash)
    Since the fragment fingerprint is a key-based fingerprint and the hash value therefore indicates the position of the respective bin in the fingerprint, each hash value occurs only once in the fingerprint.
    int
    getHash(int index)
    Since this is a key-based fingerprint, the hash value is the position of the bin in the fingerprint (no hash value is calculated).
    boolean
    hasHash(int hash)
    The parameter hash is not a calculated hash value, but also corresponds to the position of the bin in the fingerprint.
    void
    merge(org.openscience.cdk.fingerprint.ICountFingerprint fp)
    UnsupportedOperationException.
    Method for merging the given fingerprint fp into a current fingerprint.
    int
    Fragment fingerprints are key-based fingerprints, therefore the number of populated bins corresponds to the number of predefined fragments (unique SMILES).
    void
    setBehaveAsBitFingerprint(boolean behaveAsBitFingerprint)
    long
    Since fragment fingerprints are key-based, the number of bits in the fingerprint is equal to the number of predefined fragments (unique SMILES) if the list of key fragments passed during initialization does not contain duplicates, otherwise the size of the fingerprint may be smaller than the number of fragments passed since duplicates are removed/ignored.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CountFingerprint

      public CountFingerprint(String[] anArrayOfFragments, HashMap<Integer,Integer> aPositionToFrequencyMap) throws NullPointerException, IllegalArgumentException
      Constructor. Initialization of CountFingerprint. The specified parameters are checked for validity. Duplicate fragment SMILES (key fragments) in the given array will be ignored and not be a part of the count fingerprint multiple times.
      Parameters:
      anArrayOfFragments - is a string array that stores all predefined (key) fragments, which are in the form of unique SMILES. The generation of the fingerprints is based on these fragments.
      aPositionToFrequencyMap - This map is a raw map and must map the positions of key fragments in the fingerprint to their frequencies in the molecule or any set of fragments.
      Throws:
      NullPointerException - is thrown if the arguments are null.
      IllegalArgumentException - is thrown if the list anArrayOfFragments contains blank/empty strings.
  • Method Details

    • size

      public long size()
      Since fragment fingerprints are key-based, the number of bits in the fingerprint is equal to the number of predefined fragments (unique SMILES) if the list of key fragments passed during initialization does not contain duplicates, otherwise the size of the fingerprint may be smaller than the number of fragments passed since duplicates are removed/ignored.
      Specified by:
      size in interface org.openscience.cdk.fingerprint.ICountFingerprint
    • numOfPopulatedbins

      public int numOfPopulatedbins()
      Fragment fingerprints are key-based fingerprints, therefore the number of populated bins corresponds to the number of predefined fragments (unique SMILES). If the list of key fragments passed during initialization does not contain duplicates, otherwise the size of the fingerprint may be smaller than the number of fragments passed since duplicates are removed/ignored.
      Specified by:
      numOfPopulatedbins in interface org.openscience.cdk.fingerprint.ICountFingerprint
    • getCount

      public int getCount(int index) throws IllegalArgumentException
      For an index specified within the fingerprint size, the corresponding frequency is returned. If the given index is greater than the size of the fingerprint or a negative value, an IllegalArgumentException is thrown. The size of the fingerprint corresponds to the number of predefined fragments passed during initialization. However, if duplicates are included, they are ignored and are not a part of the fingerprint multiple times. The size of the fingerprint in this case is then different from the number of predefined fragments.
      Specified by:
      getCount in interface org.openscience.cdk.fingerprint.ICountFingerprint
      Throws:
      IllegalArgumentException - is thrown if the given index does not exist in the fingerprint.
    • getHash

      public int getHash(int index)
      Since this is a key-based fingerprint, the hash value is the position of the bin in the fingerprint (no hash value is calculated).
      Specified by:
      getHash in interface org.openscience.cdk.fingerprint.ICountFingerprint
    • merge

      public void merge(org.openscience.cdk.fingerprint.ICountFingerprint fp)
      UnsupportedOperationException. This method is not supported.
      Specified by:
      merge in interface org.openscience.cdk.fingerprint.ICountFingerprint
      Throws:
      UnsupportedOperationException - method is not supported
    • setBehaveAsBitFingerprint

      public void setBehaveAsBitFingerprint(boolean behaveAsBitFingerprint)
      Specified by:
      setBehaveAsBitFingerprint in interface org.openscience.cdk.fingerprint.ICountFingerprint
    • hasHash

      public boolean hasHash(int hash) throws IllegalArgumentException
      The parameter hash is not a calculated hash value, but also corresponds to the position of the bin in the fingerprint.
      Specified by:
      hasHash in interface org.openscience.cdk.fingerprint.ICountFingerprint
      Throws:
      IllegalArgumentException - is thrown if the given hash value is negative.
    • getCountForHash

      public int getCountForHash(int hash) throws IllegalArgumentException
      Since the fragment fingerprint is a key-based fingerprint and the hash value therefore indicates the position of the respective bin in the fingerprint, each hash value occurs only once in the fingerprint. Therefore, the method returns the frequency of the fragment in the specified bin.
      Specified by:
      getCountForHash in interface org.openscience.cdk.fingerprint.ICountFingerprint
      Throws:
      IllegalArgumentException - is thrown if the given hash value do not exist in the fingerprint.
      See Also:
    • count

      public int count(String aSmiles) throws IllegalArgumentException
      Method returns the frequency in the count fingerprint for a given SMILES string.
      Parameters:
      aSmiles - SMILES String for which the frequency is to be returned. These SMILES should represent a key fragment.
      Returns:
      int count value
      Throws:
      IllegalArgumentException - is thrown if the given SMILES string is not a key fragment.
    • mergedCountFingerprint

      public CountFingerprint mergedCountFingerprint(CountFingerprint aCountFingerprint)
      Method for merging the given fingerprint fp into a current fingerprint. Merging is intended only for count fingerprints generated from the same fragment set.
      Parameters:
      aCountFingerprint - to be merged
      Returns:
      CountFingerprint, i.e. a merged count fingerprint.