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) 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 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)

Given structures, return the simulation type. :param struc: structure.Structure objects. :type struc: iterable of structure.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

__contains__(key, /)

True if the dictionary has the specified key, else False.

__init__(*args, **kwargs)
__len__()

Return len(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D’s items
keys() a set-like object providing a view on D’s keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D’s values
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

AIDX_TYPE = [('ct', 'i8'), ('atom', 'i8')]
__len__()
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

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

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

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

values() numpy.array

An iterator over the values in this group. The type of the values is determined by the subclass

class schrodinger.application.desmond.cms.RestrainGroupContainer(*args, **kwargs)

Bases: collections.defaultdict

Collection of RestrainGroups corresponding to the different constants.RestrainTypes

__init__(*args, **kwargs)
default_factory

Factory for default value called by __missing__().

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.

__contains__(key, /)

True if the dictionary has the specified key, else False.

__len__()

Return len(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D.
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D’s items
keys() a set-like object providing a view on D’s keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D’s values
class schrodinger.application.desmond.cms.ModelRestrainList(iterable=(), /)

Bases: list

__contains__(key, /)

Return key in self.

__init__(*args, **kwargs)
__len__()

Return len(self).

append(object, /)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)

Insert object before index.

pop(index=- 1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

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_inactive_atoms_in_fsys=True)

Bases: schrodinger.structure._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 = {'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 of int

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, with RestrainGroup 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()
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)
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()
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.

NOTE: To adjust improper dihedrals, use build.adjustImproperDihedral instead

Parameters
  • value (float) – value the internal coordinate will be set to

  • atom1 (int or _StructureAtom) – first atom in the coordinate

  • atom2 (int or _StructureAtom) – second atom in the coordinate

  • atom3 (int or _StructureAtom or None) – third atom in the coordinate (if None, the coordinate is a bond)

  • atom4 (int or _StructureAtom or None) – fourth atom in the coordinate (if None, the coordinate is an angle)

Raises

AtomsInRingError – if specified atoms are within a ring system.

append(filename, format=None)

Convenience method for the preferred StructureWriter context manager

applyCPKStyle(atom_list=None)

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

Parameters

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.

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()

applyTubeStyle(atom_list=None)

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

Parameters

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.

applyWireStyle(atom_list=None)

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

Parameters

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.

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.

property 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.

deletePropertyFromAllAtoms(prop_name)

Deletes a property from all atoms present in structure

Param

prop_name: The name of the atom-level property to delete.

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.

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.

Parameters
  • indices (iterable or sequence) – List of atom indices to extract

  • copy_props (bool) – Whether to copy structure properties

Return type

Structure

Returns

Extracted structure

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.

property formal_charge

Get the sum of formal charges for the structure.

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.

getAtomPropertyNames(include_builtin=False)

Return a tuple of atom-level property names present in this CT.

Param

include_builtin: Whether to include built-in properties.

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.

getPropertyNames()
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.

hasAtomProperty(prop_name)

Return True if the structure has the property named prop_name, False otherwise

Parameters

prop_name (str) – the name of the property

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.

property 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 pbc

Access the PBC of the Structure. Throws KeyError if no PBC exists

property 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)

Convenience method for the preferred call to StructureReader.read()

property 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.

property title

Get the title for this structure

property 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_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.