osprey.prep

This module handles preparing molecules for Osprey designs, and building Conformation Spaces from those molecules.

LocalService Objects

class LocalService()

Runs an instance of the Osprey Service locally on this machine.

Only works on Linux.

Access the service in Python code by using a with guard:

from osprey.prep import LocalService
with LocalService():
	# run code that uses the service here

If a function here needs the Osprey Service, but the Osprey Service is not running, that function will raise an Exception.

Hybridization

Enumeration: Hybridization

  • Sp3:

  • Sp2:

  • Sp:

confLibs

List<ConfLibInfo>

Forcefield Objects

class Forcefield()

All the forcefields supported by Osprey for energy calculations

For example, to reference one of the forcefields in Python code:

from osprey.prep import Forcefield
ff = Forcefield.Amber96

Amber96

Amber96 Time-tested protein forcefield and historical favorite of the Donald Lab.

Amber14SB

Amber14SB Currently recommended by Amber 19 for simulation of proteins.

EEF1

EEF1 Calculates solvation energies for proteins in water.

loadPDB

loadPDB(pdb)

Loads molecules from a string in PDB format. Supports reading any kind of molecule, including proteins.

Arguments

  • pdb str: The text of a PDB file

Returns

[Molecule]: The molecules from the PDB file

savePDB

savePDB(mol)

Saves a molecule to a string in PDB format.

If writing the string to a file, you should use the w option to open():

import osprey.prep
with open('path/to/file.pdb', 'w') as file:
    file.write(osprey.prep.savePDB(mol))

PDB files cannot save all the information from this molecule representation. Unless you explicitly need to export your molecules to PDB format, try saving your molecules in OMOL format, which will save all the information from this molecule representation.

Arguments

Returns

str: The text of a PDB file representing the given molecule

loadOMOL

loadOMOL(omol)

Load molecules from a string in OMOL format.

Arguments

  • omol str: The text of the OMOL file.

Returns

[Molecule]: The molecules from the OMOL file

saveOMOL

saveOMOL(mols)

Saves molecules to a string in OMOL format, Osprey’s native molecule file format.

If writing the string to a file, you should use the w option to open():

import osprey.prep
with open('path/to/file.omol', 'w') as file:
    file.write(osprey.prep.saveOMOL(mols))

The canonical filename extension for an Osprey molecule is .omol.

Saving Osprey molecules into OMOL format is lossless. All information about this molecule representation will be saved, unlike saving into the PDB format, which cannot represent all the information about this molecule representation. Prefer to save your molecules into OMOL format if you want to load them in Osprey again.

Arguments

  • mols [Molecule]: The molecules to save

Returns

str: The text of an OMOL file representing the given molecules

loadConfSpace

loadConfSpace(toml)

Loads a conformation space from a string

Arguments

  • toml str: The text of a conformation space file, as generated by saveConfSpace

Returns

ConfSpace

saveConfSpace

saveConfSpace(confSpace)

Saves a conformation space to a string

If writing the string to a file, you should use the w option to open():

import osprey.prep
with open('path/to/file.confspace', 'w') as file:
    file.write(osprey.prep.saveConfSpace(confSpace))

The canonical filename extension for a conformation space is .confspace.

Arguments

  • confSpace ConfSpace: The conformation space to save

Returns

str: The text of a conformation space file representing the given conformation space

saveCompiledConfSpace

saveCompiledConfSpace(ccs)

Saves a compiled conformation space to bytes

If writing the bytes to a file, you should use the wb option to open():

import osprey.prep
with open('path/to/file.ccsx', 'wb') as file:
    file.write(osprey.prep.saveCompiledConfSpace(ccs))

The canonical filename extension for a compiled conformation space with compression is .ccsx.

Due to the large size of the compiled conformation space, the saved representation is an efficient compressed binary format, rather than a human-readable text format.

Arguments

Returns

byte[]: The bytes of a compiled conformation space file representing the given compiled conformation space

molTypes

molTypes(mol)

Returns the types of the molecules in the Molecule instance based on AMBER rules for residue classification. Generally, the Molecule instance will describe only one molecule, so the returned set will have only one type. But, if the Molecule instance actually represents multiple molecules, this function will return a molecule type for each molecule present.

Arguments

  • mol Molecule: The molecule (or multiple molecules in a single Molecule instance) for which to determine molecule types

Returns

Set<MoleculeType>

duplicateAtoms

duplicateAtoms(mol)

Detects atom duplications in a molecule, and provides tools for removing one of the duplicated atoms. PDB files from the Protein Data Bank are usually very high quality files, but rarely a third-party tool will create a malformed PDB file with duplicated atoms. This tool can help correct those errors.

