chython.utils package

Utils for data transformation, depiction etc.

class chython.utils.GridDepict(molecules: List[MoleculeContainer], labels: List[str] | None = None, *, cols: int = 3)

Grid depict for Jupyter notebooks.

Parameters:
  • molecules – list of molecules

  • labels – optional list of text labels

  • cols – number of molecules per row

class chython.utils.RetroDepict(tree: Tuple[MoleculeContainer, List[Tuple[MoleculeContainer, List[Tree]]]])

Grid depict for Jupyter notebooks.

Parameters:

tree – Graph of molecules with recursive structure. Each node is tuple of molecule and list of child nodes. Child nodes list can be empty.

chython.utils.from_rdkit_molecule(data)

RDKit molecule object to MoleculeContainer converter

chython.utils.functional_groups(molecule, limit)

Generate all connected atom groups up to limit atoms.

Parameters:
  • molecule – MoleculeContainer

  • limit – chain length

Returns:

list of molecule functional groups

chython.utils.fw_decomposition_tree(groups: List[MoleculeContainer]) Tuple[MoleculeContainer, List[Tuple[MoleculeContainer, List[Tree]]]]
chython.utils.fw_prepare_groups(core: MoleculeContainer | QueryContainer, molecule: MoleculeContainer) List[MoleculeContainer]

Prepare list of core with connected groups. Hydrogens added to groups for marking connection point. Hydrogens have isotope marks equal to mapping of core atoms. Groups connected multiple times (rings) - contains multiple hydrogens.

Parameters:
  • core – core structure for searching

  • molecule – target structure

chython.utils.grid_depict(molecules: List[MoleculeContainer], labels: List[str] | None = None, *, cols: int = 3, width=None, height=None, clean2d: bool = True)

Depict molecules grid.

Parameters:
  • molecules – list of molecules

  • labels – optional list of text labels

  • cols – number of molecules per row

  • width – set svg width param. by default auto-calculated.

  • height – set svg height param. by default auto-calculated.

  • clean2d – calculate coordinates if necessary.

chython.utils.patch_pandas()

Fix pandas molecules representation.

chython.utils.retro_depict(tree: Tuple[MoleculeContainer, List[Tuple[MoleculeContainer, List[Tree]]]], *, y_gap=3.0, x_gap=5.0, width=None, height=None, clean2d: bool = True) str

Depict retrosynthetic tree.

Parameters:
  • tree – Graph of molecules with recursive structure. Each node is tuple of molecule and list of child nodes. Child nodes list can be empty.

  • y_gap – vertical gap between molecules.

  • x_gap – horizontal gap between molecules.

  • width – set svg width param. by default auto-calculated.

  • height – set svg height param. by default auto-calculated.

  • clean2d – calculate coordinates if necessary.

chython.utils.svg2png(svg: str, width: int = 1000, height: int = 1000, scale: float = 10.0)
chython.utils.to_rdkit_molecule(data: MoleculeContainer, *, keep_mapping=True)

MoleculeContainer to RDKit molecule object converter.

Parameters:

keep_mapping – set atom numbers.

Note: implicit hydrogens data omitted.