schrodinger.application.desmond.cms module

Classes and functions for dealing with *.cms files.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.desmond.cms.fix_idx_traj_path(path: str) → str

Return the trajectory path for path string with .idx extension.

schrodinger.application.desmond.cms.check_sanity(struc)
schrodinger.application.desmond.cms.mark_fullsystem_ct(struc)

Marks atoms in the constants.CT_TYPE.VAL.FULL_SYSTEM CT with the constants.CT_TYPE and constants.CT_INDEX properties, and returns the marked full_system CT as a ‘Structure’ object.

Parameters:struc – A list of ‘Structure’ objects. The first object should be the “full_system” CT, followed by the component CTs in the same order as in the .cms file.

Note that the returned ‘Structure’ object will be a new one, not the same one as in ‘struc’.

schrodinger.application.desmond.cms.get_box(ct)
Given a CT, extract the following properties’ values:
“r_chorus_box_ax”, “r_chorus_box_ay”, “r_chorus_box_az”, “r_chorus_box_bx”, “r_chorus_box_by”, “r_chorus_box_bz”, “r_chorus_box_cx”, “r_chorus_box_cy”, “r_chorus_box_cz”,

and returns them as a list of float values. The order of the values in the list is the same as written above. A ‘KeyError’ exception will be raised if any property is missing in the CT.

schrodinger.application.desmond.cms.get_boxsize(box)

Given a simulation box in the form of a 3x3 matrix, this function returns the size of the box.

schrodinger.application.desmond.cms.dotprod(v, u)

Returns the dot product of two 3-D vectors.

schrodinger.application.desmond.cms.crossprod(v, u)

Returns the cross product of two 3-D vectors.

schrodinger.application.desmond.cms.norm(v)

Returns the norm of the 3-D vector ‘v’.

schrodinger.application.desmond.cms.get_boxvolume(box)
schrodinger.application.desmond.cms.aslselect_atom(struc, asl, should_mark_fullsystem=True)

Similar as ‘aslselect_atom’, but the ‘struc’ must be a list of CTs (‘Structure’ objects) in the same order as in a .cms file (i.e., the first one must be a “full_system” CT, followed by component CTs). The periodic boundary condition will be taken into account. The constants.CT_TYPE and constants.CT_INDEX atom properties are recognized. This function returns a ‘dict’ object. The keys are CT index (‘full_system’ CT’s index is 0, component CT’s index starts from 1), and the values are list of selected atoms of the corresponding component CT.

schrodinger.application.desmond.cms.has_ffio(ct)

Returns 1 if ‘ct’ has an mmffio block, or 0 if it does not. ‘ct’ should be either a FFIOStructure or a Structure object.

schrodinger.application.desmond.cms.delete_fepio(ct)

Delete the fepio_fep block from the input structure, which should have the block (or the behavior is undefined).

schrodinger.application.desmond.cms.has_fepio(ct)

Returns True if any of the ‘ct’ have a fepio_fep block, or False if they do not.

Parameters:ct – Either a FFIOStructure or a Structure object
schrodinger.application.desmond.cms.get_model_system_type(struc)

Returns 1 if the CTs in ‘struc’ have a fepio_fep block. Returns 2 if the CTs in ‘struc’ have a non-empty ligand atom group and do

not have an fepio_fep block.

Returns 0 otherwise.

Parameters:struc – A list of ffiostructure.FFIOStructure objects.
schrodinger.application.desmond.cms.decomp_rawfep_structure(struc)
class schrodinger.application.desmond.cms.Restrain(atom, k, ref, sigma=None)

Bases: object

__init__(atom, k, ref, sigma=None)
is_same(a)

Returns True if ‘self’ and ‘a’ are the same restraint (regardless the force constant).

merge_with(a)
schrodinger.application.desmond.cms.sort_posre(restr)
schrodinger.application.desmond.cms.merge_relative_restraint(a, b)

The ‘a’ and ‘b’ must be a list. Each element is a list of ‘RelativeRestrain’ objects for the corresponding component CT.

