moldesign.interfaces package

Submodules

moldesign.interfaces.ambertools module

class moldesign.interfaces.ambertools.AmberParameters(prmtop, inpcrd, job)

Bases: tuple

inpcrd

Alias for field number 1

job

Alias for field number 2

prmtop

Alias for field number 0

moldesign.interfaces.ambertools.ExtraAmberParameters

alias of GAFFParameters

exception moldesign.interfaces.ambertools.ParameterizationError[source]

Bases: exceptions.Exception

moldesign.interfaces.ambertools.assign_forcefield(mol, **kwargs)[source]

run_tleap(mol, forcefields=None, parameters=None, engine=None, image=None, wait=True, jobname=None, display=True) Drives tleap to create a prmtop and inpcrd file. Specifically uses the AmberTools 16 tleap distribution.

Defaults are as recommended in the ambertools manual.

Parameters:
  • mol (moldesign.Molecule) – Molecule to set up
  • forcefields (List[str]) – list of the names of forcefields to use (see AmberTools manual for descriptions)
  • parameters (List[ExtraAmberParameters]) – (optional) list of amber parameters for non-standard residues
  • engine (pyccc.Engine) – Engine to run this job on (default: moldesign.compute.get_engine())
  • image (str) – URL for the docker image
  • wait (bool) – if True, block until this function completes and return the function’s return value. Otherwise, return a job object immediately that can be queried later.
  • jobname – argument for moldesign.compute.compute.run_job()
  • display (bool) – if True, show logging output for this job

References

Ambertools Manual, http://ambermd.org/doc12/Amber16.pdf. See page 33 for forcefield recommendations.

moldesign.interfaces.ambertools.build_bdna(sequence, **kwargs)[source]

Uses Ambertools’ Nucleic Acid Builder to build a 3D double-helix B-DNA structure.

Parameters:
  • sequence (str) – DNA sequence for one of the strands (a complementary sequence will automatically be created)
  • engine (pyccc.Engine) – Engine to run this job on (default: moldesign.compute.get_engine())
  • image (str) – URL for the docker image
  • wait (bool) – if True, block until this function completes and return the function’s return value. Otherwise, return a job object immediately that can be queried later.
  • jobname – argument for moldesign.compute.compute.run_job()
  • display (bool) – if True, show logging output for this job
Returns:

B-DNA double helix

Return type:

moldesign.Molecule

moldesign.interfaces.ambertools.build_dna_helix(sequence, helix_type='B', **kwargs)[source]

Uses Ambertools’ Nucleic Acid Builder to build a 3D DNA double-helix.

Parameters:
  • sequence (str) – DNA sequence for one of the strands (a complementary sequence will automatically be created)
  • helix_type (str) – Type of helix - ‘A’=Arnott A-DNA ‘B’=B-DNA (from standard templates and helical params), ‘LB’=Langridge B-DNA, ‘AB’=Arnott B-DNA, ‘SB’=Sasisekharan left-handed B-DNA
  • engine (pyccc.Engine) – Engine to run this job on (default: moldesign.compute.get_engine())
  • image (str) – URL for the docker image
  • wait (bool) – if True, block until this function completes and return the function’s return value. Otherwise, return a job object immediately that can be queried later.
  • jobname – argument for moldesign.compute.compute.run_job()
  • display (bool) – if True, show logging output for this job

All helix types except ‘B’ are taken from fiber diffraction data (see the refernce for details)

Returns:B-DNA double helix
Return type:moldesign.Molecule

References

See NAB / AmberTools documentation: http://ambermd.org/doc12/Amber16.pdf, pg 771-2

moldesign.interfaces.ambertools.calc_am1_bcc_charges(mol, **kwargs)[source]

Calculate am1 bcc charges

Parameters:mol (moldesign.Molecule) – assign partial charges to this molecule (they will be stored at mol.properties['am1-bcc'])

Note

This will implicity run an AM1 energy minimization before calculating the final partial charges. For more control over this process, use the moldesign.models.SQMPotential energy model to calculate the charges.

