Bases: object
Class to manipulate small molecule structures
mol (rdkit.Chem.rdchem.Mol or filename or smile or moleculekit.smallmol.smallmol.SmallMol) – (i) Rdkit molecule or (ii) Location of molecule file (“.pdb”/”.mol2”) or (iii) a smile string or iv) another SmallMol object or v) moleculekit.molecule.Molecule object
ignore_errors (bool) – If True, errors will not be raised.
force_reading (bool) – If True, and the mol provided is not accepted, the molecule will be initially converted into sdf
fixHs (bool) – If True, the missing hydrogens are assigned, the others are correctly assinged into the graph of the molecule
removeHs (bool) – If True, remove the hydrogens
Examples
>>> import os
>>> from moleculekit.home import home
>>> from moleculekit.smallmol.smallmol import SmallMol
>>> SmallMol('CCO')
>>> SmallMol(os.path.join(home(dataDir='test-smallmol'), 'ligand.pdb'), fixHs=False, removeHs=True )
>>> sm = SmallMol(os.path.join(home(dataDir='test-smallmol'), 'benzamidine.mol2'))
>>> print(sm)
SmallMol with 18 atoms and 1 conformers
Atom field - bondtype
Atom field - charge
...
Methods
Attributes
Create a copy of the molecule object
newsmallmol – A copy of the object
Depicts the molecules. It is possible to save it into an svg file and also generates a jupiter-notebook rendering
sketch (bool) – Set to True for 2D depiction
filename (str) – Set the filename for the svg file
ipython (bool) – Set to True to return the jupiter-notebook rendering
optimize (bool) – Set to True to optimize the conformation. Works only with 3D.
optimizemode (['std', 'mmff']) – Set the optimization mode for 3D conformation
removeHs (bool) – Set to True to hide hydrogens in the depiction
atomlabels (str) – Accept any combinations of the following pararemters as unique string ‘%a%i%c%*’ a:atom name, i:atom index, c:atom formal charge (+/-), :chiral ( if atom is chiral)
highlightAtoms (list) – List of atom to highlight. It can be also a list of atom list, in this case different colors will be used
resolution (tuple of integers) – Resolution in pixels: (X, Y)
ipython_svg
SVG object if ipython is set to True
Example
>>> sm.depict(ipython=True, optimize=True, optimizemode='std')
>>> sm.depict(ipython=True, sketch=True)
>>> sm.depict(ipython=True, sketch=True)
>>> sm.depict(ipython=True, sketch=True, atomlabels="%a%i%c")
>>> ids = np.intersect1d(sm.get('idx', 'hybridization SP2'), sm.get('idx', 'element C'))
>>> sm.depict(ipython=True, sketch=True,highlightAtoms=ids.tolist(), removeHs=False)
Returns True if at least a bond is found between the two selections. It is possible to check for specific bond type. A tuple is returned in the form (bool, [ [(idx1,idx2), rdkit.Chem.rdchem.BondType]] ])
isbond (bool) – True if a bond was found
details (list) – A list of lists with the index of atoms in the bond and its type
Generates ligand conformers
Returns the property for the atom specified with the selection. The selection is another atom property
returnField (str) – The field of the atom to return
sel (str) – The selection string. atom field name followed by spaced values for that field
convertType (bool) – If True, and where possible the returnField is converted in rdkit object Default: True
invert (bool) – If True, the selection is inverted Default: False
values – The array of values for the property
np.array
Example
>>> sm.get('element', 'idx 0 1 7')
array(['C', 'C', 'H'],
dtype='<U1')
>>> sm.get('hybridization', 'element N')
array([rdkit.Chem.rdchem.HybridizationType.SP2,
rdkit.Chem.rdchem.HybridizationType.SP2], dtype=object)
>>> sm.get('hybridization', 'element N', convertType=False)
array([3, 3])
>>> sm.get('element', 'hybridization sp2')
array(['C', 'C', 'C', 'C', 'C', 'C', 'C', 'N', 'N'],
dtype='<U1')
>>> sm.get('element', 'hybridization S')
array(['H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'],
dtype='<U1')
>>> sm.get('element', 'hybridization 1')
array(['H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'],
dtype='<U1')
>>> sm.get('atomobject', 'element N')
array([<rdkit.Chem.rdchem.Atom object at 0x7faf616dd120>,
<rdkit.Chem.rdchem.Atom object at 0x7faf616dd170>], dtype=object)
Retuns an array with the rdkit.Chem.rdchem.Atom present in the molecule
Returns geometrical center of molecule conformation
Returns True if the molecule has at least one chiral atom. If returnDetails is set as True, a list of tuples with the atom idx and chiral type is returned.
returnDetails (bool) – If True, returns the chiral atoms and their chiral types Default: False
ischiral (bool) – True if the atom has at least a chiral atom
details (list) – A list of tuple with the chiral atoms and their types
Example
>>> chiralmol.isChiral()
True
>>> chiralmol.isChiral(returnDetails=True)
(True, [('C2', 'R')])
Return the moleculekit.molecule.Molecule
ids (list) – The list of conformer ids to store in the moleculekit Molecule object- If None, all are returned Default: None
mol – The moleculekit Molecule object
Returns the smarts string of the molecule
Returns the smiles string of the molecule