Creating Molecule Objects

Create Molecule with Labelled atoms

group_decomposition.utils.mol_with_atom_index(mol)[source]

Label a molecule with map numbers for order atoms are in molecule.

Useful for tracking atoms after fragmenting

Parameters:

mol – an rdkit molecule object

Returns:

rdkit molecule object with AtomMapNum set so that atom 0 has map number 1, atom 1 has map number 2…etc

Create Molecule from CML File

group_decomposition.utils.mol_from_cml(cml_file, input_type='cmlfile')[source]

Creates a molecule from a cml file and returns atoms, xyz and types

Builds molecule one atom at a time connected by single bonds Then determines bond orders by mapping to a template smiles in the cml Finally, updates property cache, initializes ring info, and sanitizes mol If no match between SMILEs and connectivity, returns None and writes error to file

Parameters:
  • cml_file – cml file name or dictionary containing cml data

  • input_type – cmlfile or cmldict. Use cmlfile if just raw cml file, use cmldict if dictionary

Returns:

[Molecule, list of atom symbols in molecule, list of xyz coords of atoms in molecule, list of atom types of atoms in molecule]

Return type:

list with elements

Note

list order matches mol numbering in cml

Create Molecule from mol File

group_decomposition.utils.mol_from_molfile(mol_file)[source]

takes mol_file and returns mol wth atom numbers the same

Modified for mol file structure from retrievium from stackexchange https://mattermodeling.stackexchange.com/questions/7234/how-to-input-3d-coordinates-from-xyz-file-and-connectivity-from-smiles-in-rdkit

Parameters:

mol_file – name of .mol file

Returns:

mol with AtomMapNumbers labeled by group_decomposition.utils.mol_with_atom_index