polymerist.polymers.monomers.specification

Implementations of the canonical monomer substructure SMARTS specification defined in https://doi.org/10.26434/chemrxiv-2023-f2zxd-v2

Attributes

LOGGER

COMPLIANT_ATOM_SMARTS

ABERRANT_RDKIT_ATOM_SMARTS

Functions

disambiguate_formal_charge(→ int)

Convert a (possibly implicit) sign and magnitude of a SMILES-compliant atom

chem_info_from_match(→ dict[str, Union[int, str, None]])

Generate chemical information dict (with proper types) from an atom query regex match

compliant_atom_query_from_info(→ Union[str, ...)

Construct a monomer-spec compliant atom SMARTS string directly from chemical information

compliant_atom_query_from_rdatom(→ Union[str, ...)

Construct a monomer-spec compliant atom SMARTS string from an RDKit Atom

compliant_atom_query_from_re_match(→ str)

Construct a monomer-spec compliant atom SMARTS string from a RegEx string match of a compliant or aberrant atom

compliant_mol_SMARTS(→ str)

Convert a generic SMARTS string into a monomer specification-compliant one

Module Contents

polymerist.polymers.monomers.specification.LOGGER
polymerist.polymers.monomers.specification.COMPLIANT_ATOM_SMARTS
polymerist.polymers.monomers.specification.ABERRANT_RDKIT_ATOM_SMARTS
polymerist.polymers.monomers.specification.disambiguate_formal_charge(sign: str, magnitude: str) int[source]

Convert a (possibly implicit) sign and magnitude of a SMILES-compliant atom formal charge entry to an explicit signed integer value (e.g. “+” -> +1, “–” -> -2)

Parameters:
  • sign (str (“”, “+”, or “-”) – The string (possibly empty) representing the sign of the formal charge

  • magnitude (str (”” or digit string)) – The string (possibly empty) representing the magnitude of the formal charge (digits only)

Returns:

formal_charge – The explicit signed integer value of the formal charge

Will raise ValueError if sign and magnitude passed cannot be coerced into the appropriate types

Return type:

int

polymerist.polymers.monomers.specification.chem_info_from_match(match: re.Match) dict[str, int | str | None][source]

Generate chemical information dict (with proper types) from an atom query regex match

polymerist.polymers.monomers.specification.compliant_atom_query_from_info(atomic_num: int, degree: int, atom_map_num: int, formal_charge: int = 0, isotope: int = 0, as_atom: bool = False) str | rdkit.Chem.QueryAtom[source]

Construct a monomer-spec compliant atom SMARTS string directly from chemical information

polymerist.polymers.monomers.specification.compliant_atom_query_from_rdatom(rdatom: rdkit.Chem.Atom, as_atom: bool = False) str | rdkit.Chem.QueryAtom[source]

Construct a monomer-spec compliant atom SMARTS string from an RDKit Atom

polymerist.polymers.monomers.specification.compliant_atom_query_from_re_match(match: re.Match) str[source]

Construct a monomer-spec compliant atom SMARTS string from a RegEx string match of a compliant or aberrant atom

polymerist.polymers.monomers.specification.compliant_mol_SMARTS(smarts: polymerist.smileslib.cleanup.Smiles | polymerist.smileslib.cleanup.Smarts) str[source]

Convert a generic SMARTS string into a monomer specification-compliant one For details on specification, see https://doi-org.colorado.idm.oclc.org/10.1021/acs.jcim.3c01691

Parameters:

smarts (Union[Smiles, Smarts]) – The SMARTS (or, by virtue of superset, SMILES) string to convert

Returns:

compliant_smarts – The structurally-correspondent monomer specification-compliant SMARTS string

Return type:

Smarts