Arguments

  • mol Molecule: : The molecule for which to search for duplicate atoms

Returns

DuplicateAtoms

inferMissingAtoms

inferMissingAtoms(mol)

Uses Amber forcefields to infer missing heavy atoms and their positions.

Arguments

  • mol Molecule: The molecule for which to infer missing atoms

Returns

List<MissingAtom>

inferBonds

inferBonds(mol)

Uses Amber forcefields to infer atom connectivity, but not bond order.

Arguments

  • mol Molecule: The molecule for which to infer bonds

Returns

List<AtomPair>

inferProtonation

inferProtonation(mol)

Returns a list of heavy-hydrogen atom pairs based on inferred forcefield atom and bond types.

Arguments

  • mol Molecule: The molecule for which to infer protonation

Returns

List<ProtonatedAtom>

deprotonate

deprotonate(mol, atoms=None)

Deprotonates a molecule or certain atoms in a molecule.

Without supplying an argument for atom, the entire molecule is deprotonated. When atom is supplied, it should be supplied as an iterable of atoms.

Arguments

  • mol Molecule: The molecule from which to remove atoms

  • atoms [Atom]: An iterable of atoms from which to remove protons, instead of deprotonating the whole molecule.

protonate

protonate(mol, atom, numH, hybridization)

Adds hydrogens atoms to the atom in the supplied protonation state.

Arguments

  • mol Molecule: The molecule to which to add Hydrogen atoms
  • atom Atom: : The atom in the molecule to which to add Hydrogen atoms
  • numH Int: : The number of Hydrogen atoms to add
  • hybridization Hybridization: : The hybridization state

minimizerInfo

minimizerInfo(mol, restrainedAtoms)

Holds molecule information for a later call to minimize

Arguments

  • mol Molecule:
  • restrainedAtoms [Atom]: List of atoms to restrain during the minimization

Returns

MinimizerInfo

minimize

minimize(minimizerInfos, numSteps)

Minimize the selected molecules with molecule-associated information using sander from AmberTools

Arguments

  • minimizerInfos [MinimizerInfo]: The molecules (and their associated information) to minimize
  • numSteps Int: : The number of steps to minimize

ConfSpace

ConfSpace(mols)

Create a new conformation space from a list of molecules

Arguments

Returns

ConfSpace

ProteinDesignPosition

ProteinDesignPosition(protein, chainId, resId, name=None)

Makes a design position for a conformation space from a protein residue

Arguments

  • protein Polymer: The protein from which to make the design position
  • chainId String:
  • resId String:
  • name String: : a recognizable name for the design position

Returns

DesignPosition

DihedralAngleSettings

DihedralAngleSettings(radiusDegrees=9.0, includeHydroxyls=True, includeNonHydroxylHGroups=False)

Settings for dihedral angles

The default values match Osprey’s classic settings.

Arguments

  • radiusDegrees float: Amount of rotation allowed in either direction from the starting angle, in degrees
  • includeHydroxyls bool: True to include dihedral angles for hydroxyl groups
  • includeNonHydroxylHGroups bool: True to include dihedral angles for other groups, like methyl groups

Returns

LibrarySettings

conformationDihedralAngles

conformationDihedralAngles(pos, confInfo, settings)

Create motions from all the dihedral angles in the conformation library, so the motions can be added to a conformation at a design position

Arguments

Returns

List<ConfDescription>

moleculeDihedralAngle

moleculeDihedralAngle(mol, a, b, c, d, settings)

Creates a dihedral angle motion for a general molecule, outside of a design position

Arguments

  • mol Molecule: The molecule for which to create the motion
  • a str: the name of first atom to define the dihedral angle
  • b str: the name of second atom to define the dihedral angle
  • c str: the name of third atom to define the dihedral angle
  • d str: the name of fourth atom to define the dihedral angle
  • settings LibrarySettings: dihedral angle settings, from DihedralAngleSettings

Returns

MolDescription

moleculeTranslationRotation

moleculeTranslationRotation(mol, dist=1.2, degrees=5.0)

Creates a translation/rotation motion for a general molecule

Arguments

  • mol Molecule: The molecule for which to create the motion
  • dist float: the maximum distance in Angstroms to translate from the original position
  • degrees float: the maximum angle in degrees to rotate from the original orientation

Returns

MolDescription

ConfSpaceCompiler

ConfSpaceCompiler(confSpace)

Creates the compiler for a conformation space

Arguments

  • confSpace ConfSpace: : the conformation space to compile

Returns

ConfSpaceCompiler