peleffy.topology.Molecule

class peleffy.topology.Molecule(path=None, smiles=None, pdb_block=None, rotamer_resolution=30, exclude_terminal_rotamers=True, name='', tag='UNK', connectivity_template=None, core_constraints=[], allow_undefined_stereo=False, hydrogens_are_explicit=True, fix_pdb=True)[source]

It represent wraps up all the tools to parameterize a molecule with the OpenForceField toolkit for PELE.

__init__(path=None, smiles=None, pdb_block=None, rotamer_resolution=30, exclude_terminal_rotamers=True, name='', tag='UNK', connectivity_template=None, core_constraints=[], allow_undefined_stereo=False, hydrogens_are_explicit=True, fix_pdb=True)[source]

It initializes a Molecule object through a PDB file or a SMILES tag.

Parameters
  • path (str) – The path to a PDB with the molecule structure

  • smiles (str) – The smiles tag

  • rotamer_resolution (float) – The resolution in degrees to discretize the rotamer’s conformational space. Default is 30

  • exclude_terminal_rotamers (bool) – Whether to exclude terminal rotamers when generating the rotamers library or not

  • name (str) – The molecule name

  • tag (str) – The molecule tag. It must be a 3-character string

  • connectivity_template (an rdkit.Chem.rdchem.Mol object) – A molecule represented with RDKit to use when assigning the connectivity of this Molecule object

  • core_constraints (list[int or str]) – It defines the list of atoms to constrain in the core, thus, the core will be forced to contain them. Atoms can be specified through integers that match the atom index or strings that match with the atom PDB name

  • allow_undefined_stereo (bool) – Whether to allow a molecule with undefined stereochemistry to be defined or try to assign the stereochemistry and raise a complaint if not possible. Default is False

  • hydrogens_are_explicit (bool) – Whether the input molecule has explicit information about hydrogen atoms or not. Otherwise, they will be added when the molecule is built. Default is True

  • fix_pdb (bool) – Activates or deactivate the PDB fixer that is executed prior parsing it

Examples

Load a molecule from a PDB file and parameterize it with Open Force Field

>>> from peleffy.topology import Molecule
>>> molecule = Molecule('molecule.pdb')
>>> molecule.parameterize('openff_unconstrained-1.2.0.offxml')

Load a molecule using a SMILES tag and parameterize it with Open Force Field

>>> from peleffy.topology import Molecule
>>> molecule = Molecule(smiles='Cc1ccccc1')

Load a molecule usign a PDB file (without connectivity) and assign the missing connectivity from an RDKit template (e.g. obtained from qcportal and the Open Force Field Toolkit)

>>> import qcportal as ptl
>>> from openff.toolkit.topology import Molecule as OFFMolecule
>>> ds = client.get_collection('OptimizationDataset',
                               'Kinase Inhibitors: WBO Distributions')
>>> entry = ds.get_entry(ds.df.index[0])
>>> mol_record = OFFMolecule.from_qcschema(entry)
>>> template = mol_record.to_rdkit()
>>> from peleffy.topology import Molecule
>>> molecule = Molecule('PDB_without_connectivity.pdb',
                        template=template)

Load a molecule and create its rotamer library template with a core constraint

>>> from peleffy.topology import Molecule
>>> from peleffy.topology import RotamerLibrary
>>> molecule = Molecule(smiles='CCCC', name='butane', tag='BUT',
                        exclude_terminal_rotamers=False,
                        core_constraints=[0, ])
>>> rotamer_library = RotamerLibrary(mol)
>>> rotamer_library.to_file('butz')

Deactivate OpenFF Toolkit’s stereochemistry checking when loading a molecule

>>> from peleffy.topology import Molecule
>>> molecule = Molecule('molecule_with_undefined_stereochemistry.pdb',
                        allow_undefined_stereo=True)

Load a molecule with no explicit hydrogen atoms and ask the builder to add them

>>> from peleffy.topology import Molecule
>>> molecule = Molecule('molecule_with_implicit_hydrogen.pdb',
                        hydrogens_are_explicit=False)

Display the molecular representation in a Jupyter Notebook

>>> from peleffy.topology import Molecule
>>> molecule = Molecule(smiles='CCCC', name='butane', tag='BUT')
>>> display(molecule)
static from_openff(openff_molecule, rotamer_resolution=30, exclude_terminal_rotamers=True, name='', tag='UNK', connectivity_template=None, core_constraints=[], allow_undefined_stereo=False, hydrogens_are_explicit=True)[source]

It initializes and returns a peleffy Molecule representation from an OpenForceField molecular representation.

