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
ConstructorsConstructorDescriptionCountFingerprint(String[] anArrayOfFragments, HashMap<Integer, Integer> aPositionToFrequencyMap) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintMethod returns the frequency in the count fingerprint for a given SMILES string.intgetCount(int index) For an index specified within the fingerprint size, the corresponding frequency is returned.intgetCountForHash(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.intgetHash(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).booleanhasHash(int hash) The parameter hash is not a calculated hash value, but also corresponds to the position of the bin in the fingerprint.voidmerge(org.openscience.cdk.fingerprint.ICountFingerprint fp) UnsupportedOperationException.mergedCountFingerprint(CountFingerprint aCountFingerprint) Method for merging the given fingerprint fp into a current fingerprint.intFragment fingerprints are key-based fingerprints, therefore the number of populated bins corresponds to the number of predefined fragments (unique SMILES).voidsetBehaveAsBitFingerprint(boolean behaveAsBitFingerprint) longsize()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.
-
Constructor Details
-
CountFingerprint
public CountFingerprint(String[] anArrayOfFragments, HashMap<Integer, Integer> aPositionToFrequencyMap) throws NullPointerException, IllegalArgumentExceptionConstructor. 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:
sizein interfaceorg.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:
numOfPopulatedbinsin interfaceorg.openscience.cdk.fingerprint.ICountFingerprint
-
getCount
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:
getCountin interfaceorg.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:
getHashin interfaceorg.openscience.cdk.fingerprint.ICountFingerprint
-
merge
public void merge(org.openscience.cdk.fingerprint.ICountFingerprint fp) UnsupportedOperationException. This method is not supported.- Specified by:
mergein interfaceorg.openscience.cdk.fingerprint.ICountFingerprint- Throws:
UnsupportedOperationException- method is not supported
-
setBehaveAsBitFingerprint
public void setBehaveAsBitFingerprint(boolean behaveAsBitFingerprint) - Specified by:
setBehaveAsBitFingerprintin interfaceorg.openscience.cdk.fingerprint.ICountFingerprint
-
hasHash
The parameter hash is not a calculated hash value, but also corresponds to the position of the bin in the fingerprint.- Specified by:
hasHashin interfaceorg.openscience.cdk.fingerprint.ICountFingerprint- Throws:
IllegalArgumentException- is thrown if the given hash value is negative.
-
getCountForHash
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:
getCountForHashin interfaceorg.openscience.cdk.fingerprint.ICountFingerprint- Throws:
IllegalArgumentException- is thrown if the given hash value do not exist in the fingerprint.- See Also:
-
count
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
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.
-