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 0x7f2012169d10>

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 0x7f2011e10d10>

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 0x7f2011d8a310>

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

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

See prolif.residue for more information on residues

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

Create 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 0x7f2011d95f40>

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 0x7f2011ce8f90>
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)