class schrodinger.application.desmond.cms.AtomGroup(atom=None, name=None, index=None)

Bases: object

__init__(atom=None, name=None, index=None)
class schrodinger.application.desmond.cms.Site(type, charge, mass, vdwtype)

Bases: object

__init__(type, charge, mass, vdwtype)
class schrodinger.application.desmond.cms.Pseudo(x, y, z)

Bases: object

__init__(x, y, z)
class schrodinger.application.desmond.cms.Constraint(func, atom_i=0, atom_j=0, atom_k=0, atom_l=0, atom_m=0, c1=0, c2=0, c3=0, c4=0, c5=0, c6=0)

Bases: object

NUM_CONSTRAINT = {'AH1': 1, 'AH2': 2, 'AH3': 3, 'AH4': 4, 'AH5': 5, 'HOH': 3}
__init__(func, atom_i=0, atom_j=0, atom_k=0, atom_l=0, atom_m=0, c1=0, c2=0, c3=0, c4=0, c5=0, c6=0)
num_constraint()
class schrodinger.application.desmond.cms.Vdw(atom_type, func, c)

Bases: object

A class for handling VDW parameters.

__init__(atom_type, func, c)

Constructor.

Parameters:
  • atom_type – A pair of strings for the names of the two atom types. If only one string is given, the other will be considered as the same as the first one. If more than 2 strings are given, only the first two will be used, and the other ones will be ignored.
  • func – A string telling the particular VDW potential type.
  • c – A tuple of floating numbers for the parameters.
c6()

c6 = 4 * epsilon * sigma**6

schrodinger.application.desmond.cms.combine_vdw(v1, v2, comb_rule='geometric')

Given two homogenous Vdw objects ‘v1’ and ‘v2’ and a combination rule ‘comb_rule’, this function returns a Vdw object as a combination of ‘v1’ and ‘v2’.

schrodinger.application.desmond.cms.calc_average_vdw_coeff(struc)

Calculates and returns the average dispersion coefficient.

The unit of the coefficient is in the unit of the original ffio block.

Parameters:struc – A list of schrodinger.structure.Structure objects that have been pre-treated by the prep_struc function.
class schrodinger.application.desmond.cms.Cms(file=None, string=None, remove_ghost_atoms_in_fsys=True)

Bases: schrodinger.structure.Structure

ATOMGROUP_PREFIX = 'i_ffio_grp_'
MODEL_SYSTEM_TYPE = ['standard model system', 'model system for mutation FEP', 'model system for total free energy FEP']
META_ASL = {'heavy_atom': 'not atom.elem H', 'membrane': "atom.s_ffio_ct_type 'membrane'", 'solute': "atom.s_ffio_ct_type 'solute'", 'solute_heavy_atom': "atom.s_ffio_ct_type 'solute' and not atom.elem H", 'solvent': "atom.s_ffio_ct_type 'solvent'", 'solvent_heavy_atom': "atom.s_ffio_ct_type 'solvent' and not atom.elem H"}
PROP_CMS = 's_m_original_cms_file'
PROP_TRJ = 's_chorus_trajectory_file'
__init__(file=None, string=None, remove_ghost_atoms_in_fsys=True)

Initialize cms object

synchronize_fsys_ct()

Sync the fullsystem CT fsys_ct to the component CTs. The handle of the fullsystem CT will remain unchanged. In order to modify the atoms of the cms object, modifications should be made to the component CTs, and then this method called to propagate the changes to the fullsystem CT.

sanitize_for_viparr()

Viparr’s custom mae file reader does not play well with certain characters like square brackets. This is also true when the these characters are ‘escaped’. Thus this method sanitizes offensive property names and their values by replacing them with forward slashes. This method checks if the CT properties are okay for viparr.

get_fep_cts()

find ref and mut cts by fep_fragname property

get_solvent_cts()

find any cts with ffio_ct_type solvent

get_membrane_cts()

Find and structures with ffio_ct_type=membrane

ffio_refresh()

‘atom_index’ starts from 1.

