Chython [ˈkʌɪθ(ə)n]¶
Library for processing molecules and reactions in python way.
- Features:
Read/write/convert formats: MDL .RDF (.RXN) and .SDF (.MOL), .MRV, SMILES, INCHI (inchi-trust library), .XYZ, .PDB
Standardize molecules and reactions and valid structures checker
Supported python-magic
Tetrahedron, Allene and CIS-TRANS stereo supported
Perform subgraph search
Build/edit molecules and reactions with Python API
Produce template based reactions and molecules
Atom-to-atom mapping, checking and rule-based fixing
Perform MCS search
2d coordinates generation (based on SmilesDrawer)
2d/3d depiction with Jupyter support
SMARTS parser with restrictions
Protective groups remover
Common reaction templates collection
Full documentation can be found here.
CGRtools¶
Chython is fork of CGRtools.
Install¶
Only python 3.8+.
Note: for using clean2d install NodeJS into system.
stable version available through PyPI:
pip install chython
Install chython library DEV version for features that are not well tested:
pip install -U git+https://github.com/chython/chython.git@master#egg=chython
Copyright¶
2014-2023 Ramil Nugmanov nougmanoff@protonmail.com main developer
Contributors¶
CGRtools contributors are included too.
Adelia Fatykhova adelik21979@gmail.com
Aleksandr Sizov murkyrussian@gmail.com
Dinar Batyrshin batyrshin-dinar@mail.ru
Dmitrij Zanadvornykh zandmitrij@gmail.com
Ravil Mukhametgaleev sonic-mc@mail.ru
Tagir Akhmetshin tagirshin@gmail.com
Timur Gimadiev timur.gimadiev@gmail.com
Zarina Ibragimova
Chython package API¶
chython. pickle_cache = True - Store cached attributes in pickle. Effective for multiprocessing.
chython. torch_device = ‘cpu’ - Atom-to-Atom mapping model device in torch notation. Change before first reset_mapping call!
- chython.depict_settings(*, carbon: bool = False, aam: bool = True, monochrome: bool = False, bond_color: str = 'black', aam_color: str = '#0305A7', atoms_colors: tuple = ('#909090', '#D9FFFF', '#CC80FF', '#C2FF00', '#FFB5B5', '#101010', '#3050F8', '#FF0D0D', '#90E050', '#B3E3F5', '#AB5CF2', '#8AFF00', '#BFA6A6', '#F0C8A0', '#FF8000', '#C6C600', '#1FF01F', '#80D1E3', '#8F40D4', '#3DFF00', '#E6E6E6', '#BFC2C7', '#A6A6AB', '#8A99C7', '#9C7AC7', '#E06633', '#F090A0', '#50D050', '#C88033', '#7D80B0', '#C28F8F', '#668F8F', '#BD80E3', '#FFA100', '#A62929', '#5CB8D1', '#702EB0', '#00FF00', '#94FFFF', '#94E0E0', '#73C2C9', '#54B5B5', '#3B9E9E', '#248F8F', '#0A7D8C', '#006985', '#C0C0C0', '#FFD98F', '#A67573', '#668080', '#9E63B5', '#D47A00', '#940094', '#429EB0', '#57178F', '#00C900', '#70D4FF', '#FFFFC7', '#D9FFC7', '#C7FFC7', '#A3FFC7', '#8FFFC7', '#61FFC7', '#45FFC7', '#30FFC7', '#1FFFC7', '#00FF9C', '#00E675', '#00D452', '#00BF38', '#00AB24', '#4DC2FF', '#4DA6FF', '#2194D6', '#267DAB', '#266696', '#175487', '#D0D0E0', '#FFD123', '#B8B8D0', '#A6544D', '#575961', '#9E4FB5', '#AB5C00', '#754F45', '#428296', '#420066', '#007D00', '#70ABFA', '#00BAFF', '#00A1FF', '#008FFF', '#0080FF', '#006BFF', '#545CF2', '#785CE3', '#8A4FE3', '#A136D4', '#B31FD4', '#B31FBA', '#B30DA6', '#BD0D87', '#C70066', '#CC0059', '#D1004F', '#D90045', '#E00038', '#E6002E', '#EB0026', '#EB0026', '#EB0026', '#EB0026', '#EB0026', '#EB0026', '#EB0026', '#EB0026', '#EB0026', '#EB0026'), bond_width: float = 0.04, wedge_space: float = 0.08, dashes: Tuple[float, float] = (0.2, 0.1), aromatic_dashes: Tuple[float, float] = (0.15, 0.05), dx_ci: float = 0.05, dy_ci: float = 0.2, dx_m: float = 0.05, dy_m: float = 0.2, span_dy: float = 0.15, double_space: float = 0.06, triple_space: float = 0.13, aromatic_space: float = 0.14, atom_radius: float = 0.2, bond_radius=0.02, font_size: float = 0.5, other_size: float = 0.3, span_size: float = 0.35, aam_size: float = 0.25, symbols_font_style: str = 'sans-serif', other_font_style: str = 'monospace', other_color: str = 'black', mapping_font_style: str = 'monospace')¶
Settings for depict of chemical structures
- Parameters:
carbon – if True, depict atom C
font_size – font size
aam_size – atom-to-atom mapping font size
span_size – font size for hydrogen count
other_size – isotope, radical, charges, neighbors and hybridization symbols size
bond_width – bond width
bond_color – color of bonds
aam_color – atom-to-atom mapping color
atoms_colors – atom colors where key is atomic number - 1, value is atom color (str)
other_color – color for charges, radicals, isotopes
symbols_font_style – font style for atom symbols
other_font_style – font style for charges, radicals, isotopes, hybridization and neighbors
aam – if True, depict mapping
monochrome – if True, colors of items in molecule not used
dashes – first value is long of visible line, second is long of invisible line
aromatic_space – space between simple and aromatic bonds
triple_space – space between simple and triple bonds
double_space – space between simple and double bonds
aromatic_dashes – first value is long of visible line, second is long of invisible line
atom_radius – radius of atoms spheres in depict3d. if negative is multiplier to covalent radii
bond_radius – radius of bonds spheres in depict3d
dx_ci – x-axis offset relative to the center of the atom symbol for radical, charges, isotope
dy_ci – y-axis offset relative to the center of the atom symbol for radical, charges, isotope
dx_m – x-axis offset relative to the center of the atom symbol for atom-to-atom mapping
dy_m – y-axis offset relative to the center of the atom symbol for atom-to-atom mapping
span_dy – y-axis offset relative to the center of the atom symbol for hydrogen count
mapping_font_style – font style for mapping
wedge_space – wedge bond width
- chython.inchi(data, /, *, ignore_stereo: bool = False, _cls=<class 'chython.containers.molecule.MoleculeContainer'>) MoleculeContainer ¶
INCHI string parser
- chython.mdl_mol(data: str, /, *, ignore=True, calc_cis_trans=False, ignore_stereo=False, remap=False, ignore_bad_isotopes=False, _cls=<class 'chython.containers.molecule.MoleculeContainer'>) MoleculeContainer ¶
Parse string with mol file.
- chython.smarts(data: str)¶
Parse SMARTS string.
stereo ignored.
only D, a, h, r and !R atom primitives supported.
bond order list and not bond supported.
[not]ring bond supported only in combination with explicit bonds, not bonds and bonds orders lists.
mapping, charge and isotopes supported.
list of elements supported.
A - treats as any element. <A> primitive (aliphatic) ignored.
M - treats as any metal..
<&> logic operator unsupported.
<;> logic operator is mandatory except (however preferable) for charge, isotope, stereo marks.
CXSMARTS radicals supported.
hybridization and heteroatoms count in CXSMARTS atomProp notation coded as <hyb> and <het> keys.
- masked atom - chython.Reactor specific mark for masking reactant atoms from deletion.
Coded in CXSMARTS atomProp as <msk> key with any value.
For example:
[C;r5,r6;a]-;!@[C;h1,h2] |^1:1,atomProp:1.hyb.24:1.het.0| - aromatic C member of 5 or 6 atoms ring connected with non-ring single bond to aromatic or SP2 radical C with 1 or 2 hydrogens.
Alternative hybridization, heteroatoms and masks coding:
primitive <xN> - heteroatoms (e.g. x2 - two heteroatoms)
primitive <zN> - hybridization (N = 1 - sp3, 2 - sp2, 3 - sp, 4 - aromatic)
primitive <M> - masked atom
Note: atom numbers greater than 10 ** 9 forbidden for usage and reserved for masked atoms numbering. In multiprocess mode has potential bugs in reaction enumeration task then used templates prepared from components from different processes. For avoiding, prepare templates on single process and then share it.
- chython.smiles(data, /, *, ignore: bool = True, remap: bool = False, ignore_stereo: bool = False, ignore_bad_isotopes: bool = False, keep_implicit: bool = False, ignore_carbon_radicals: bool = False, ignore_aromatic_radicals: bool = True, _r_cls=<class 'chython.containers.reaction.ReactionContainer'>, _m_cls=<class 'chython.containers.molecule.MoleculeContainer'>) MoleculeContainer | ReactionContainer ¶
SMILES string parser
- Parameters:
ignore – Skip some checks of data or try to fix some errors.
remap – Remap atom numbers started from one.
ignore_stereo – Ignore stereo data.
keep_implicit – keep given in smiles implicit hydrogen count, otherwise ignore on valence error.
ignore_bad_isotopes – reset invalid isotope mark to non-isotopic.
ignore_carbon_radicals – fill carbon radicals with hydrogen (X[C](X)X case).
ignore_aromatic_radicals – don’t treat aromatic tokens like c[c]c as radicals.
- chython.xyz(matrix: ~typing.Sequence[~typing.Tuple[str, float, float, float]], charge=0, radical=0, radius_multiplier=1.25, atom_charge: ~typing.Sequence[int] | None = None, _cls=<class 'chython.containers.molecule.MoleculeContainer'>) MoleculeContainer ¶
Subpackages¶
- chython.containers package
Bond
MoleculeContainer
MoleculeContainer.add_atom()
MoleculeContainer.add_atom_stereo()
MoleculeContainer.add_bond()
MoleculeContainer.add_cis_trans_stereo()
MoleculeContainer.add_wedge()
MoleculeContainer.adjacency_matrix()
MoleculeContainer.aromatic_rings
MoleculeContainer.atom()
MoleculeContainer.atoms()
MoleculeContainer.atoms_count
MoleculeContainer.atoms_numbers
MoleculeContainer.atoms_order
MoleculeContainer.atoms_rings
MoleculeContainer.atoms_rings_sizes
MoleculeContainer.augmented_substructure()
MoleculeContainer.augmented_substructures()
MoleculeContainer.bond()
MoleculeContainer.bonds()
MoleculeContainer.bonds_count
MoleculeContainer.brutto
MoleculeContainer.calculate_cis_trans_from_2d()
MoleculeContainer.canonicalize()
MoleculeContainer.check_valence()
MoleculeContainer.clean2d()
MoleculeContainer.clean_isotopes()
MoleculeContainer.clean_stereo()
MoleculeContainer.compose()
MoleculeContainer.connected_components
MoleculeContainer.connected_components_count
MoleculeContainer.copy()
MoleculeContainer.cumulenes
MoleculeContainer.delete_atom()
MoleculeContainer.delete_bond()
MoleculeContainer.depict()
MoleculeContainer.depict3d()
MoleculeContainer.enumerate_charged_forms()
MoleculeContainer.enumerate_charged_tautomers()
MoleculeContainer.enumerate_kekule()
MoleculeContainer.enumerate_tautomers()
MoleculeContainer.environment()
MoleculeContainer.explicify_hydrogens()
MoleculeContainer.explicit_hydrogens()
MoleculeContainer.fix_resonance()
MoleculeContainer.fix_stereo()
MoleculeContainer.flush_cache()
MoleculeContainer.flush_stereo_cache()
MoleculeContainer.get_automorphism_mapping()
MoleculeContainer.get_fast_mapping()
MoleculeContainer.get_mapping()
MoleculeContainer.get_mcs_mapping()
MoleculeContainer.has_atom()
MoleculeContainer.has_bond()
MoleculeContainer.heteroatoms()
MoleculeContainer.hybridization()
MoleculeContainer.implicify_hydrogens()
MoleculeContainer.implicit_hydrogens()
MoleculeContainer.int_adjacency
MoleculeContainer.is_automorphic()
MoleculeContainer.is_equal()
MoleculeContainer.is_radical
MoleculeContainer.is_ring_bond()
MoleculeContainer.is_substructure()
MoleculeContainer.kekule()
MoleculeContainer.linear_bit_set()
MoleculeContainer.linear_fingerprint()
MoleculeContainer.linear_hash_set()
MoleculeContainer.linear_hash_smiles()
MoleculeContainer.linear_smiles_hash()
MoleculeContainer.meta
MoleculeContainer.molecular_charge
MoleculeContainer.molecular_mass
MoleculeContainer.morgan_bit_set()
MoleculeContainer.morgan_fingerprint()
MoleculeContainer.morgan_hash_set()
MoleculeContainer.morgan_hash_smiles()
MoleculeContainer.morgan_smiles_hash()
MoleculeContainer.name
MoleculeContainer.neighbors()
MoleculeContainer.neutralize()
MoleculeContainer.not_special_connectivity
MoleculeContainer.pack()
MoleculeContainer.pack_len()
MoleculeContainer.remap()
MoleculeContainer.remove_acids()
MoleculeContainer.remove_coordinate_bonds()
MoleculeContainer.remove_metals()
MoleculeContainer.ring_atoms
MoleculeContainer.rings_count
MoleculeContainer.saturate()
MoleculeContainer.skin_graph
MoleculeContainer.smiles_atoms_order
MoleculeContainer.split()
MoleculeContainer.split_metal_salts()
MoleculeContainer.sssr
MoleculeContainer.standardize()
MoleculeContainer.standardize_charges()
MoleculeContainer.sticky_smiles()
MoleculeContainer.substructure()
MoleculeContainer.tetrahedrons
MoleculeContainer.thiele()
MoleculeContainer.total_hydrogens()
MoleculeContainer.union()
MoleculeContainer.unpack()
MoleculeContainer.view3d()
QueryBond
QueryContainer
QueryContainer.add_atom()
QueryContainer.add_bond()
QueryContainer.atom()
QueryContainer.atoms()
QueryContainer.atoms_count
QueryContainer.atoms_numbers
QueryContainer.atoms_order
QueryContainer.atoms_rings
QueryContainer.atoms_rings_sizes
QueryContainer.bond()
QueryContainer.bonds()
QueryContainer.bonds_count
QueryContainer.clean_stereo()
QueryContainer.connected_components
QueryContainer.connected_components_count
QueryContainer.copy()
QueryContainer.cumulenes
QueryContainer.enumerate_queries()
QueryContainer.flush_cache()
QueryContainer.get_automorphism_mapping()
QueryContainer.get_mapping()
QueryContainer.has_atom()
QueryContainer.has_bond()
QueryContainer.int_adjacency
QueryContainer.is_automorphic()
QueryContainer.is_equal()
QueryContainer.is_ring_bond()
QueryContainer.is_substructure()
QueryContainer.not_special_connectivity
QueryContainer.remap()
QueryContainer.ring_atoms
QueryContainer.rings_count
QueryContainer.skin_graph
QueryContainer.smiles_atoms_order
QueryContainer.sssr
QueryContainer.tetrahedrons
QueryContainer.union()
ReactionContainer
ReactionContainer.canonicalize()
ReactionContainer.check_valence()
ReactionContainer.clean2d()
ReactionContainer.clean_isotopes()
ReactionContainer.clean_stereo()
ReactionContainer.compose()
ReactionContainer.contract_ions()
ReactionContainer.copy()
ReactionContainer.depict()
ReactionContainer.explicify_hydrogens()
ReactionContainer.fix_groups_mapping()
ReactionContainer.fix_mapping()
ReactionContainer.fix_positions()
ReactionContainer.flush_cache()
ReactionContainer.implicify_hydrogens()
ReactionContainer.kekule()
ReactionContainer.meta
ReactionContainer.molecules()
ReactionContainer.name
ReactionContainer.pack()
ReactionContainer.pack_len()
ReactionContainer.products
ReactionContainer.reactants
ReactionContainer.reagents
ReactionContainer.remove_reagents()
ReactionContainer.reset_mapping()
ReactionContainer.standardize()
ReactionContainer.thiele()
ReactionContainer.unpack()
- chython.files package
- chython.reactor package
- chython.utils package
- chython.periodictable package
C
C.__eq__()
C.__hash__()
C.atomic_mass
C.atomic_number
C.atomic_radius
C.atomic_symbol
C.charge
C.copy()
C.explicit_hydrogens
C.from_atom()
C.from_atomic_number()
C.from_symbol()
C.heteroatoms
C.hybridization
C.implicit_hydrogens
C.in_ring
C.is_radical
C.isotope
C.isotopes_distribution
C.isotopes_masses
C.neighbors
C.ring_sizes
C.total_hydrogens
C.valence_rules()
C.x
C.xy
C.y
QueryC
QueryC.__eq__()
QueryC.__hash__()
QueryC.atomic_number
QueryC.atomic_radius
QueryC.atomic_symbol
QueryC.charge
QueryC.copy()
QueryC.from_atom()
QueryC.from_atomic_number()
QueryC.from_symbol()
QueryC.heteroatoms
QueryC.hybridization
QueryC.implicit_hydrogens
QueryC.is_radical
QueryC.isotope
QueryC.neighbors
QueryC.ring_sizes
AnyElement
ListElement
ListElement.__eq__()
ListElement.__hash__()
ListElement.atomic_number
ListElement.atomic_symbol
ListElement.charge
ListElement.copy()
ListElement.heteroatoms
ListElement.hybridization
ListElement.implicit_hydrogens
ListElement.is_radical
ListElement.isotope
ListElement.neighbors
ListElement.ring_sizes
AnyMetal