moldesign.helpers package

Submodules

moldesign.helpers.helpers module

This module contains various helper functions used by MDT internally.

class moldesign.helpers.helpers.VolumetricGrid(positions, padding=<Quantity(2.5, 'ang')>, npoints=25)[source]

Bases: object

Helper object for preparing gaussian CUBE files

UNITS = <Unit('ang')>
origin()[source]
xyzlist()[source]
moldesign.helpers.helpers.colormap(cats, mplmap='auto')[source]
moldesign.helpers.helpers.get_all_atoms(*objects)[source]

Given Atoms, AtomContainers, lists of Atoms, and lists of AtomContainers, return a flat list of all atoms contained therein.

A given atom is only returned once, even if it’s found more than once.

Parameters:(moldesign.Atom OR moldesign.AtomContainer OR List[moldesign.Atom] OR (*objects) – List[moldesign.AtomContainer]): objects to take atoms from
moldesign.helpers.helpers.kinetic_energy(momenta, masses)[source]
moldesign.helpers.helpers.kinetic_temperature(ke, dof)[source]

moldesign.helpers.pdb module

PDB file parsing utilities

We don’t yet (and hopefully will never need) an internal PDB parser or writer. For now, routines in this module read and write data that’s not necessarily parsed by other implementations.

class moldesign.helpers.pdb.BioAssembly(desc, chains, transforms)

Bases: tuple

chains

Alias for field number 1

desc

Alias for field number 0

transforms

Alias for field number 2

moldesign.helpers.pdb.assign_biopolymer_bonds(mol)[source]

Assign bonds to all standard residues using the PDB chemical component dictionary

Any unrecognized residues are ignored.

References

http://www.wwpdb.org/data/ccd

moldesign.helpers.pdb.assign_unique_hydrogen_names(mol)[source]

Assign unique names to all hydrogens, based on either: 1) information in the Chemical Component Database, or 2) newly generated, unique names

Parameters:mol (moldesign.Molecule) –
moldesign.helpers.pdb.get_conect_records(pdbfile)[source]

Parse a PDB file, return CONECT records

Bond orders are assigned as 1 by default. Repeated CONECT records are interpreted as higher order bonds.

Parameters:pdbfile (file) – file-like object

Example

> CONECT 1 2 3 > CONECT 1 2 > CONECT 2 1 1 > CONECT 3 1 These records are interpreted as a double-bond between atoms 1 and 2 and a single bond between atoms 1 and 3

Note

This only returns the covalent CONECT records (the first 4 entries) - it doesn’t return salt bridges or hydrogen bonds

Returns:
CONECT records using serial numbers -
{serial1: {serial2:order. serial3:order, }, ...}
Return type:dict
moldesign.helpers.pdb.get_pdb_assemblies(fileobj)[source]

Parse a PDB file, return biomolecular assembly specifications

Parameters:fileobj (file-like) – File-like object for the PDB file (this object will be rewound before returning)
Returns:dict mapping assembly ids to BioAssembly instances
Return type:Mapping[str, BioAssembly]
moldesign.helpers.pdb.guess_atnum_from_name(s)[source]

Guess an atomic number given a name string (usually 1-3 characters).

Parameters:s (str) – atomic number
Returns:atomic number
Return type:int
Raises:KeyError – if atomic number can’t be determined

Examples

>>> guess_atnum_from_name('C')
6
>>> guess_atnum_from_name('C1')
6
>>> guess_atnum_from_name('cl3')
17
>>> guess_atnum_from_name('CL')
17
moldesign.helpers.pdb.insert_ter_records(mol, pdbfile)[source]

Inserts TER records to indicate the end of the biopolymeric part of a chain

Many common PDB writers - including OpenBabel - don’t insert TER records. This can cause a problem for situations such as forcefield assignment. This routine is one solution to that problem.

What it does: This routine inserts ‘TER’ records 1) after any protein residue not bound to the next residue via backbone peptide bond, and 2) after any DNA residue not bound to the next residue via a backbone phosphate bond

In the input PDB file, the ATOM records be formatted with the proper columns (see http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM) and the chain names and residue numbers must match chain.pdbname and residue.pdbindex, respectively.

Parameters:
  • mol (moldesign.Molecule) – the MDT version of the molecule that pdbfile describes
  • pdbfile (TextIO OR str) – pdb file (file-like or string)
Returns:

copy of the pdb file with added TER records - it will be

returned as the same type passed (i.e., as a filelike buffer or as a string)

Return type:

cStringIO.StringIO OR str

moldesign.helpers.pdb.warn_assemblies(mol, assemblies)[source]

Print a warning message if the PDB structure contains a biomolecular assembly