get_fullsys_ct_atom_index_range(comp_ct_index)

for a given component CT, return a map of that compontent CT in full_system CT

get_lambda_atom_indices(l)
Parameters:l – lambda value, 0 or 1
Returns:list of int (for atoms), list of list of int (for virtual sites)
gid_refresh()
gid(atom_index)

`atom_index’ is the index of the atom in the ‘full_system’ CT.

allaid_gids

Get the 0-indexed mapping between aids and gids as a view of the underlying numpy array. :return: np.array

comp_atom_total

Get the sum of the atom totals of the component CTs. For systems with ghost atoms, this will be different than the value of self.atom_total, as that value corresponds to the number of atoms in the fullsystem CT.

site(atom_index)

`atom_index’ starts from 1.

model_system_type()
get_fragname()
select_atom(asl)

Evaluate ASL and meta-ASL. Ghost atoms are removed. Note that ghost atom removal does not work if they are spread across multiple component CTs.

Return type:list of `int`s
select_atom_comp(asl)

Returns a list of lists. Each list element contains a list of atom indices of the corresponding component CT.

get_restrain()
set_restrain(restrain_list)

`restrain_list’ must be a list. Each element must be a list of `Restrain’ objects.

clear_restrain()

Deletes all existing restraints.

get_atom_group()
set_atom_group(atom_group)
merge_atom_group(atom_group)
set_atom_group_from_asl(asl, group_name, group_index)
merge_atom_group_from_asl(asl, group_name, group_index)
delete_atom_group(group_name)
delete_all_atom_group(exception=[])
get_vdw()

Returns the Vdw parameters for all atoms. The returned object is a list. Each element of the returned list is a Vdw object for the corresponding atom.

get_constraint()
get_num_constraint()
set_nactive_gids(nactive_gids, ntotal_gids)

Given a number of active gids, set the number of physical atoms that are active in the fullsystem and solvent CTs, ie self.active_total. Also stores the nactive_gids so that it will be written to disk and can be used by msys models. If nactive_gids == ntotal_gids, this will set self.active_total to self.atom_total, thereby removing the underlying properties from the fullsystem and solvent CTs.

Parameters:
  • nactive_gids (int) – the number of active gids
  • ntotal_gids (int) – the total number of atoms (ie gids) in the frame
active_total_from_nactive_gids(nactive_gids, ntotal_gids)
nactive_gids
is_for_gcmc
active_total

Get the number of active physical atoms :return: The number of active physical atoms :rtype: int

get_degrees_of_freedom()
fix_filenames(cms_fname=None, trj_fname=None)
write(fname)
write_to_string()
addAtom(element, x, y, z, color=None, atom_type=None)

Add a new atom to the structure. Return the created _StructureAtom object.

addAtoms(num_atoms)

Add the specified number of atoms to this structure.

The following atom attributes will have to be set for each atom afterwards:

  • element
  • x, y, z
  • color
  • atom_type
addBond(atom1, atom2, bond_type)

Add a bond of the specified type between the two atoms atom1 and atom2. The atom parameters can be _StructureAtom objects or integer indices from 1 to the number of atoms in the structure. If the two atoms are already bound then the bond type is just changed.

:param bond_type bond type (legacy integer 0-3 bond order)

addBonds(bonds_list)

Add multiple bonds to this structure. This is much faster than multiple calls to addBond() method when many bonds need to be added. Bonds are specified by a list of integer lists: (atom1, atom2, bond_type).

Example::
st.addBonds([(10, 11, 1), (12, 13, 2)])

This will add a single-order bond between atoms 10 and 11, and a double-order bond between atoms 12 and 13.

adjust(value, atom1, atom2, atom3=None, atom4=None)

Adjust a distance, angle or dihedral angle. If atom3 is None then the distance between atom1 and atom2 will be set to value, atom2 and all atoms attached to that atom will be moved. If atom4 is None then the angle between atom1, atom2 and atom3 will set to value, atom3 and all other atoms attached to that will be moved. If all atoms are specified then the dihedral angle made by atom1, atom2, atom3 and atom4 will be set to value and atom4 and all other atoms attached to that will be moved. All distances are specified in Angstroms, all angles in degrees.

