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 theconstants.CT_TYPE
andconstants.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) List[float] ¶
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: List[float])¶
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
andconstants.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)¶
Given structures, return the simulation type. :param struc:
structure.Structure
objects. :type struc: iterable ofstructure.Structure
objects. :rtype: constants.SystemType
- schrodinger.application.desmond.cms.decomp_rawfep_structure(struc)¶
- schrodinger.application.desmond.cms.encode_str(data: str) str ¶
Encode a string into a b64 string.
- schrodinger.application.desmond.cms.decode_str(data: str) str ¶
Decode a b64 string into a string.
- class schrodinger.application.desmond.cms.Restrain(atom_idx: List[Tuple[int, int]], k: Union[float, Sequence[float]], ref: Union[float, Sequence[float]], sigma: Optional[Union[float, Sequence[float]]] = None)¶
Bases:
object
- __init__(atom_idx: List[Tuple[int, int]], k: Union[float, Sequence[float]], ref: Union[float, Sequence[float]], sigma: Optional[Union[float, Sequence[float]]] = None)¶
- Parameters
atom_idx – List of (ct index, atom index) tuples.
- property ref¶
- merge_with(a: schrodinger.application.desmond.cms.Restrain)¶
Merge this restrain with another, keeping the maximum force constant and copying reference coordinates from the other restrain.
- class schrodinger.application.desmond.cms.RestrainGroup¶
Bases:
object
Acts as a ‘default’ class, whose methods either no-op or in the case of
merge_with
return concrete subclasses.- merge_with(other: schrodinger.application.desmond.cms.RestrainGroup) schrodinger.application.desmond.cms.RestrainGroup ¶
Merge this group with another group
- retain_refs(other: schrodinger.application.desmond.cms.RestrainGroup)¶
Copy reference values from any duplicate entries in another group to this group
- retain_ref_single(other: schrodinger.application.desmond.cms.Restrain)¶
If other is a duplicate of an entry in this group, copy reference value from this group’s entry to other
- merge_single(other: schrodinger.application.desmond.cms.Restrain) schrodinger.application.desmond.cms.Restrain ¶
Merge a single Restrain into this group, returning this group
The default implementation creates a new DictRestrainGroup with only other and returns it
- values() Iterator[Any] ¶
An iterator over the values in this group. The type of the values is determined by the subclass
- class schrodinger.application.desmond.cms.DictRestrainGroup¶
Bases:
dict
,schrodinger.application.desmond.cms.RestrainGroup
- merge_with(other: Union[schrodinger.application.desmond.cms.RestrainGroup, schrodinger.application.desmond.cms.DictRestrainGroup]) schrodinger.application.desmond.cms.DictRestrainGroup ¶
Subclasses are not interoperable - other is assumed to be either a ‘null’ RestrainGroup or a DictRestrainGroup, but not a PosRestrainArray subclass
- merge_single(other: schrodinger.application.desmond.cms.Restrain) schrodinger.application.desmond.cms.DictRestrainGroup ¶
Merge a single Restrain into this group, returning this group
The default implementation creates a new DictRestrainGroup with only other and returns it
- add(restrain: schrodinger.application.desmond.cms.Restrain)¶
- retain_refs(other: Union[schrodinger.application.desmond.cms.RestrainGroup, schrodinger.application.desmond.cms.DictRestrainGroup])¶
Subclasses are not interoperable - other is assumed to be either a ‘null’ RestrainGroup or a DictRestrainGroup, but not a PosRestrainArray subclass
- retain_ref_single(other: schrodinger.application.desmond.cms.Restrain)¶
If other is a duplicate of an entry in this group, copy reference value from this group’s entry to other
- class schrodinger.application.desmond.cms.PosRestrainArray(atom_idxs, k=None, ref=None)¶
Bases:
schrodinger.application.desmond.cms.RestrainGroup
Stores a group of position restraints as a numpy structured array for faster creation (if from existing arrays) and merging
- AIDX_TYPE = [('ct', 'i8'), ('atom', 'i8')]¶
- DTYPE = [('atom_idx', [('ct', 'i8'), ('atom', 'i8')]), ('k', 'f8', (3,)), ('ref', 'f8', (3,))]¶
- INTERSECT_KEYS = 'atom_idx'¶
- __init__(atom_idxs, k=None, ref=None)¶
Atoms can be an iterable of tuples with type corresponding to
self.DTYPE
such that they can be passed directly to numpy’s structured array constructor, or a numpy array of atom indices, in which case k and ref must also be numpy arrays of the same length. In the latter case, the array fields will be filled in with each of the subarrays. :param atom_idxs: The atom indices or a list of tuples with all of the parameters :param k: The force constants :param ref: The reference values
- merge_with(other: Union[schrodinger.application.desmond.cms.RestrainGroup, schrodinger.application.desmond.cms.PosRestrainArray]) schrodinger.application.desmond.cms.PosRestrainArray ¶
Subclasses are not interoperable - other is assumed to be either a ‘null’ RestrainGroup or a PosRestrainArray, but not a DictRestrainArray subclass
- merge_single(other)¶
Merge a single Restrain into this group, returning this group
The default implementation creates a new DictRestrainGroup with only other and returns it
- retain_refs(other: Union[schrodinger.application.desmond.cms.RestrainGroup, schrodinger.application.desmond.cms.PosRestrainArray])¶
Subclasses are not interoperable - other is assumed to be either a ‘null’ RestrainGroup or a PosRestrainArray, but not a DictRestrainArray subclass
- retain_ref_single(other)¶
If other is a duplicate of an entry in this group, copy reference value from this group’s entry to other
- values() numpy.array ¶
An iterator over the values in this group. The type of the values is determined by the subclass
- __len__()¶
- class schrodinger.application.desmond.cms.FBHWPosRestrainArray(atom_idxs=None, k=None, ref=None, sigma=None)¶
Bases:
schrodinger.application.desmond.cms.PosRestrainArray
- DTYPE = [('atom_idx', [('ct', 'i8'), ('atom', 'i8')]), ('k', 'f8'), ('ref', 'f8', (3,)), ('sigma', 'f8')]¶
- INTERSECT_KEYS = ['atom_idx', 'sigma']¶
- __init__(atom_idxs=None, k=None, ref=None, sigma=None)¶
Atoms can be an iterable of tuples with type corresponding to
self.DTYPE
such that they can be passed directly to numpy’s structured array constructor, or a numpy array of atom indices, in which case k and ref must also be numpy arrays of the same length. In the latter case, the array fields will be filled in with each of the subarrays. :param atom_idxs: The atom indices or a list of tuples with all of the parameters :param k: The force constants :param ref: The reference values
- class schrodinger.application.desmond.cms.RestrainGroupContainer(*args, **kwargs)¶
Bases:
collections.defaultdict
Collection of
RestrainGroups
corresponding to the differentconstants.RestrainTypes
- __init__(*args, **kwargs)¶
- merge_group(key: schrodinger.application.desmond.constants.RestrainTypes, val: schrodinger.application.desmond.cms.RestrainGroup)¶
Merges a new restrain group with the existing value and updates the result.
- merge_single(key: schrodinger.application.desmond.constants.RestrainTypes, val: schrodinger.application.desmond.cms.Restrain)¶
Merges a new restrain into the corresponding restrain group value and updates the result.
- class schrodinger.application.desmond.cms.ModelRestrainList(iterable=(), /)¶
Bases:
list
- class schrodinger.application.desmond.cms.AtomGroup(atom: List[int] = None, name: str = None, index: int = None)¶
Bases:
object
Store information about atom groups, and their type.
- __init__(atom: List[int] = None, name: str = None, index: int = None)¶
Object used to set atom group property in the
Cms
- property atom_property: str¶
- class schrodinger.application.desmond.cms.Site(type, charge, mass, vdwtype)¶
Bases:
object
- __init__(type, charge, mass, vdwtype)¶
- 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 aVdw
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 theprep_struc
function.
- class schrodinger.application.desmond.cms.Cms(file=None, string=None, remove_inactive_atoms_in_fsys=True)¶
Bases:
schrodinger.structure._structure.Structure
- MODEL_SYSTEM_TYPE = ['standard model system', 'model system for mutation FEP', 'model system for total free energy FEP']¶
- META_ASL = {'cosolvent': "atom.s_ffio_ct_type 'cosolvent'", '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_inactive_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.
- static clean_ct_properties(ct)¶
Replace newlines and square brackets in ct property names and values. This function needs to be call for all cts that is to be read by desmond to guard againt destro failure.
- 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.
- property need_msys¶
- property particle_total¶
- property use_titration¶
- property glued_topology¶
- glue(glue_pts, start_fresh=False)¶
- get_fep_cts()¶
find ref and mut cts by fep_fragname property
- get_titration_ct()¶
find titration ct
- 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(lambda_val)¶
- Parameters
lambda_val – lambda value, 0 or 1
- Returns
list of int (for atoms), list of list of int (for virtual sites)
- update_with_frame(frame)¶
Given frame object (traj.Frame), update coordinates and velocites ( if they exist in frame) for all particles. All coordinates in the serialized titration states are updated as well if titration ct exists. This also works for the new alchemical msys code for FEP and will replace topo.update_cms in the long run.
- convert_to_gids(aids, with_pseudo=False)¶
Given aids, convert them to gids with pseudo particles as required. :type aids: List[int] :param aids: aids to be converted :type with_pseudo: bool :param with_pseudo: switch to include pseudo particles :rtype: List[int] :return: A list of gids of corresponding to aids
- gid_refresh()¶
- gid(atom_index)¶
atom_index
is the index of the atom in the ‘full_system’ CT.
- property allaid_gids¶
Get the 0-indexed mapping between aids and gids as a view of the underlying numpy array. :return:
np.array
- property comp_atom_total¶
Get the sum of the atom totals of the component CTs. For systems with inactive 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. Inactive atoms are removed. Note that inactive atom removal does not work if they are spread across multiple component CTs.
- Return type
list
ofint
- select_atom_comp(asl)¶
Returns a list of lists. Each list element contains a list of atom indices of the corresponding component CT.
- get_charge(gids: List[int]) numpy.array ¶
Given gids, return corresponding charge values
- get_mass(gids: List[int]) numpy.array ¶
Given gids, return corresponding mass values
- extract_titration_states()¶
Generate Cms objects and particle ids for all titration states. The first Cms object is just self with titration properties removed in the titration ct. Then each of the Cms objects is generated by replacing the titration_ct with other titration state. Each Cms object is an independent titration state interacting with the rest of the system. :return: tuple of Cms and gid lists :rtype: (List[Cms], List[List]):
- extract_with_comp_selection(selections: List[List[int]])¶
Extract from given atom numbers in each component ct (selections). A new Cms object and the gids corresponding to all particles selected are returned. The caller needs to make sure the atoms in each selection include all atoms in the ffio_sites block.
- extract_with_asl(asl: str, with_aid: Optional[bool] = False)¶
Extract from given ASL selection. A new Cms object and the gids corresponding to all particles selected are returned. Aids are returned as well, if requested. If the selection contains only partial molecules, it will be extended to entire molecules. The caller needs to make sure the ASL selects all atoms in the ffio block.
- property has_velocities: bool¶
- get_pos_vel() Tuple[numpy.array, Optional[numpy.array]] ¶
Generate positions and velocities (if they exist) in the same layout as in trajectory.
- get_restrain() schrodinger.application.desmond.cms.ModelRestrainList ¶
Create a portable list of restraints representing the ffio restraints for each CT. The output is a list of
RestrainGroupContainer`s ( essentially a dict), indexed by each of the `RestraintTypes
, withRestrainGroup
subclasses as values. These values represent all the restrains of the same type for a given CT.
- set_restrain(restrain_list: List[Union[schrodinger.application.desmond.cms.RestrainGroupContainer, List[schrodinger.application.desmond.cms.Restrain]]])¶
restrain_list
must be a list. Its members should be RestrainGroupContainers or for compatibility, lists of Restrain objects.
- clear_restrain()¶
Deletes all existing restraints.
- get_atom_group() List[schrodinger.application.desmond.cms.AtomGroup] ¶
Return previusly defined atom groups. These groups have
i_ffio_group_
prefix, followed by the group name.
- set_atom_group(atom_group: Union[schrodinger.application.desmond.cms.AtomGroup, List[schrodinger.application.desmond.cms.AtomGroup]])¶
Set atom groups (ie. energy, restraints) by labeling atom properties with the
i_ffio_group_
prefix. TheAtomGroup.name
suffix is then appended. This function first clears the previously defined atom groups, before setting new ones.
- merge_atom_group(atom_group: Union[schrodinger.application.desmond.cms.AtomGroup, List[schrodinger.application.desmond.cms.AtomGroup]])¶
- 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 thenactive_gids
so that it will be written to disk and can be used by msys models. Ifnactive_gids
==ntotal_gids
, this will setself.active_total
toself.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)¶
- property nactive_gids¶
- property is_for_gcmc¶
- property active_total¶
Get the number of active physical atoms :return: The number of active physical atoms :rtype:
int
- get_degrees_of_freedom()¶
- get_ff() str ¶
Get the canonical force field name of the model.
- Returns
Canonical force field name or empty string, if unknown
- move_solvent_cts_back()¶
Rearrange components so that solvent components are last.
- get_cts()¶
Return system and component cts.
- Returns
raw full system, full system, and component ct
- Return type
list
- set_cts_property(propname: str, value: Any)¶
Set a property on all cts
- Parameters
propname – The property to set
value – The property’s value
- remove_cts_property(propname: str)¶
Remove a property from all cts
- Parameters
propname – The property to remove
- fix_filenames(cms_fname=None, trj_fname=None)¶
- write(fname)¶
- write_to_string()¶
- schrodinger.application.desmond.cms.get_titration_sites(model: schrodinger.application.desmond.cms.Cms) List[str] ¶
Get the residue sites from a cms model that are titratable if it has any.
- Parameters
model – The cms model to get the titration sites from.
- Returns
A list of the residue sites that are titrated to. If there are no titratable residues the list will be empty.
- schrodinger.application.desmond.cms.get_titration_states(model: schrodinger.application.desmond.cms.Cms) List[schrodinger.application.desmond.ffiostructure.FFIOStructure] ¶
Get the structures that are generated from titrating the residues of the model protein.
- Parameters
model – The cms model to get the titration states from.
- Returns
A list of titration states as structures. If there are no titratable residues the list will be empty.
- 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.
- schrodinger.application.desmond.cms.get_asl_from_meta_asl(asl: str) str ¶
Convert a meta-ASL into an ASL.