chemfp.openbabel_types module

This module should not be imported directly.

It contains internal implementation details of Open Babel 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.openbabel_types.OpenBabelBaseFingerprintType(fingerprint_kwargs: Dict[str, Any])

Bases: FingerprintType

from_inchi(content: str | bytes, *, options: str | None = None, delimiter: Literal['to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', ' ', '\t'] | None = None, 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:
  • options (string or None) – options string passed to Open Babel

  • delimiter (One of None, 'to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', or the space or tab characters (default: None)) – 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, *, options: str | None = None, 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:
  • options (string or None) – options string passed to Open Babel

  • errors (one of "strict", "ignore", or "log") – specify how to handle errors

Returns:

a fingerprint byte string

from_sdf(content: str | bytes, *, implementation: Literal[None, 'openbabel', 'chemfp'] = 'openbabel', perceive_stereo: bool = False, perceive_0d_stereo: bool = False, options: str | None = None, 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:
  • implementation (None or 'openbabel' to use Open Babel, else 'chemfp' (default: "openbabel")) – SDF record tokenizer implementation

  • perceive_stereo (Boolean (default: False)) – not implemented

  • perceive_0d_stereo (Boolean (default: False)) – not implemented

  • options (string or None) – options string passed to Open Babel

  • errors (one of "strict", "ignore", or "log") – specify how to handle errors

Returns:

a fingerprint byte string

from_smi(content: str | bytes, *, options: str | None = None, cxsmiles: bool = True, delimiter: Literal['to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', ' ', '\t'] | None = None, has_header: bool = False, 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:
  • options (string or None) – options string passed to Open Babel

  • cxsmiles (Boolean (default: True)) – If true, strip CXSMILES extension before processing. Open Babel does not support CXSMILES.

  • delimiter (One of None, 'to-eol', 'space', 'tab', 'comma', 'whitespace', 'native', or the space or tab characters (default: None)) – The separator between the SMILES and the id

  • has_header (Boolean (default: False)) – If true, treat the first line of the SMILES file as a header

  • errors (one of "strict", "ignore", or "log") – specify how to handle errors

Returns:

a fingerprint byte string

from_smiles(content: str | bytes, *, options: str | None = None, cxsmiles: bool = True, 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:
  • options (string or None) – options string passed to Open Babel

  • cxsmiles (Boolean (default: True)) – If true, strip CXSMILES extension before processing. Open Babel does not support CXSMILES.

  • errors (one of "strict", "ignore", or "log") – specify how to handle errors

Returns:

a fingerprint byte string

from_smistring(content: str | bytes, *, options: str | None = None, cxsmiles: bool = True, 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:
  • options (string or None) – options string passed to Open Babel

  • cxsmiles (Boolean (default: True)) – If true, strip CXSMILES extension before processing. Open Babel does not support CXSMILES.

  • errors (one of "strict", "ignore", or "log") – specify how to handle errors

Returns:

a fingerprint byte string

module = <module 'chemfp.openbabel_toolkit>'
software: _OptionalStr = ...

a description of the Open Babel and chemfp software packages used

class chemfp.openbabel_types.OpenBabelBaseMACCSFingerprintType(fingerprint_kwargs: Dict[str, Any])

Bases: NoFingerprintParametersMixin, OpenBabelBaseFingerprintType

make_fingerprinter()

Make a ‘fingerprinter’; a callable which takes a molecule and returns a fingerprint

Returns:

a function object which takes a molecule and return a fingerprint

num_bits: int = 166
class chemfp.openbabel_types.OpenBabelECFP0FingerprintType_v1(fingerprint_kwargs)

Bases: OpenBabelECFPBaseFingerprintType

Open Babel’s implementation of the ECFP0 fingerprint

This is a circular fingerprint of diameter 0.

The OpenBabel-ECFP0/1 FingerprintType parameter is:

  • nBits - the number of bits in the fingerprint (default: 4096 and

    must be a power of 2)

is_available = False
name: str = 'OpenBabel-ECFP0/1'

the fingerprint name

class chemfp.openbabel_types.OpenBabelECFP10FingerprintType_v1(fingerprint_kwargs)

Bases: OpenBabelECFPBaseFingerprintType

Open Babel’s implementation of the ECFP10 fingerprint

This is a circular fingerprint of diameter 10.

The OpenBabel-ECFP10/1 FingerprintType parameter is:

  • nBits - the number of bits in the fingerprint (default: 4096 and

    must be a power of 2)

is_available = False
name: str = 'OpenBabel-ECFP10/1'

the fingerprint name

class chemfp.openbabel_types.OpenBabelECFP2FingerprintType_v1(fingerprint_kwargs)

Bases: OpenBabelECFPBaseFingerprintType

Open Babel’s implementation of the ECFP2 fingerprint

This is a circular fingerprint of diameter 2.

The OpenBabel-ECFP2/1 FingerprintType parameter is:

  • nBits - the number of bits in the fingerprint (default: 4096 and

    must be a power of 2)

name: str = 'OpenBabel-ECFP2/1'

the fingerprint name

class chemfp.openbabel_types.OpenBabelECFP4FingerprintType_v1(fingerprint_kwargs)

Bases: OpenBabelECFPBaseFingerprintType

Open Babel’s implementation of the ECFP4 fingerprint

This is a circular fingerprint of diameter 4.

The OpenBabel-ECFP4/1 FingerprintType parameter is:

  • nBits - the number of bits in the fingerprint (default: 4096 and

    must be a power of 2)

name: str = 'OpenBabel-ECFP4/1'

the fingerprint name

class chemfp.openbabel_types.OpenBabelECFP6FingerprintType_v1(fingerprint_kwargs)

Bases: OpenBabelECFPBaseFingerprintType

Open Babel’s implementation of the ECFP6 fingerprint

This is a circular fingerprint of diameter 6.

The OpenBabel-ECFP6/1 FingerprintType parameter is:

  • nBits - the number of bits in the fingerprint (default: 4096 and

    must be a power of 2)

name: str = 'OpenBabel-ECFP6/1'

the fingerprint name

class chemfp.openbabel_types.OpenBabelECFP8FingerprintType_v1(fingerprint_kwargs)

Bases: OpenBabelECFPBaseFingerprintType

Open Babel’s implementation of the ECFP8 fingerprint

This is a circular fingerprint of diameter 8.

The OpenBabel-ECFP8/1 FingerprintType parameter is:

  • nBits - the number of bits in the fingerprint (default: 4096 and

    must be a power of 2)

is_available = False
name: str = 'OpenBabel-ECFP8/1'

the fingerprint name

class chemfp.openbabel_types.OpenBabelECFPBaseFingerprintType(fingerprint_kwargs)

Bases: OpenBabelBaseFingerprintType

class chemfp.openbabel_types.OpenBabelFP2FingerprintType_v1(fingerprint_kwargs: Dict[str, Any])

Bases: NoFingerprintParametersMixin, OpenBabelBaseFingerprintType

OpenBabel FP2 fingerprint based on path enumeration

See https://openbabel.org/wiki/FP2

This is a Daylight-like path enumeration fingerprint with 1021 bits.

The OpenBabel-FP2/1 FingerprintType has no parameters.

make_fingerprinter()

Make a ‘fingerprinter’; a callable which takes a molecule and returns a fingerprint

Returns:

a function object which takes a molecule and return a fingerprint

name: str = 'OpenBabel-FP2/1'

the fingerprint name

num_bits: int = 1021
class chemfp.openbabel_types.OpenBabelFP3FingerprintType_v1(fingerprint_kwargs: Dict[str, Any])

Bases: NoFingerprintParametersMixin, OpenBabelBaseFingerprintType

OpenBabel FP3 fingerprint

See https://openbabel.org/wiki/FP3

55 bit fingerprints based on a set of SMARTS patterns defining functional groups.

The OpenBabel-FP3/1 FingerprintType has no parameters.

make_fingerprinter()

Make a ‘fingerprinter’; a callable which takes a molecule and returns a fingerprint

Returns:

a function object which takes a molecule and return a fingerprint

name: str = 'OpenBabel-FP3/1'

the fingerprint name

num_bits: int = 55
class chemfp.openbabel_types.OpenBabelFP4FingerprintType_v1(fingerprint_kwargs: Dict[str, Any])

Bases: NoFingerprintParametersMixin, OpenBabelBaseFingerprintType

OpenBabel FP4 fingerprint

https://openbabel.org/wiki/FP4

307 bit fingerprints based on a set of SMARTS patterns defining functional groups.

The OpenBabel-FP4/1 FingerprintType has no parameters.

make_fingerprinter()

Make a ‘fingerprinter’; a callable which takes a molecule and returns a fingerprint

Returns:

a function object which takes a molecule and return a fingerprint

name: str = 'OpenBabel-FP4/1'

the fingerprint name

num_bits: int = 307
class chemfp.openbabel_types.OpenBabelMACCSFingerprintType_v2(fingerprint_kwargs: Dict[str, Any])

Bases: OpenBabelBaseMACCSFingerprintType

Open Babel’s implementation of the 166 MACCS keys

See https://openbabel.org/wiki/Tutorial:Fingerprints and https://github.com/openbabel/openbabel/blob/master/data/MACCS.txt .

Note: Open Babel added support for key 44 on 20 October 2014. This should have been version 3. However, I didn’t notice until 1 May 2017 that there was no chemfp test for it. Since everyone has been using it as v2, and very few people used the older version, I won’t change the version number.

The OpenBabel-MACCS/2 FingerprintType has no parameters.

name: str = 'OpenBabel-MACCS/2'

the fingerprint name