All atom arguments can be integers or _StructureAtom objects. There is no return value for this function.

Raises:AtomsInRingError – if specified atoms are within a ring system. If ring distortion from an adjustment is not an issue, then the moving bitset can be manually created and passed to mmct_atom_set_distance(), mmct_atom_set_bond_angle(), or mmct_atom_set_dihedral_angle().
append(filename, format=None)

Append the structure to the named file.

This method should provided acceptable performance if you are writing a small number of structures, but if you need to write a large number of structures (more than a few hundred) to a file, the StructureWriter class will provide better performance.

Parameters:format (str) – By default, the file format is determined from the filename suffix, but this can be specified explicitly. Supported option values are one of the PDB, MOL2, SD, MAESTRO, SMILES, SMILESCSV module-level constants.
applyStyle(atoms=3, bonds=3, atom_list=None)

Applies the given display styles to the atoms and bonds of the entire structure (by default) or to the atoms (and their bonds) given in atom_list.

Parameters:
  • atoms (int) – Display style for atoms, given by structure module constants ATOM_NOSTYLE, ATOM_CIRCLE, ATOM_CPK, ATOM_BALLNSTICK. Default is ATOM_BALLNSTICK.
  • atoms – Display style for bonds, given by structure module constants BOND_NOSTYLE, BOND_WIRE, BOND_TUBE, BOND_BALLNSTICK. Default is BOND_BALLNSTICK.
  • atom_list (iterable) – An iterable of atom objects or atom indices to apply the given styles to. If not included the styles are applied to all atoms in the structure. Possible examples include:: [1, 3, 5] ring.atom schrodinger.structutils.analyze.evalulate_asl(asl_expr) [structure.atom[x] for x in xrange(50)] maestro.selected_atoms_get()
areBound(atom1, atom2)

Returns True if atom1 and atom2 have a bond of any order between them and False is there is no bond.

atom

An iterable of structure atoms, each of which is a _StructureAtom instance.

Example usage, where st is a Structure instance:

# Access an atom (indices start at 1)
atomobj = st.atom[n]

# Delete an atom
del st.atom[n]

# Find the number of atoms
len(st.atom)

# Iterate over all atoms
for atom in st.atom:
    take_some_action(atom)
Note:As with many other collections, the contents of the atom list should not be modified through additions or deletions while you are iterating over it.
atom_total

Get total number of atoms in this structure

bond

An iterable of structure bonds, each of which is a _StructureBond instance.

To iterate over bonds:

for bond in st.bond:
    take_some_action(bond)
Note:Atoms and bonds should not be added or deleted while you are iterating over bonds.
Note:Bonds are not accessible by index.
chain

An iterable of chains in the structure, each of which is a _Chain instance.

Example usage:

# Find the number of chains in the structure
len(st.chain)

# Retrieve a _Chain instance by letter
chain = st.chain[letter]

# Iterate over chains
for chain in st.chain:
    take_some_action(chain)
Note:Atoms and bonds should not be added or deleted while you are iterating over chains.
closeBlockIfNecessary(filehandle)

Used by the Maestro writer to leave the header block if necessary. For Structure objects this is not needed so it only returns

copy()

Returns a copy of the structure.

deleteAtoms(indices, renumber_map=False)

Delete multiple atoms from the Structure. The argument indices must be a sequence or an iterable, and able to be interpreted as ints.

After deletion, indices are renumbered from 1 to len(atoms). Pre-existing references to Structure atoms will not be correct, as they store index values.

If renumber_map is set to True, will return a renumbering dictionary. Keys are atom numbers before deleting, and value for each is the new atom number, or None if that atom was deleted.

deleteBond(atom1, atom2)

Delete the bond between atom1 and atom2. Raises an Exception if there is no bond between these two.

extend(other_structure)

Add the atoms in other_structure to the end of the current structure. The other_structure is left unchanged.