Returns:AM1-BCC partial charges on each atom
Return type:Mapping[moldesign.Atom, units.Scalar[charge]]
moldesign.interfaces.ambertools.calc_gasteiger_charges(mol, **kwargs)[source]

Calculate gasteiger charges

Parameters:mol (moldesign.Molecule) – assign partial charges to this molecule
Returns:
gasteiger partial charges on each atom
(they will be stored at mol.properties['gasteiger'])
Return type:Mapping[moldesign.Atom, units.Scalar[charge]]
moldesign.interfaces.ambertools.parameterize(mol, charges='esp', ffname='gaff2', **kwargs)[source]

Parameterize mol, typically using GAFF parameters.

This will both assign a forcefield to the molecule (at mol.ff) and produce the parameters so that they can be used in other systems (e.g., so that this molecule can be simulated embedded in a larger protein)

Note

‘am1-bcc’ and ‘gasteiger’ partial charges will be automatically computed if necessary. Other charge types must be precomputed.

Parameters:
  • mol (moldesign.Molecule) –
  • charges (str or dict) –
    what partial charges to use? Can be a dict ({atom:charge}) OR
    a string, in which case charges will be read from

    mol.properties.[charges name]; typical values will be ‘esp’, ‘mulliken’, ‘am1-bcc’, etc. Use ‘zero’ to set all charges to 0 (for QM/MM and testing)

  • ffname (str) – Name of the gaff-like forcefield file (default: gaff2)
Returns:

Parameters for the molecule; this object can be used to create

forcefield parameters for other systems that contain this molecule

Return type:

ExtraAmberParameters

moldesign.interfaces.ambertools.run_tleap(mol, forcefields=None, parameters=None, **kwargs)[source]

Drives tleap to create a prmtop and inpcrd file. Specifically uses the AmberTools 16 tleap distribution.

Defaults are as recommended in the ambertools manual.

Parameters:
  • mol (moldesign.Molecule) – Molecule to set up
  • forcefields (List[str]) – list of the names of forcefields to use (see AmberTools manual for descriptions)
  • parameters (List[ExtraAmberParameters]) – (optional) list of amber parameters for non-standard residues
  • engine (pyccc.Engine) – Engine to run this job on (default: moldesign.compute.get_engine())
  • image (str) – URL for the docker image
  • wait (bool) – if True, block until this function completes and return the function’s return value. Otherwise, return a job object immediately that can be queried later.
  • jobname – argument for moldesign.compute.compute.run_job()
  • display (bool) – if True, show logging output for this job

References

Ambertools Manual, http://ambermd.org/doc12/Amber16.pdf. See page 33 for forcefield recommendations.

moldesign.interfaces.biopython_interface module

moldesign.interfaces.biopython_interface.biopy_to_mol(struc)[source]

Convert a biopython PDB structure to an MDT molecule.

Note

Biopython doesn’t deal with bond data, so no bonds will be present in the Molecule

Parameters:struc (Bio.PDB.Structure.Structure) – Biopython PDB structure to convert
Returns:converted molecule
Return type:moldesign.Molecule
moldesign.interfaces.biopython_interface.get_mmcif_assemblies(fileobj=None, mmcdata=None)[source]

Parse an mmCIF file, return biomolecular assembly specifications

Parameters:
  • fileobj (file-like) – File-like object for the PDB file (this object will be rewound before returning)
  • mmcdata (dict) – dict version of complete mmCIF data structure (if passed, this will not be read again from fileobj)
Returns:

dict mapping assembly ids to BioAssembly instances

Return type:

Mapping[str, BioAssembly]

moldesign.interfaces.biopython_interface.parse_mmcif(f)[source]

Parse an mmCIF file (using the Biopython parser) and return a molecule

Note

This routine is not currently called by any part of the user-facing API! The OpenBabel parser appears to give more accurate results for the time being. The molecules created using this routine will NOT have any bond topology!

