This module handles preparing molecules for Osprey designs, and building Conformation Spaces from those molecules.
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.
Enumeration: Hybridization
Sp3:
Sp2:
Sp:
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 Time-tested protein forcefield and historical favorite of the Donald Lab.
Amber14SB Currently recommended by Amber 19 for simulation of proteins.
EEF1 Calculates solvation energies for proteins in water.
loadPDB(pdb)
Loads molecules from a string in PDB format. Supports reading any kind of molecule, including proteins.
Arguments
str: The text of a PDB fileReturns
[Molecule]: The molecules from the PDB file
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(omol)
Load molecules from a string in OMOL format.
Arguments
str: The text of the OMOL file.Returns
[Molecule]: The molecules from the OMOL file
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
[Molecule]: The molecules to saveReturns
str: The text of an OMOL file representing the given molecules
loadConfSpace(toml)
Loads a conformation space from a string
Arguments
str: The text of a conformation space file, as generated by saveConfSpaceReturns
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
Returns
str: The text of a conformation space file representing the given conformation space
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(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
Returns
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
Returns
inferMissingAtoms(mol)
Uses Amber forcefields to infer missing heavy atoms and their positions.
Arguments
Returns
inferBonds(mol)
Uses Amber forcefields to infer atom connectivity, but not bond order.
Arguments
Returns
inferProtonation(mol)
Returns a list of heavy-hydrogen atom pairs based on inferred forcefield atom and bond types.
Arguments
Returns
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(mol, atom, numH, hybridization)
Adds hydrogens atoms to the atom in the supplied protonation state.
Arguments
minimizerInfo(mol, restrainedAtoms)
Holds molecule information for a later call to minimize
Arguments
Returns
minimize(minimizerInfos, numSteps)
Minimize the selected molecules with molecule-associated information using sander from AmberTools
Arguments
[MinimizerInfo]: The molecules (and their associated information) to minimizeConfSpace(mols)
Create a new conformation space from a list of molecules
Arguments
Returns
ProteinDesignPosition(protein, chainId, resId, name=None)
Makes a design position for a conformation space from a protein residue
Arguments
Returns
DihedralAngleSettings(radiusDegrees=9.0, includeHydroxyls=True, includeNonHydroxylHGroups=False)
Settings for dihedral angles
The default values match Osprey’s classic settings.
Arguments
float: Amount of rotation allowed in either direction from the starting angle, in degreesbool: True to include dihedral angles for hydroxyl groupsbool: True to include dihedral angles for other groups, like methyl groupsReturns
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
DihedralAngleSettingsReturns
moleculeDihedralAngle(mol, a, b, c, d, settings)
Creates a dihedral angle motion for a general molecule, outside of a design position
Arguments
str: the name of first atom to define the dihedral anglestr: the name of second atom to define the dihedral anglestr: the name of third atom to define the dihedral anglestr: the name of fourth atom to define the dihedral angleDihedralAngleSettingsReturns
moleculeTranslationRotation(mol, dist=1.2, degrees=5.0)
Creates a translation/rotation motion for a general molecule
Arguments
float: the maximum distance in Angstroms to translate from the original positionfloat: the maximum angle in degrees to rotate from the original orientationReturns
ConfSpaceCompiler(confSpace)
Creates the compiler for a conformation space
Arguments
Returns