RDKit¶
Following the template outlined, chemper
Mol, Atom, and Bond objects
can be created from RDKit Chem module.
cp_rdk.py
Cheminformatics tools using RDKit
The classes provided here follow the structure in adapters. This is a wrapper allowing our actual package to use RDKit
- class chemper.mol_toolkits.cp_rdk.Atom(atom)[source]¶
-
- connectivity()[source]¶
- Returns
connectivity – connectivity or total number of bonds (regardless of order) around the atom
- Return type
int
- degree()[source]¶
- Returns
degree – degree or number of explicit bond orders around the atom
- Return type
int
- get_molecule()[source]¶
Extracts the parent molecule this atom is from.
- Returns
mol – Molecule this atom is stored in
- Return type
ChemPer Mol
- get_neighbors()[source]¶
- Returns
neighbors – Atoms that are one bond away from this atom
- Return type
list[ChemPer Atoms]
- hydrogen_count()[source]¶
- Returns
H_count – total number of hydrogen atoms connected to this Atom
- Return type
int
- is_aromatic()[source]¶
- Returns
is_aromatic – True if the atom is aromatic otherwise False
- Return type
boolean
- is_connected_to(atom2)[source]¶
- Parameters
atom2 (ChemPer Atom) – Atom to check if it is bonded to this atom
- Returns
connected – True if atom2 is a bonded to atom1
- Return type
boolean
- min_ring_size()[source]¶
- Returns
min_ring_size – size of the smallest ring this atom is a part of
- Return type
int
- class chemper.mol_toolkits.cp_rdk.Bond(bond)[source]¶
- get_atoms()[source]¶
- Returns
atoms – The two atoms connected by this bond
- Return type
list[ChemPer Atoms]
- get_molecule()[source]¶
Extracts the parent molecule this bond is from
- Returns
mol – Molecule this bond is stored in
- Return type
ChemPer Mol
- get_order()[source]¶
- Returns
order – This is the absolute order, returns 1.5 if bond is aromatic
- Return type
int or float
- class chemper.mol_toolkits.cp_rdk.Mol(mol)[source]¶
- classmethod from_smiles(smiles)[source]¶
Creates a ChemPer Mol form a SMILES string
- Parameters
smiles (str) – SMILES used to create molecule with wrapped toolkit
- Returns
Mol
- Return type
ChemPer Mol
- get_atom_by_index(idx)[source]¶
- Parameters
idx (int) – atom index
- Returns
atom – atom with index idx
- Return type
ChemPer Atom
- get_atoms()[source]¶
- Returns
atom_list – list of all atoms in the molecule
- Return type
list[ChemPer Atoms]
- get_bond_by_atoms(atom1, atom2)[source]¶
Finds a bond between two atoms
- Parameters
atom1 (ChemPer Atom) –
atom2 (ChemPer Atom) –
- Returns
bond – If atoms are connected returns bond otherwise None
- Return type
ChemPer Bond or None
- get_bond_by_index(idx)[source]¶
- Parameters
idx (int) – bond index
- Returns
bond – bond with index idx
- Return type
ChemPer Bond
- get_bonds()[source]¶
- Returns
bond_list – list of all bonds in the molecule
- Return type
list[ChemPer Bonds]
- smirks_search(smirks)[source]¶
Performs a substructure search on the molecule with the provided SMIRKS pattern. Note - this function expects SMIRKS patterns with indexed atoms that is with :n for at least some atoms.
- Parameters
smirks (str) – SMIRKS pattern with indexed atoms (:n)
- Returns
matches – match dictionaries have the form {smirks index: atom index}
- Return type
list[match dictionary]
- chemper.mol_toolkits.cp_rdk.mols_from_mol2(mol2_file)[source]¶
Parses a mol2 file into ChemPer molecules using RDKit
This is a hack for separating mol2 files taken from a Source Forge discussion here: https://www.mail-archive.com/rdkit-discuss@lists.sourceforge.net/msg01510.html It splits up a mol2 file into blocks and then uses RDKit to parse those blocks
- Parameters
mol2_file (str) – relative or absolute path to a mol2 file you want to parse accessible form the current directory
- Returns
mols – list of molecules in the mol2 file as ChemPer molecules
- Return type
list[ChemPer Mol]