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(int aFingerprintSize, Map<Integer,Integer> aPositionToFrequencyMap)
    Initialization of default CountFingerprint.
    CountFingerprint(int aFingerprintSize, Map<Integer,Integer> aPositionToFrequencyMap, boolean aFingerprintBehaviorStatement)
    Initialization of CountFingerprint with a given behavior statement.
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    Public getter for internally used size of given pre-defined fingerprint.
    int
    getHash(int index)
    Public getter for internal map of smiles fingerprint position to corresponding frequency.
    boolean
    hasHash(int hash)
    void
    merge(org.openscience.cdk.fingerprint.ICountFingerprint fp)
    UnsupportedOperationException.
    static org.openscience.cdk.fingerprint.ICountFingerprint
    mergeCountFingerprint(CountFingerprint aFirstCountFingerprintToMerge, CountFingerprint aSecondCountFingerprintToMerge)
    Static method to merge two specified CountFingerprint instances into a NEW CountFingerprint instance created from their combined frequency maps.
    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(int aFingerprintSize, Map<Integer,Integer> aPositionToFrequencyMap) throws NullPointerException, IllegalArgumentException
      Initialization of default 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:
      aFingerprintSize - defines the size of the fingerprint
      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 given size is smaller than one.
    • CountFingerprint

      public CountFingerprint(int aFingerprintSize, Map<Integer,Integer> aPositionToFrequencyMap, boolean aFingerprintBehaviorStatement) throws NullPointerException, IllegalArgumentException
      Initialization of CountFingerprint with a given behavior statement.
      Parameters:
      aFingerprintSize - defines the size of the fingerprint
      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.
      aFingerprintBehaviorStatement - defines whether CountFingerprint should behave ass BitFingerprint
      Throws:
      NullPointerException - is thrown if the arguments are null.
      IllegalArgumentException - is thrown if the given size is smaller than one.
  • 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)
      Specified by:
      getHash in interface org.openscience.cdk.fingerprint.ICountFingerprint
      Throws:
      UnsupportedOperationException - as the fingerprint is not a hash fingerprint
    • 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
      Specified by:
      hasHash in interface org.openscience.cdk.fingerprint.ICountFingerprint
      Throws:
      UnsupportedOperationException - due to not being a hash fingerprint.
      IllegalArgumentException
    • 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:
    • mergeCountFingerprint

      public static org.openscience.cdk.fingerprint.ICountFingerprint mergeCountFingerprint(CountFingerprint aFirstCountFingerprintToMerge, CountFingerprint aSecondCountFingerprintToMerge) throws NullPointerException, IllegalArgumentException
      Static method to merge two specified CountFingerprint instances into a NEW CountFingerprint instance created from their combined frequency maps. Neither param fingerprints are changed when merged. Merging is only supported (and recommended) for fingerprints generated from the same (sub)set of fragments.
      Parameters:
      aFirstCountFingerprintToMerge - First CountFingerprint instance to merge
      aSecondCountFingerprintToMerge - Second CountFingerprint instance to merge
      Returns:
      new ICountFingerprint with combined occurrence frequencies
      Throws:
      NullPointerException - if either given fingerprint is null
      IllegalArgumentException - if defined fingerprint size does not match between given fingerprints
    • getSmilesPositionToFrequencyMap

      public Map<Integer,Integer> getSmilesPositionToFrequencyMap()
      Public getter for internal map of smiles fingerprint position to corresponding frequency.
      Returns:
      Mapping of smiles fingerprint position to frequency
    • getDefinedFingerprintSize

      public int getDefinedFingerprintSize()
      Public getter for internally used size of given pre-defined fingerprint.
      Returns:
      int of defined fingerprint size