chemfp.cdk_types module¶
This module should not be imported directly.
It contains internal implementation details of CDK fingerprint generation.
This module is included in the documentation because parts of this module are returned to the user, and are part of the public API.
- class chemfp.cdk_types.CDKAtomPairs2DFingerprintType_v20(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s implementation of the atom pairs fingerprint from Yap Chun Wei’s PaDEL.
The CDK-AtomPairs2D/2.0
FingerprintType
takes no parameters.This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-AtomPairs2D/2.0'¶
the fingerprint name
- num_bits: int = 780¶
- class chemfp.cdk_types.CDKBaseFingerprintType(fingerprint_kwargs)¶
Bases:
ThreadsafeFingerprinterMixin
,FingerprintType
- fingerprinter_can_fail: bool = True¶
a CDK fingerprinter can raise an exception if the molecule isn’t correctly prepared
- from_inchi(content: str | bytes, *, delimiter: Literal['to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', ' ', '\t'] | None = 'to-eol', errors: str = 'strict')¶
Generate a fingerprint from an InChI string and its id
This is equivalent to calling:
mol = fptype.toolkit.parse_inchi(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
delimiter (One of None, 'to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', or the space or tab characters (default: "to-eol")) – The separator between the SMILES and the id
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- from_inchistring(content: str | bytes, *, delimiter: Literal['to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', ' ', '\t'] | None = 'to-eol', errors: str = 'strict')¶
Generate a fingerprint from an InChI string
This is equivalent to calling:
mol = fptype.toolkit.parse_inchistring(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
delimiter (One of None, 'to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', or the space or tab characters (default: "to-eol")) – The separator between the SMILES and the id
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- from_molfile(content: str | bytes, *, AddStereo0d: bool = True, AddStereoElements: bool = True, InterpretHydrogenIsotopes: bool = True, ForceReadAs3DCoordinates: bool = False, mode: Literal['RELAXED', 'STRICT'] = 'RELAXED', hydrogens: Literal['as-is', 'make-explicit', 'make-implicit', 'make-nonchiral-implicit'] = 'as-is', implementation: Literal['cdk', 'chemfp'] | None = 'cdk', errors: str = 'strict')¶
Generate a fingerprint from a molfile record
This is equivalent to calling:
mol = fptype.toolkit.parse_molfile(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
AddStereo0d (Boolean (default: True)) – if true, create stereo from parity value when no coordinates
AddStereoElements (Boolean (default: True)) – if true, detect and create IStereoElements
InterpretHydrogenIsotopes (Boolean (default: True)) – if true, interpret D and T as hydrogen isotopes
ForceReadAs3DCoordinates (Boolean (default: False)) – if true, always interpret coordinates as 3D
mode ('RELAXED' will attempt to recover, 'STRICT' will not) – strictness mode when parsing a record
hydrogens (One of 'as-is', 'make-explicit', 'make-implicit', or 'make-nonchiral-implicit' (default: "as-is")) – Specify how to handle implicit or explicit hydrogens
implementation (either 'cdk' or 'chemfp') – use CDK or chemfp to identify records
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- from_sdf(content: str | bytes, *, AddStereo0d: bool = True, AddStereoElements: bool = True, InterpretHydrogenIsotopes: bool = True, ForceReadAs3DCoordinates: bool = False, mode: Literal['RELAXED', 'STRICT'] = 'RELAXED', hydrogens: Literal['as-is', 'make-explicit', 'make-implicit', 'make-nonchiral-implicit'] = 'as-is', implementation: Literal['cdk', 'chemfp'] | None = 'cdk', errors: str = 'strict')¶
Generate a fingerprint from an SDF record
This is equivalent to calling:
mol = fptype.toolkit.parse_sdf(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
AddStereo0d (Boolean (default: True)) – if true, create stereo from parity value when no coordinates
AddStereoElements (Boolean (default: True)) – if true, detect and create IStereoElements
InterpretHydrogenIsotopes (Boolean (default: True)) – if true, interpret D and T as hydrogen isotopes
ForceReadAs3DCoordinates (Boolean (default: False)) – if true, always interpret coordinates as 3D
mode ('RELAXED' will attempt to recover, 'STRICT' will not) – strictness mode when parsing a record
hydrogens (One of 'as-is', 'make-explicit', 'make-implicit', or 'make-nonchiral-implicit' (default: "as-is")) – Specify how to handle implicit or explicit hydrogens
implementation (either 'cdk' or 'chemfp') – use CDK or chemfp to identify records
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- from_smi(content: str | bytes, *, has_header: bool = False, delimiter: Literal['to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', ' ', '\t'] | None = 'to-eol', implementation: Literal['cdk', 'chemfp'] | None = 'cdk', kekulise: bool = True, cxsmiles: bool = True, hydrogens: Literal['as-is', 'make-explicit', 'make-implicit', 'make-nonchiral-implicit'] = 'as-is', errors: str = 'strict')¶
Generate a fingerprint from a SMILES string and its id
This is equivalent to calling:
mol = fptype.toolkit.parse_smi(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
has_header (Boolean (default: False)) – If true, treat the first line of the SMILES file as a header
delimiter (One of None, 'to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', or the space or tab characters (default: "to-eol")) – The separator between the SMILES and the id
implementation (either 'cdk' or 'chemfp') – use CDK or chemfp to identify records
kekulise (Boolean (default: True)) – if true, ensure a valid Kekule intepretation exists
cxsmiles (Boolean (default: True)) – If true, look for ChemAxon CXSMILES extensions after the SMILES string (only works with ‘chemfp’ implementation)
hydrogens (One of 'as-is', 'make-explicit', 'make-implicit', or 'make-nonchiral-implicit' (default: "as-is")) – Specify how to handle implicit or explicit hydrogens
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- from_smiles(content: str | bytes, *, kekulise: bool = True, cxsmiles: bool = True, hydrogens: Literal['as-is', 'make-explicit', 'make-implicit', 'make-nonchiral-implicit'] = 'as-is', errors: str = 'strict')¶
Generate a fingerprint from a SMILES string
This is equivalent to calling:
mol = fptype.toolkit.parse_smistring(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
kekulise (Boolean (default: True)) – if true, ensure a valid Kekule intepretation exists
cxsmiles (Boolean (default: True)) – If true, look for ChemAxon CXSMILES extensions after the SMILES string
hydrogens (One of 'as-is', 'make-explicit', 'make-implicit', or 'make-nonchiral-implicit' (default: "as-is")) – Specify how to handle implicit or explicit hydrogens
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- from_smistring(content: str | bytes, *, kekulise: bool = True, cxsmiles: bool = True, hydrogens: Literal['as-is', 'make-explicit', 'make-implicit', 'make-nonchiral-implicit'] = 'as-is', errors: str = 'strict')¶
Generate a fingerprint from a SMILES string
This is equivalent to calling:
mol = fptype.toolkit.parse_smistring(content, ..., errors=errors) fp = fptype.from_mol(mol) if (mol is not None) else None
- Parameters:
kekulise (Boolean (default: True)) – if true, ensure a valid Kekule intepretation exists
cxsmiles (Boolean (default: True)) – If true, look for ChemAxon CXSMILES extensions after the SMILES string
hydrogens (One of 'as-is', 'make-explicit', 'make-implicit', or 'make-nonchiral-implicit' (default: "as-is")) – Specify how to handle implicit or explicit hydrogens
errors (one of "strict", "ignore", or "log") – specify how to handle errors
- Returns:
a fingerprint byte string
- module = <module 'chemfp.cdk_toolkit>'¶
- software: _OptionalStr = ...¶
a description of the CDK and chemfp versions
- class chemfp.cdk_types.CDKDaylightFingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s Daylight-like fingerprint, version 2.0
The CDK-Daylight/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
searchDepth - maximum path length (default: 7)
pathLimit - maximum number of paths (default: 42000)
hashPseudoAtoms - include pseudo-atoms in the hash calculation (default: 0)
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-Daylight/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKECFP0FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the ECFP0 fingerprint, version 2.0
The CDK-ECFP0/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-ECFP0/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKECFP2FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the ECFP2 fingerprint, version 2.0
The CDK-ECFP2/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-ECFP2/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKECFP4FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the ECFP4 fingerprint, version 2.0
The CDK-ECFP4/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-ECFP4/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKECFP6FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the ECFP6 fingerprint, version 2.0
The CDK-ECFP6/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-ECFP6/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKEStateFingerprintType_v20(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s implementation of the EState fingerprint, version 2.0
The CDK-EState/2.0 fingerprints have no parameters.
This fingerprinter requires fully implicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-implicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-EState/2.0'¶
the fingerprint name
- num_bits: int = 79¶
- class chemfp.cdk_types.CDKExtendedFingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s Extended fingerprint, version 2.0
This extends the DaylightFingerprinter with 25 additional bits describing ring features and isotopic masses.
The CDK-Extended/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
searchDepth - maximum path length (default: 7)
pathLimit - maximum number of paths (default: 42000)
hashPseudoAtoms - include pseudo-atoms in the hash calculation (default: 0)
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-Extended/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKFCFP0FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the FCFP0 fingerprint, version 2.0
The CDK-FCFP0/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-FCFP0/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKFCFP2FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the FCFP2 fingerprint, version 2.0
The CDK-FCFP2/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-FCFP2/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKFCFP4FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the FCFP4 fingerprint, version 2.0
The CDK-FCFP4/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-FCFP4/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKFCFP6FingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s implementation of the FCFP6 fingerprint, version 2.0
The CDK-FCFP6/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
perceiveStereochemistry - if True, re-perceive stereochemistry from 2D/3D coordinates
- name: str = 'CDK-FCFP6/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKGraphOnlyFingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s GraphOnly fingerprint, version 2.0
This is a variant of the DaylightFingerprinter which does not take bond orders into account.
The CDK-GraphOnly/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
searchDepth - maximum path length (default: 7)
pathLimit - maximum number of paths (default: 42000)
hashPseudoAtoms - include pseudo-atoms in the hash calculation (default: 0)
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-GraphOnly/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKHybridizationFingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s Hybridization fingerprint, version 2.0
This is a variant of the DaylightFingerprinter which ignores aromaticity but instead takes into account SP2 hybridization.
The CDK-Hybridization/2.0
FingerprintType
parameters are:size - the number of bits in the fingerprint (default: 1024)
searchDepth - maximum path length (default: 7)
pathLimit - maximum number of paths (default: 42000)
hashPseudoAtoms - include pseudo-atoms in the hash calculation (default: 0)
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-Hybridization/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKKlekotaRothFingerprintType_v20(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s implementation of the Klekota-Roth fingerprints
The CDK-KlekotaRoth/2.0 fingerprints have no parameters.
- name: str = 'CDK-KlekotaRoth/2.0'¶
the fingerprint name
- num_bits: int = 4860¶
- class chemfp.cdk_types.CDKMACCSFingerprintType_v20(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s implementation of the 166 MACCS keys, version 2.0
The CDK-MACCS/2.0 fingerprints have no parameters.
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-MACCS/2.0'¶
the fingerprint name
- num_bits: int = 166¶
- class chemfp.cdk_types.CDKPubchemFingerprintType_v20(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s implementation of the PubChem fingerprints
This is generated by CDK versions up to and including 2.8.
The CDK-Pubchem/2.0 fingerprints have no parameters.
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
Note that the PubChem fingerprinter in CDK 2.9 and later does not require explicit hydrogens.
- name: str = 'CDK-Pubchem/2.0'¶
the fingerprint name
- num_bits: int = 881¶
- class chemfp.cdk_types.CDKPubchemFingerprintType_v29(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s implementation of the PubChem fingerprints
This is generated by CDK versions 2.9 and later. Quoting the release notes:
“Explicit hydrogens are not longer required and there is an option to use a more correct ring set definition matching closer the original CACTVS substructure keys.”
The CDK-Pubchem/2.9 fingerprints have no parameters.
(The underlying CDK fingerprinter has an option, ‘esssr’, to use the older and less correct ring set definition, but I cannot think of a reason for chemfp to support it, even after dicussion with one of the CDK authors.)
- name: str = 'CDK-Pubchem/2.9'¶
the fingerprint name
- num_bits: int = 881¶
- class chemfp.cdk_types.CDKShortestPathFingerprintType_v20(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s ShortestPath fingerprint, version 2.0
Calculate a fingerprint based on the shortest paths between two atoms.
The CDK-ShortestPath/2.0
FingerprintType
parameter is:size - the number of bits in the fingerprint (default: 1024)
This is generated by CDK versions older than 2.7.
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- fingerprinter_can_fail: bool = True¶
a CDK fingerprinter can raise an exception if the molecule isn’t correctly prepared
- name: str = 'CDK-ShortestPath/2.0'¶
the fingerprint name
- class chemfp.cdk_types.CDKShortestPathFingerprintType_v27(fingerprint_kwargs)¶
Bases:
VariableSizeFingerprint
CDK’s ShortestPath fingerprint, version 2.7
Calculate a fingerprint based on the shortest paths between two atoms.
The CDK-ShortestPath/2.7
FingerprintType
parameter is:size - the number of bits in the fingerprint (default: 1024)
This version is new in CDK 2.7, where the internal PRNG was changed from a Mersenne Twister to XorShift, resulting in a different bit pattern.
This fingerprinter requires explicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-explicit” to convert any implicit hydrogens to explicit.
- fingerprinter_can_fail: bool = True¶
a CDK fingerprinter can raise an exception if the molecule isn’t correctly prepared
- name: str = 'CDK-ShortestPath/2.7'¶
the fingerprint name
- class chemfp.cdk_types.CDKSubstructureFingerprintType_v20(fingerprint_kwargs: Dict[str, Any])¶
Bases:
NoFingerprintParametersMixin
,FixedSizeFingerprint
CDK’s Substructure key fingerprints
The CDK-Substructure/2.0 fingerprints have no parameters.
This fingerprinter requires fully implicit hydrogens. When using chemfp to read a SMILES or SDF, set the “hydrogens” reader argument to “make-implicit” to convert any implicit hydrogens to explicit.
- name: str = 'CDK-Substructure/2.0'¶
the fingerprint name
- num_bits: int = 307¶