Parameters:f (file) – file-like object containing the mmCIF file
Returns:parsed molecule
Return type:moldesign.Molecule
moldesign.interfaces.biopython_interface.parse_pdb(f)[source]

Parse a PDB file (using the Biopython parser) and return the basic structure

Note

This structure will be missing some key data - most notably bonds, but also any biomolecular assembly information. Therefore, our default parser combines this routine with a few other methods to create the final Molecule object

See also

moldesign.fileio.read_pdb

Parameters:f (file) – file-like object containing the PDB file
Returns:parsed molecule
Return type:moldesign.Molecule

moldesign.interfaces.nbo_interface module

moldesign.interfaces.nbo_interface.add_orbitals(mol, wfn, orbdata, orbtype)[source]
moldesign.interfaces.nbo_interface.append_matrix(l, mat)[source]
moldesign.interfaces.nbo_interface.make_nbo_input_file(mol, requests)[source]
Parameters:mol (moldesign.molecules.Molecule) –
Returns:
moldesign.interfaces.nbo_interface.parse_nbo(f, nbasis)[source]
moldesign.interfaces.nbo_interface.read_orbital_set(lineiter, nbasis)[source]
moldesign.interfaces.nbo_interface.run_nbo(mol, requests=('nlmo', 'nbo'), image='nbo', engine=None)[source]

moldesign.interfaces.openbabel module

moldesign.interfaces.openbabel.add_hydrogen(mol, ph=None, wait=True)[source]

Add hydrogens to saturate atomic valences.

Parameters:
  • mol (moldesign.Molecule) – Molecule to saturate
  • ph (float) – Assign formal charges and protonation using pH model; if None (the default), neutral protonation will be assigned where possible.
Returns:

New molecule with all valences saturated

Return type:

moldesign.Molecule

moldesign.interfaces.openbabel.from_smiles(smi, name=None, wait=True)[source]

Translate a smiles string to a 3D structure. This method uses OpenBabel to generate a plausible 3D conformation of the 2D SMILES topology. We only use the first result from the conformation generator.

Parameters:
  • smi (str) – smiles string
  • name (str) – name to assign to molecule (default - the smiles string)
Returns:

the translated molecule

Return type:

moldesign.Molecule

moldesign.interfaces.openbabel.guess_bond_orders(mol, wait=True)[source]

Use OpenBabel to guess bond orders using geometry and functional group templates.

Parameters:mol (moldesign.Molecule) – Molecule to perceive the bonds of
Returns:New molecule with assigned bonds
Return type:moldesign.Molecule
moldesign.interfaces.openbabel.mol_to_pybel(mdtmol)[source]

Translate a moldesign molecule object into a pybel molecule object.

Note

The focus is on translating topology and biomolecular structure - we don’t translate any metadata.

Parameters:mdtmol (moldesign.Molecule) – molecule to translate
Returns:translated molecule
Return type:pybel.Molecule
moldesign.interfaces.openbabel.pybel_to_mol(pbmol, atom_names=True, reorder_atoms_by_residue=False, primary_structure=True, **kwargs)[source]

Translate a pybel molecule object into a moldesign object.

Note

The focus is on translating topology and biomolecular structure - we don’t translate any metadata.

Parameters:
  • pbmol (pybel.Molecule) – molecule to translate
  • atom_names (bool) – use pybel’s atom names (default True)
  • reorder_atoms_by_residue (bool) – change atom order so that all atoms in a residue are stored contiguously
  • primary_structure (bool) – translate primary structure data as well as atomic data
  • **kwargs (dict) – keyword arguments to moldesign.Molecule __init__ method
Returns:

translated molecule

Return type:

moldesign.Molecule

moldesign.interfaces.openbabel.read_file(filename, name=None, format=None)[source]

Read a molecule from a file

Note

Currently only reads the first conformation in a file

Parameters:
  • filename (str) – path to file
  • name (str) – name to assign to molecule
  • format (str) – File format: pdb, sdf, mol2, bbll, etc.
Returns:

parsed result

Return type:

moldesign.Molecule

moldesign.interfaces.openbabel.read_stream(filelike, format, name=None)[source]

Read a molecule from a file-like object

Note

Currently only reads the first conformation in a file

Parameters:
  • filelike – a file-like object to read a file from
  • format (str) – File format: pdb, sdf, mol2, bbll, etc.
  • name (str) – name to assign to molecule
Returns:

parsed result

Return type:

moldesign.Molecule

moldesign.interfaces.openbabel.read_string(molstring, format, name=None, wait=True)[source]

Read a molecule from a file-like object

Note

Currently only reads the first conformation in a file

Parameters:
  • molstring (str) – string containing file contents
  • format (str) – File format: pdb, sdf, mol2, bbll, etc.
  • name (str) – name to assign to molecule
Returns:

parsed result

Return type:

moldesign.Molecule

moldesign.interfaces.openbabel.write_file(mol, filename=None, mode='w', format=None)[source]

Write molecule to a file

Parameters:
  • mol (moldesign.Molecule) – molecule to write
  • filename (str) – File to write to
  • mode (str) – Writing mode (e.g. ‘w’ to overwrite, the default, or ‘a’ to append)
  • format (str) – File format: pdb, sdf, mol2, bbll, etc.
moldesign.interfaces.openbabel.write_string(mol, format, wait=True)[source]

Create a file from the passed molecule

Parameters:
  • mol (moldesign.Molecule) – molecule to write
  • format (str) – File format: pdb, sdf, mol2, bbll, etc.
Returns:

contents of the file

Return type:

str

moldesign.interfaces.openmm module

moldesign.interfaces.openmm.MdtReporter(mol, report_interval)[source]
class moldesign.interfaces.openmm.OpenMMPickleMixin[source]

Bases: object

moldesign.interfaces.openmm.amber_to_mol(prmtop_file, inpcrd_file)[source]
moldesign.interfaces.openmm.mol_to_modeller(mol)[source]
moldesign.interfaces.openmm.mol_to_topology(mol)[source]

Create an openmm topology object from an MDT molecule

Parameters:mol (moldesign.Molecule) – molecule to copy topology from
Returns:topology of the molecule
Return type:simtk.openmm.app.Topology
moldesign.interfaces.openmm.pint2simtk(quantity)[source]

Converts a quantity from the pint to simtk unit system. Note SimTK appears limited, esp for energy units. May need to have pint convert to SI first

moldesign.interfaces.openmm.simtk2pint(quantity, flat=False)[source]

Converts a quantity from the simtk unit system to a quantity from the pint unit system :param quantity: :param flat: if True, flatten 3xN arrays to 3N

moldesign.interfaces.openmm.topology_to_mol(topo, name=None, positions=None, velocities=None, assign_bond_orders=True)[source]

Convert an OpenMM topology object into an MDT molecule.

Parameters:
  • topo (simtk.openmm.app.topology.Topology) – topology to convert
  • name (str) – name to assign to molecule
  • positions (list) – simtk list of atomic positions
  • velocities (list) – simtk list of atomic velocities
  • assign_bond_orders (bool) – assign bond orders from templates (simtk topologies do not store bond orders)

moldesign.interfaces.opsin_interface module

moldesign.interfaces.opsin_interface.name_to_smiles(name, image='opsin', engine=None)[source]

moldesign.interfaces.parmed_interface module

moldesign.interfaces.parmed_interface.parmed_to_mdt(pmdmol)[source]

Convert parmed object to MDT object

Parameters:pmdmol (parmed.Structure) – parmed structure to convert
Returns:converted molecule
Return type:mdt.Molecule

moldesign.interfaces.pdbfixer_interface module

moldesign.interfaces.pdbfixer_interface.add_hydrogen(mol, pH=7.4, wait=True)[source]
moldesign.interfaces.pdbfixer_interface.add_water(mol, min_box_size=None, padding=None, ion_concentration=None, neutralize=True, positive_ion='Na+', negative_ion='Cl-', wait=True)[source]