Raises:ValueError – Extending a structure with itself is not allowed.
extract(indices, copy_props=False)

Return a new structure object which contains the atoms of the current structure that appear in the specified list. The argument indices must be a sequence or an iterable, and able to be interpreted as ints.

After extractions, indices are renumbered from 1 to len(atoms). Pre-existing references to Structure atoms will not be correct, as they store index values.

If copy_props is set to True, then the new structure object will inherit Structure-level properties from the source object.

findResidue(query)

Returns a _Residue object matching the given string (e.g. “A:123”). Currently only protein residues are supported.

If no residues were found that match the given string, or if the given string is of improper format, ValueError is raised.

Note:If the structure has more than one matching residue, then only the first match will be returned.
find_rings(sort=True)

Find all rings in the structure using SSSR.

Each ring is returned in connectivity order.

Parameters:sort (bool) – Deprecated and unused
Returns:A list of lists of integers corresponding to the atom indices of the rings.
formal_charge

Get the sum of formal charges for the structure.

Accessing this property is an O(N) operation.

generate3dConformation(require_stereo=True)

Generate new 3D coordinates for the current structure, and add hydrogens if any are missing. This method is useful for “volumizing” a 2D structure into 3D. NOTE: For 2D inputs, annotation properties must be present for chiral centers to be processed correctly.

Parameters:require_stereo (bool) – Whether to require all chiral centers to have defined stereochemistry via annotation properties. Defaults to True. UndefinedStereochemistry exception is raised if any chiral atom has ambiguous chirality. If set to False, ambiguous chiralities will be expanded arbitrarily.
get3dStructure(require_stereo=True)
Deprecated:Use generate3dConformation() instead.
getAtomIndices()

Return a list of all atom indices in this structure.

getBond(atom1, atom2)

Returns a _StructureBond object for the bond between atom1 and atom2. The atom parameters can be _StructureAtom objects or integer indices from 1 to the number of atoms in the structure.

getChainAtoms(atom)

Return a list of atom objects that are in the same chain as ‘atom’.

getMoleculeAtoms(atom)

Return a list of atom objects that are in the same molecule as ‘atom’.

getMovingAtoms(fixed_atom, moving_atom)

Returns all atoms that would move if <moving_atom> is moved while <fixed_atom> is frozen. This effectively returns all atoms in the same molecule substructure as <moving_atom> (atoms in the same substructure as fixed_atom are excluded).

In other words, if the bond between the moving_atom and fixed_atom (or towards the direction of fixed_atom) were to be broken, the atoms that would be in the same molecule as moving_atom are returned. Can be used for detecting things like residue side-chain atoms, etc.

Note:

If fixed_atom and moving_atom are part of different molecules, then all atoms in the moving_atom’s molecule will be returned. If fixed_atom and moving_atom are not bound directly, the intervening atoms will not be included in the result. If fixed_atom and moving_atom are connected with more than one path (are in a ring), then ValueError is raised.

Parameters:
  • fixed_atom (Atom index or _StructureAtom.) – Atom which is part of the molecule that is to be excluded from the result (frozen, not being moved).
  • moving_atom (Atom index or _StructureAtom.) – Atom of interest (atom to be moved); a set of atoms that would be moved with it (connected to it) will be returned.
Return type:

Set of ints

Returns:

Set of atom indices for atoms “connected” to moving_atom - those atoms that would be moved with it if it was moved. For example, if called with alpha carbon and beta carbon atoms of a protein residue, then all side-chain atoms would be returned. Atom moving_atom will also be included.

Raises ValueError if the given atoms are part of a ring (in other words, moving_atom is connected to fixed_atom via more than one path). This may happen if part of the moving_atom’s “chain” is bonded to something unexpected; e.g. ZOBed to metals, or involved in a di-sulfide bond.

getResidueAtoms(atom)

Return a list of atom objects that are in the same residue as ‘atom’.

getXYZ(copy=True)

Get a numpy array of the xyz coordinates of all atoms in the molecule with shape (atom_total, 3). Note that numpy arrays are indexed starting with 0.