Parameters
  • openff_molecule (an openforcefield.topology.Molecule object) – The OpenForceField’s Molecule to use to initialize a peleffy Molecule object

  • rotamer_resolution (float) – The resolution in degrees to discretize the rotamer’s conformational space. Default is 30

  • exclude_terminal_rotamers (bool) – Whether to exclude terminal rotamers when generating the rotamers library or not

  • name (str) – The molecule name

  • tag (str) – The molecule tag. It must be a 3-character string

  • connectivity_template (an rdkit.Chem.rdchem.Mol object) – A molecule represented with RDKit to use when assigning the connectivity of this Molecule object

  • core_constraints (list[int or str]) – It defines the list of atoms to constrain in the core, thus, the core will be forced to contain them. Atoms can be specified through integers that match the atom index or strings that match with the atom PDB name

  • allow_undefined_stereo (bool) – Whether to allow a molecule with undefined stereochemistry to be defined or try to assign the stereochemistry and raise a complaint if not possible. Default is False

  • hydrogens_are_explicit (bool) – Whether the input molecule has explicit information about hydrogen atoms or not. Otherwise, they will be added when the molecule is built. Default is True

Returns

molecule – The resulting peleffy’s Molecule object

Return type

an peleffy.topology.Molecule

Examples

Load a molecule from an RDKit molecular representation

>>> from rdkit import Chem
>>> rdkit_molecule = Chem.MolFromPDBFile(pdb_path)
>>> from peleffy.topology import Molecule
>>> molecule = Molecule.from_rdkit(rdkit_molecule)
static from_rdkit(rdkit_molecule, rotamer_resolution=30, exclude_terminal_rotamers=True, name='', tag='UNK', connectivity_template=None, core_constraints=[], allow_undefined_stereo=False, hydrogens_are_explicit=True)[source]

It initializes and returns a peleffy Molecule representation from an RDKit molecular representation.

Parameters
  • rdkit_molecule (an rdkit.Chem.rdchem.Mol object) – The RDKit’s Molecule object to use to initialize a peleffy Molecule object

  • rotamer_resolution (float) – The resolution in degrees to discretize the rotamer’s conformational space. Default is 30

  • exclude_terminal_rotamers (bool) – Whether to exclude terminal rotamers when generating the rotamers library or not

  • name (str) – The molecule name

  • tag (str) – The molecule tag. It must be a 3-character string

  • connectivity_template (an rdkit.Chem.rdchem.Mol object) – A molecule represented with RDKit to use when assigning the connectivity of this Molecule object

  • core_constraints (list[int or str]) – It defines the list of atoms to constrain in the core, thus, the core will be forced to contain them. Atoms can be specified through integers that match the atom index or strings that match with the atom PDB name

  • allow_undefined_stereo (bool) – Whether to allow a molecule with undefined stereochemistry to be defined or try to assign the stereochemistry and raise a complaint if not possible. Default is False

  • hydrogens_are_explicit (bool) – Whether the input molecule has explicit information about hydrogen atoms or not. Otherwise, they will be added when the molecule is built. Default is True

Returns

molecule – The resulting peleffy’s Molecule object

Return type

an peleffy.topology.Molecule

Examples

Load a molecule from an RDKit molecular representation

>>> from rdkit import Chem
>>> rdkit_molecule = Chem.MolFromPDBFile(pdb_path, removeHs=False)
>>> from peleffy.topology import Molecule
>>> molecule = Molecule.from_rdkit(rdkit_molecule)
get_conformer()[source]

It gets the current conformer of the molecule.

Returns

conformer – The array of 3D coordinates of all the atoms in the molecule

Return type

numpy.ndarray

get_pdb_atom_names()[source]

It returns the PDB atom names of all the atoms in the molecule.

Returns

pdb_atom_names – The PDB atom names of all the atoms in this Molecule object

Return type

list[str]

set_conformer(conformer)[source]

It sets a new conformer to the molecule.

Parameters

conformer (an RDKit.Chem.rdchem.Conformer object) – The conformer to set to the molecule

set_name(name)[source]

It sets the name of the molecule.

Parameters

name (str) – The name to set to the molecule

set_tag(tag)[source]

It sets the tag of the molecule. It must be a 3-character string.

Parameters

tag (str) – The tag to set to the molecule. It must be a 3-character string

to_pdb_file(path)[source]

It writes the molecule to a PDB file.

Parameters

path (str) – Path to write to

Attributes

allow_undefined_stereo

Whether to allow a molecule with undefined stereochemistry to be defined or try to assign the stereochemistry and raise a complaint if not possible

connectivity_template

The template containing the correct connectivity for this Molecule object.

core_constraints

The list of indices or PDB names of the atoms to constraint to the core when building the rotamers.

exclude_terminal_rotamers

The behavior when handling terminal rotamers when generating the rotamers library.

fix_pdb

It activates or deactivates the PDB fixer prior parsing the PDB file.

graph

The topological graph of the molecule.

hydrogens_are_explicit

Whether the input molecule has explicit information about hydrogen atoms or not.

name

Molecule’s name.

off_molecule

The OpenForceField’s molecule instance linked to the molecule.

rdkit_molecule

The RDKit’s molecule instance linked to the molecule.

rotamer_resolution

The resolution to be used when generating the rotamers library.

rotamers

The list of rotamers of the molecule.

tag

Molecule’s tag.