Solvate a molecule in a water box with optional ions

Parameters:
  • mol (moldesign.Molecule) – solute molecule
  • min_box_size (u.Scalar[length] or u.Vector[length]) – size of the water box - either a vector of x,y,z dimensions, or just a uniform cube length. Either this or padding (or both) must be passed
  • padding (u.Scalar[length]) – distance to edge of water box from the solute in each dimension
  • neutralize (bool) – add ions to neutralize solute charge (in addition to specified ion concentration)
  • positive_ion (str) – type of positive ions to add, if needed. Allowed values (from OpenMM modeller) are Cs, K, Li, Na (the default) and Rb
  • negative_ion (str) – type of negative ions to add, if needed. Allowed values (from OpenMM modeller) are Cl (the default), Br, F, and I
  • ion_concentration (float or u.Scalar[molarity]) – ionic concentration in addition to whatever is needed to neutralize the solute. (if float is passed, we assume the number is Molar)
Returns:

new Molecule object containing both solvent and solute

Return type:

moldesign.Molecule

moldesign.interfaces.pdbfixer_interface.mutate(mol, mutationmap, wait=True)[source]

moldesign.interfaces.pyscf_interface module

class moldesign.interfaces.pyscf_interface.StatusLogger(description, columns, logger)[source]

Bases: object

LEN = 15
moldesign.interfaces.pyscf_interface.basis_values(mol, basis, coords, coeffs=None, positions=None, wait=True)[source]

Calculate the orbital’s value at a position in space

Parameters:
  • mol (moldesign.Molecule) – Molecule to attach basis set to
  • basis (moldesign.orbitals.BasisSet) – set of basis functions
  • coords (Array[length]) – List of coordinates (with shape (len(coords), 3))
  • coeffs (Vector) – List of ao coefficients (optional; if not passed, all basis fn values are returned)
Returns:

if coeffs is not passed, an array of basis fn values at each

coordinate. Otherwise, a list of orbital values at each coordinate

Return type:

Array[length]

moldesign.interfaces.pyscf_interface.get_eris_in_basis(basis, orbs, wait=True)[source]

Get electron repulsion integrals transformed in (in form eri[i,j,k,l] = (ij|kl))

moldesign.interfaces.pyscf_interface.mol_to_pyscf(mol, basis, symmetry=None, charge=0, positions=None)[source]

Convert an MDT molecule to a PySCF “Mole” object

moldesign.interfaces.qmmm module

moldesign.interfaces.qtrfit module

Interface to quaternion-based atom alignment routines.

This code has been translated from Fortran to Python

moldesign.interfaces.qtrfit.qtrfit(mol, pos, ref, massweight=True)[source]

Transform the atomic positions in pos to minimize the overall distance to those in ref

This function minimizes the distance between pos and ref. If `massweight`=True, we minimize the mass-weighted distance:

..math::
D = sqrt{ sum_{i=1}^{text{N}} m_i left| mathbf{pos}_i - mathbf{ref}_i right|^2 }

Otherwise, the root-squared distance is used:

..math::
D = sqrt{ sum_{i=1}^{text{N}} left| mathbf{pos}_i - mathbf{ref}_i right|^2 }
Parameters:
  • mol (moldesign.Molecule) – molecule that these arrays describe
  • pos (u.Array) – The Nx3 array to be rotated
  • ref (u.Array) – The Nx3 array to match
  • massweight (bool) – whether to use mass-weighted coordinates (the default)
Returns:

translated and rotated version of pos with minimum RMSD

Return type:

u.Array

References

TODO: reference to original qtrfit code (and license, if it exists)

moldesign.interfaces.symmol_interface module

moldesign.interfaces.symmol_interface.get_aligned_coords(mol, data)[source]
moldesign.interfaces.symmol_interface.parse_output(outfile)[source]
moldesign.interfaces.symmol_interface.run_symmol(mol, tolerance=<Quantity(0.1, 'ang')>, image='symmol', engine=None)[source]