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(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 TypeMethodDescriptionintgetCount(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.intPublic getter for internally used size of given pre-defined fingerprint.intgetHash(int index) Public getter for internal map of smiles fingerprint position to corresponding frequency.booleanhasHash(int hash) voidmerge(org.openscience.cdk.fingerprint.ICountFingerprint fp) UnsupportedOperationException.static org.openscience.cdk.fingerprint.ICountFingerprintmergeCountFingerprint(CountFingerprint aFirstCountFingerprintToMerge, CountFingerprint aSecondCountFingerprintToMerge) Static method to merge two specified CountFingerprint instances into a NEW CountFingerprint instance created from their combined frequency maps.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(int aFingerprintSize, Map<Integer, Integer> aPositionToFrequencyMap) throws NullPointerException, IllegalArgumentExceptionInitialization 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 fingerprintaPositionToFrequencyMap- 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, IllegalArgumentExceptionInitialization of CountFingerprint with a given behavior statement.- Parameters:
aFingerprintSize- defines the size of the fingerprintaPositionToFrequencyMap- 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:
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) - Specified by:
getHashin interfaceorg.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:
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
- Specified by:
hasHashin interfaceorg.openscience.cdk.fingerprint.ICountFingerprint- Throws:
UnsupportedOperationException- due to not being a hash fingerprint.IllegalArgumentException
-
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:
-
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 mergeaSecondCountFingerprintToMerge- Second CountFingerprint instance to merge- Returns:
- new ICountFingerprint with combined occurrence frequencies
- Throws:
NullPointerException- if either given fingerprint is nullIllegalArgumentException- if defined fingerprint size does not match between given fingerprints
-
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
-