schrodinger.application.matsci.desmondutils module¶
Utilities for working with Desmond.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.matsci.desmondutils.
BrownieMSJStringer
(time=100.0, temp=10.0, random_seed=None, timestep='[0.001 0.001 0.003]', last=False, **kwargs)¶ Bases:
schrodinger.application.matsci.desmondutils.MSJStringer
An MSJStringer class for Brownie stages
-
formLine
(key, value)¶
-
-
class
schrodinger.application.matsci.desmondutils.
MDMSJStringer
(time=None, temp=None, pressure=None, random_seed=None, ensemble='NPT', method=None, timestep=None, last=False, **kwargs)¶ Bases:
schrodinger.application.matsci.desmondutils.MSJStringer
An MSJStringer class for Molecular Dynamics stages
-
class
schrodinger.application.matsci.desmondutils.
MSAnalysisMSJStringer
(analysis_type=None, **kwargs)¶ Bases:
schrodinger.application.matsci.desmondutils.MSJStringer
An MSJStringer class for MS MD Analysis stages
-
class
schrodinger.application.matsci.desmondutils.
MSJStringer
(stype, last=False, use_base=True, **kwargs)¶ Bases:
object
A base class for setting up the information and generating a string describing that information for a stage in a Desmond MSJ file.
-
ANALYSIS
= 'matsci_analysis'¶
-
ANALYSIS_TYPE
= 'analysis_type'¶
-
CHECKPOINT
= 'checkpt.write_last_step'¶
-
COMPRESS
= 'compress'¶
-
DIR
= 'dir'¶
-
DOT
= '_dot_'¶
-
ENSEMBLE
= 'ensemble'¶
-
ENSEMBLE_CLASS
= 'ensemble.class'¶
-
ENSEMBLE_METHOD
= 'ensemble.method'¶
-
INDENT
= ' '¶
-
INTERVAL
= 'trajectory_dot_interval'¶
-
JOBNAME
= 'jobname'¶
-
KNOWN_LINES
= set(['checkpt.write_last_step', 'temperature', 'othertag', 'timestep', 'trajectory_dot_interval', 'compress', 'ensemble.method', 'jobname', 'pressure', 'dir', 'time', 'analysis_type', 'ensemble.class', 'max_steps', 'ensemble', 'randomize_velocity.seed'])¶
-
LINE_ORDER
= ['max_steps', 'analysis_type', 'time', 'timestep', 'ensemble', 'ensemble.class', 'ensemble.method', 'temperature', 'pressure', 'trajectory_dot_interval', 'randomize_velocity.seed', 'othertag', 'jobname', 'dir', 'compress', 'checkpt.write_last_step']¶
-
MAX_STEPS
= 'max_steps'¶
-
MINIMIZE
= 'minimize'¶
-
MSJ_BASE
= {'checkpt.write_last_step': 'yes', 'jobname': '"$MASTERJOBNAME"'}¶
-
MSJ_LAST
= {'compress': '""', 'dir': '"."'}¶
-
OTHERS
= 'othertag'¶
-
PADDING
= ' '¶
-
PRESSURE
= 'pressure'¶
-
SEED
= 'randomize_velocity.seed'¶
-
SETTINGS
= {'minimize': <schrodinger.utils.sea.Map object>, 'assign_forcefield': None, 'matsci_analysis': None, 'simulate': <schrodinger.utils.sea.Map object>}¶
-
SIMULATE
= 'simulate'¶
-
SYSBUILD
= 'assign_forcefield'¶
-
TEMP
= 'temperature'¶
-
TIME
= 'time'¶
-
TIMESTEP
= 'timestep'¶
-
createString
()¶ Create and return the string that represents this stage in the .msj file
Return type: str Returns: The msj string representing this stage
-
formLine
(key, value)¶ Create the line that should go in the .msj file for this key.
Subclasses should use this function to create custom strings for specific key values
Parameters: Return type: Returns: The line (or lines) to put in the .msj file for this key/value pair
-
-
class
schrodinger.application.matsci.desmondutils.
MinimizeMSJStringer
(iterations=None, last=False, **kwargs)¶ Bases:
schrodinger.application.matsci.desmondutils.MSJStringer
An MSJStringer class for Minimizer stages
-
class
schrodinger.application.matsci.desmondutils.
SysbuildMSJStringer
(forcefield='OPLS_2005', compress='""', **kwargs)¶ Bases:
schrodinger.application.matsci.desmondutils.MSJStringer
An MSJStringer class for building systems
-
schrodinger.application.matsci.desmondutils.
add_cms_property
(cms, propname, value)¶ Add or change a property of cms model
Parameters:
-
schrodinger.application.matsci.desmondutils.
add_cubic_chorus_box_props
(struct)¶ Add the Chorus box properties to the structure for a cubic box
Parameters: struct ( schrodinger.structure.Structure
) – The structure to add the properties to
-
schrodinger.application.matsci.desmondutils.
copy_atom_properties
(struct1, struct2, atom_props)¶ Parameters: - struct1 (
schrodinger.structure.Structure
) – The structure from which atom properties are copied - struct2 (
schrodinger.structure.Structure
) – The structure to which atom properties are copied - atom_props (list of strings) – Atom properties that are copied
- struct1 (
-
schrodinger.application.matsci.desmondutils.
create_msj
(stringers, filename=None, task_stage=True, extra_task_text='', check_cg=None, check_infinite=None)¶ Write a Desmond .msj file based on the supplied stringers
Parameters: - filename (str) – If given, write the msj string to this path
- stringers (list of
MSJStringer
objects) – Each item of the list is the MSJStringer for a single stage. The stages will be written in list order - task_stage (bool) – Whether the traditional desmond auto task stage should be written before the stages in stringers
- extra_task_text (str) – Additional text to place in the task stage. Ignored if task_stage=False.
- check_cg (
schrodinger.structure.Structure
) – Check the given structure to see if it is coarse grain. If it is, add the typical headers for the appropriate coarse grain structure type. Note that the interplay between extra_task_test and the headers used for coarse grain structures is uncertain and left to the caller to determine if the results are acceptable if both are used. Ignored if task_stage=False. - check_infinite (
schrodinger.structure.Structure
) – Check the given structure to see if it is infinite. If it is, add the typical headers for the infinite systems. Ignored if task_stage=False.
Return type: Returns: The string that was written to the file
-
schrodinger.application.matsci.desmondutils.
delete_cms_property
(cms, propname)¶ Delete a property from a cms model
Parameters: - cms (
cms.Cms
) – cms model - propname (str) – property name
- cms (
-
schrodinger.application.matsci.desmondutils.
determine_box_size
(struct)¶ Determine the size of a cubic box that encloses the entire structure
Parameters: struct ( schrodinger.structure.Structure
) – The structure to use in determining the box size.Return type: float Returns: The largest span in the X, Y or Z direction
-
schrodinger.application.matsci.desmondutils.
find_forcefield_invalid_structures
(structs, ffield_num)¶ Check structures to see if the specified forcefield is valid for them
Parameters: - structs (list) – A list of
schrodinger.structure.Structure
objects - ffield_num (int) – An integer specifying which forcefield to use
Return type: list
Returns: A list containing all the structures that fail the force field test. The list is empty if all structures are valid for the force field
- structs (list) – A list of
-
schrodinger.application.matsci.desmondutils.
get_bigger_rclone_setting
(for_gpu, check_cg=None)¶ We use bigger_rclone = true for all non-gpu jobs
Parameters: - for_gpu (bool) – True if this is for a cpu run, False if not
- check_cg (
schrodinger.structure.Structure
) – Check the given structure to see if it is coarse grain and return the value appropriate for coarse grain structures.
Return type: Returns: The value to set bigger_rclone to in the .msj file
-
schrodinger.application.matsci.desmondutils.
get_default_far_timestep
()¶ Return the default far timestep
Returns: Default far timestep in femtoseconds Return type: float
-
schrodinger.application.matsci.desmondutils.
get_default_near_timestep
()¶ Return the default near timestep
Returns: Default near timestep in femtoseconds Return type: float
-
schrodinger.application.matsci.desmondutils.
get_density_from_ene
(ene_file, struct, fraction=0.2)¶ Parse the volume from the ene file and compute the density from it. The density is averaged over the last fraction of frames.
Parameters: - ene_file (str) – The name of the file to read in.
- struct (
schrodinger.structure.Structure
) – The structure to compute the density for - fraction (float) – The fraction of frames to average the density over. For instance, use 0.20 to compute the density over the final 20% of frames. Use the special value 0 to just use the final density. With fraction=0, the returned standard deviation is 0.
Return type: (float, float)
Returns: The mean density and standard deviation of the density.
Raises: IOError – If unable to read the volumes from the ene file
-
schrodinger.application.matsci.desmondutils.
get_model_ff_name
(model)¶ If possible detect what force field the model was created with
Parameters: model ( schrodinger.application.desmond.cms.Cms
) – The cms model to checkReturn type: str Returns: The name of the detected forcefield or and empty string if no known force field was detected. FF names are the module constants OPLS3 or OPLS2005
-
schrodinger.application.matsci.desmondutils.
get_multisim_command
(input_name, output_name, msj_name=None, job_name=None, gpu=False, procs=1)¶ Return a command to run the Desmond multisim utility
Parameters: - input_name (str) – The name of the input file
- output_name (str) – The name to use for the output CMS file
- msj_name (str) – The name of the .msj command file
- job_name (str) – The name to use for the job
- gpu (bool) – Whether the job will run on gpu. Will override the procs keyword
- procs (int) – The number of CPU processors to use. Will not be used if gpu=True
Return type: list
Returns: The command line command to use
-
schrodinger.application.matsci.desmondutils.
get_periodic_fix_msj_header
(struct)¶ Get periodic fix settings string if structure is infinite, this should be added to task block.
Parameters: struct ( schrodinger.structure.Structure
) – Check the given structure to see if it is infinite and return the value appropriate for infinite structures.Returns: Family header with periodic fix settings Return type: str
-
schrodinger.application.matsci.desmondutils.
has_chorus_box_props
(struct)¶ Check if the structure has all the Chorus box properties
Parameters: struct ( schrodinger.structure.Structure
) – The structure to check for propertiesReturn type: bool Returns: Whether the structure has all the chorus box properties
-
schrodinger.application.matsci.desmondutils.
has_orthorhombic_pbc
(struct, tolerance=0.0)¶ Detect if the given structure has a PBC that is orthorhombic (all angles are 90 degrees).
Parameters: - struct (
schrodinger.structure.Structure
) – The structure to check - tolerance (float) – The tolerance for the 90 degree check, in degrees
Return type: bool
Returns: True if a PBC exists and it is orthorhombic
- struct (
-
schrodinger.application.matsci.desmondutils.
has_space_group_pbc_props
(struct)¶ Check if the structure has all the space group PBC properties
Parameters: struct ( schrodinger.structure.Structure
) – The structure to check for propertiesReturn type: bool Returns: Whether the structure has all the space group pbc properties
-
schrodinger.application.matsci.desmondutils.
is_opls2005_model
(model)¶ Check if the given Cms model was made with OPLS_2005
Parameters: model ( schrodinger.application.desmond.cms.Cms
) – The cms model to checkReturn type: bool Returns: True if OPLS_2005 was detected, False if not
-
schrodinger.application.matsci.desmondutils.
is_opls3_model
(model)¶ Check if the given Cms model was made with OPLS3
Parameters: model ( schrodinger.application.desmond.cms.Cms
) – The cms model to checkReturn type: bool Returns: True if OPLS3 was detected, False if not
-
schrodinger.application.matsci.desmondutils.
make_chorus_orthorhombic
(struct)¶ Zero out all the non-diagonal Chorus box properties. The main use of this function is to remove numerical imprecision in the off-diagonal elements that causes Desmond to consider the box triclinic. The function returns the largest off-diagonal element pre-zeroing so the calling routine can decide what to do (warn user, etc) if the off-diagonals looked large enough to be intentionally non-zero.
Parameters: struct ( schrodinger.structure.Structure
) – The structure whose Chorus box properties should be modifiedReturn type: float Returns: The absolute value of the largest off-diagonal element before zeroing
-
schrodinger.application.matsci.desmondutils.
parse_ene_file
(filename=None, fileobj=None, prop=None)¶ Parse data from a Desmond .ene file. All the data from the file can be returned in a dictionary, or just the data from a single property can be returned in a list.
Parameters: - filename (str) – The name of the .ene file to read
- fileobj (file) – The open file object for the .ene file. Only one of filename or fileobj should be supplied. If both are given, filename will take precedence.
- prop (str) – If given, should match one of the properties in the ene file header (such as ‘V’). The return value will be a list of values for this property only
Return type: dict or list
Returns: If prop is not specified, the return value is a dict. Keys are property names from the ene header (without units, such as ‘V’) and values are lists of floating point values for that property in the order obtained from the .ene file. If prop is specified, the return value is a list of those property values in the order found in the .ene file.
Raises: - ValueError – If a line of unknown format is found while reading the file, or if neither filename or fileobj is specified.
- TypeError – If prop is supplied but does not match a property in the header line
-
schrodinger.application.matsci.desmondutils.
read_density_from_eaf
(density_eaf, fraction=0.2, logger=None)¶ Reads in a .eaf file generated by an ms_analysis stage of a Desmond MD run and returns density data.
Parameters: - density_eaf (str) – EAF file containing density information
- fraction (float) – The last fraction of the frames to use in the density averaging
- logger (
logging.Logger
) – The logger to use while logging errors. If not supplied, messages will be printed.
Return type: Returns: (None, None) if the density cannot be read from the file, or tuple of the calculated density and standard deviation.
-
schrodinger.application.matsci.desmondutils.
remove_fatal_atom_properties
(struct, fatal_atom_properties)¶ Remove atom properties from struct that cause the system builder to fail
Parameters: struct ( schrodinger.structure.Structure
) – The structure to remove atom properties from
-
schrodinger.application.matsci.desmondutils.
run_system_builder
(struct_in, output_basename, forcefield='OPLS_2005', rezero_system=True, logger=None, copy_output=True, atom_props_to_keep=[], fatal_atom_properties=['i_ffio_grp_ligand', 'i_ffio_grp_energy', 'i_psp_parent', 'f_psp_parent', 's_psp_parent'])¶ Run the Desmond multisim system builder
Parameters: - struct_in (
schrodinger.structure.Structure
) – The structure to run the system builder on. If the chorus box properties are not set to define the periodic boundary condition, a cubic PBC will be imposed based on the largest span of the X, Y or Z coordinates. - output_basename (str) – The base name of the output file
- forcefield (str) – The name of the force field to use. The default is ‘OPLS_2005’. Note that any custom directory needed for OPLS3 is taken care of via the runtime environment as long as the script was launched via launcher with the oplsdir argument.
- rezero_system (bool) – Whether to move the center of mass to the origin
- logger (
logging.Logger
) – The logger to use to record any messages. If None, the messages are printed. - copy_output (bool) – specifies to copy output files back to the launch directory by adding them to the job control backend
- atom_props_to_keep (list of strings) – Properties to copy to the final structure
- fatal_atom_properties (tuple of strings) – Properties to remove from structure
Return type: Returns: The name of the resulting .cms file, or None if the file was not produced successfully
- struct_in (
-
schrodinger.application.matsci.desmondutils.
store_chorus_box_props
(struct, ax, ay=0.0, az=0.0, bx=0.0, by=None, bz=0.0, cx=0.0, cy=0.0, cz=None)¶ Add properties to the structure that define the periodic boundary condition in the way Desmond wants it defined.
Parameters: struct ( schrodinger.structure.Structure
) – The structure to add the properties to@ax: float :param ax: The value of the ax box property
@ay: float :param ay: The value of the ay box property. Defaults to 0.
@az: float :param az: The value of the az box property. Defaults to 0.
@bx: float :param bx: The value of the bx box property. Defaults to 0.
@by: float :param by: The value of the by box property. If not given, this value is set
the same as ax.@bz: float :param bz: The value of the bz box property. Defaults to 0.
@cx: float :param cx: The value of the cx box property. Defaults to 0.
@cy: float :param cy: The value of the cy box property. Defaults to 0.
@cz: float :param cz: The value of the cz box property. If not given, this value is set
the same as ax.
-
schrodinger.application.matsci.desmondutils.
update_pdb_pbc
(icms_obj=None, icms_file=None, ocms_file=None)¶ Update the PDB PBC properties given a cms-type input.
Parameters: Raises: RuntimeError – if there is a problem with the input
Return type: Returns: the updated cms.Cms
-
schrodinger.application.matsci.desmondutils.
validate_ff_name_and_get_number
(name)¶ Check that the given name is a valid force field name and if so, return the mmffld number associated with that name
Parameters: name (str) – The force field name to check Return type: (str or None, int) Returns: The first item is an error message if an error occurred. The second item is the mmffld integer for the given forcefield, or 0 if an error occurred.
-
schrodinger.application.matsci.desmondutils.
write_builder_input
(struct, out_name, forcefield='OPLS_2005', rezero_system=True)¶ Write input for the Desmond System Builder
Parameters: - struct (
schrodinger.structure.Structure
) – The structure to run the system builder on - out_name (str) – The base name for the output files
- forcefield (str) – The forcefield to use
- rezero_system (bool) – Whether to move the center of mass to the origin
Return type: Returns: The names of the .msj and .mae files that were created
- struct (