Molecules

Reading RDKit molecules — prolif.rdkitmol

class prolif.rdkitmol.BaseRDKitMol[source]

Bases: rdkit.Chem.rdchem.Mol

Base molecular class that behaves like an RDKit Mol with extra attributes (see below). The sole purpose of this class is to define the common API between the Molecule and Residue classes. This class should not be instantiated by users.

Parameters

mol (rdkit.Chem.rdchem.Mol) – A molecule (protein, ligand, or residue) with a single conformer

centroid

XYZ coordinates of the centroid of the molecule

Type

numpy.ndarray

xyz

XYZ coordinates of all atoms in the molecule

Type

numpy.ndarray

Reading proteins and ligands — prolif.molecule

class prolif.molecule.Molecule(mol)[source]

Bases: prolif.rdkitmol.BaseRDKitMol

Main molecule class that behaves like an RDKit Mol with extra attributes (see examples below). The main purpose of this class is to access residues as fragments of the molecule.

Parameters

mol (rdkit.Chem.rdchem.Mol) – A ligand or protein with a single conformer

residues

A dictionnary storing one/many Residue indexed by ResidueId. The residue list is sorted.

Type

prolif.residue.ResidueGroup

n_residues

Number of residues

Type

int

Examples

In [1]: import MDAnalysis as mda

In [2]: import prolif

In [3]: u = mda.Universe(prolif.datafiles.TOP, prolif.datafiles.TRAJ)

In [4]: mol = u.select_atoms("protein").convert_to("RDKIT")

In [5]: mol = prolif.Molecule(mol)

In [6]: mol
Out[6]: <prolif.molecule.Molecule with 302 residues and 4988 atoms at 0x7fd6382a5180>

You can also create a Molecule directly from a Universe:

In [7]: mol = prolif.Molecule.from_mda(u, "protein")

In [8]: mol
Out[8]: <prolif.molecule.Molecule with 302 residues and 4988 atoms at 0x7fd6377aabd0>

Notes

Residues can be accessed easily in different ways:

In [9]: mol["TYR38.A"] # by resid string (residue name + number + chain)
Out[9]: <prolif.residue.Residue TYR38.A at 0x7fd6377ba360>

In [10]: mol[42] # by index (from 0 to n_residues-1)
Out[10]: <prolif.residue.Residue LEU80.A at 0x7fd63787a810>

In [11]: mol[prolif.ResidueId("TYR", 38, "A")] # by ResidueId
Out[11]: <prolif.residue.Residue TYR38.A at 0x7fd6377ba360>

See prolif.residue for more information on residues

classmethod from_mda(obj, selection=None, **kwargs)[source]

Creates a Molecule from an MDAnalysis object

Parameters

Example

In [1]: mol = prolif.Molecule.from_mda(u, "protein")

In [2]: mol
Out[2]: <prolif.molecule.Molecule with 302 residues and 4988 atoms at 0x7fd63778acc0>

Which is equivalent to:

In [3]: protein = u.select_atoms("protein")

In [4]: mol = prolif.Molecule.from_mda(protein)

In [5]: mol
Out[5]: <prolif.molecule.Molecule with 302 residues and 4988 atoms at 0x7fd63778adb0>
classmethod from_rdkit(mol, resname='UNL', resnumber=1, chain='')[source]

Creates a Molecule from an RDKit molecule

While directly instantiating a molecule with prolif.Molecule(mol) would also work, this method insures that every atom is linked to an AtomPDBResidueInfo which is required by ProLIF

Parameters
  • mol (rdkit.Chem.rdchem.Mol) – The input RDKit molecule

  • resname (str) – The default residue name that is used if none was found

  • resnumber (int) – The default residue number that is used if none was found

  • chain (str) – The default chain Id that is used if none was found

Notes

This method only checks for an existing AtomPDBResidueInfo in the first atom. If none was found, it will patch all atoms with the one created from the method’s arguments (resname, resnumber, chain).

prolif.molecule.mol2_supplier(path, **kwargs)[source]

Generates prolif.Molecule objects from a MOL2 file

Parameters
  • path (str) – A path to the .mol2 file

  • resname (str) – Residue name for every ligand

  • resnumber (int) – Residue number for every ligand

  • chain (str) – Chain ID for every ligand

Returns

suppl – A generator object that will provide the Molecule object as you iterate over it.

Return type

generator

Example

The supplier is typically used like this:

>>> lig_suppl = mol2_supplier("docking/output.mol2")
>>> for lig in lig_suppl:
...     # do something with each ligand
prolif.molecule.pdbqt_supplier(paths, template)[source]

Supplies molecules, given a path to PDBQT files

Parameters
  • paths (list) – A list (or any iterable) of PDBQT files

  • template (rdkit.Chem.rdchem.Mol) – A template molecule with the correct bond orders and charges. It must match exactly the molecule inside the PDBQT file.

Returns

suppl – A generator object that will provide the Molecule object as you iterate over it.

Return type

generator

Example

The supplier is typically used like this:

>>> import glob
>>> pdbqts = glob.glob("docking/ligand1/*.pdbqt")
>>> lig_suppl = pdbqt_supplier(pdbqts, template)
>>> for lig in lig_suppl:
...     # do something with each ligand
prolif.molecule.sdf_supplier(path, **kwargs)[source]

Supplies molecules, given a path to an SDFile

Parameters
  • path (str) – A path to the .sdf file

  • resname (str) – Residue name for every ligand

  • resnumber (int) – Residue number for every ligand

  • chain (str) – Chain ID for every ligand

Returns

suppl – A generator object that will provide the Molecule object as you iterate over it.

Return type

generator

Example

The supplier is typically used like this:

>>> lig_suppl = sdf_supplier("docking/output.sdf")
>>> for lig in lig_suppl:
...     # do something with each ligand
class prolif.residue.Residue(mol)[source]

Bases: prolif.rdkitmol.BaseRDKitMol

A class for residues as RDKit molecules

Parameters

mol (rdkit.Chem.rdchem.Mol) – The residue as an RDKit molecule

resid

The residue identifier

Type

prolif.residue.ResidueId

Notes

The name of the residue can be converted to a string by using str(Residue)