You can avoid copying the underlying data by specifying copy=False, in which case modifying any values will modify the coordinate values in the Structure.

Note that if coordinates are retrieved with copy=False they will become invalid after their source Structure has been garbage collected. Any use of them after this point will likely cause a core dump. This is because the python numpy array provides access directly to the underlying C data.

has3dCoords()

Returns True if any atom in the structure has a non-zero z-coordinate.

isEquivalent(struct, check_stereo=True)

Return True if the 2 structures are equivalent Return False if the 2 structures are different

struct: Another structure class object

check_stereo: Specifies whether or not to check stereo chemistry.

measure(atom1, atom2, atom3=None, atom4=None)

Return the measurement for the provided atoms. If atom3 is None, return the distance between atom1 and atom2. If atom4 is None, return the angle with atoms 1 through 3, and if all atoms are provided, return the dihedral angle.

All atom arguments can be integers or _StructureAtom objects.

If Periodic Boundary Condition CT-level properties are defined, uses the PBC measurement.

See also the structutil.measure module, which has functions to make measurements between atoms in different structures, and can also measure angles between planes.

merge(other_structure, copy_props=False)

Return a new structure object which contains the atoms of the current structure and the atoms of other_structure.

If copy_props is True, properties from the current structure and other_structure will be added to the new structure. If the same property is specifed in both the current structure and other_structure, the current value will take precedence.

mol_total

Get total number of molecules in this structure

molecule

An iterable of molecules in the structure, each of which is a _Molecule instance.

Example usage:

# Find the number of molecules in the structure
len(st.molecule)

# Retrieve a molecule by number (indices start at 1)
mol = st.molecule[molnum]

# Iterate over all molecules
for mol in st.molecule:
    take_some_action(mol)
Note:Atoms and bonds should not be added or deleted while you are iterating over molecules.
property

Dictionary-like container of Structure-level properties. Keys are strings of the form type_family_name as described in the PropertyName documentation.

putToM2ioFile(filehandle)

Used by the Maestro writer - put a single structure to the (already open) filehandle

static read(filename, index=1, error_handler=None, format=None, ignore_errors=False)

Read a single structure from file ‘filename’, returning a Structure instance.

Parameters:
  • index (int) – For multi-structure formats, the index of the structure to read.
  • error_handler (int) – Handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • format (str) – Format of the file, either ‘pdb’, ‘sd’, ‘mol2’, ‘maestro’ or ‘maestro_text’ (determined from file extension by default).
  • ignore_errors (bool) – If True, bad structures will be skipped instead of raising an exception. Currently only used by the SD reader.
residue

An iterable of residues in the structure, each of which is a _Residue instance.

To iterate over all residues:

for residue in st.residue:
    take_some_action(residue)
Note:Atoms and bonds should not be added or deleted while you are iterating over residues.
Note:residues are not accessible by index. See Structure.findResidue()
retype()

Reassign all the MacroModel atom types based on the bond orders and formal charges. This function should be called after either of these have been changed.

ring

An iterable of rings in the structure, each of which is a _Ring instance.

To iterate over rings:

for ring in st.ring:
    take_some_action(ring)
Note:Atoms and bonds should not be added or deleted while you are iterating over rings.
setXYZ(xyz)

Set all xyz coordinates for the molecule from a numpy array.

title

Get the title for this structure

total_weight

The sum of atomic weights for the whole structure.

The weight of implicit hydrogens is automatically included.

Accessing this property is an O(N) operation.

writeToString(format)

Write the structure to a string representation and return the string. The format parameter is required.

schrodinger.application.desmond.cms.get_gluepoints(model, cutoff=3.0)
schrodinger.application.desmond.cms.find_prev_residue(ct, residue)
schrodinger.application.desmond.cms.find_next_residue(ct, residue)
schrodinger.application.desmond.cms.gen_alpha_helix_restraint(model, helix_asl, fc, sigma, ref)

Given a model (‘Cms’ object) and an optional ‘helix_asl’ expression, returns a string specifying the restraint settings.