schrodinger.application.matsci.desconfig module

MSJ configuration tools for working with Desmond.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.desconfig.BarrierInfo(rcut, prefac, direction, exponent, coord, asl, buffer, asl_group, reciprocal)

Bases: schrodinger.application.matsci.desconfig.BarrierInfo

Tuple to store barrier info.

classmethod create(asl_group, rcut, prefac, direction, exponent, coord=None, asl=None, buffer=None, struct=None, reciprocal=False)

Prefer this over the constructor, since validation is implemented here.

Parameters
  • asl_group (str) – ASL for impermeable atoms. If ‘all’, wall is impermeable. Otherwise wall is semipermeable.

  • rcut (float) – R cutoff

  • prefac (float) – Prefactor

  • direction (int) – 0 or 1 or 2 axis

  • exponent (int) – Exponent

  • coord (float) – Coordinate of the wall (if ASL is not defined)

  • asl (str) – ASL if coord is not provided

  • buffer (float) – Buffer to use with ASL

  • struct (structure.Structure) – Structure to use with ASL

  • reciprocal (bool) – add coordinate in reciprocal space

static getPosition(struct, asl, direction, buffer)

Get barrier position along the direction.

Parameters
  • struct (structure.Structure) – Structure to run asl on

  • asl (str) – ASL

  • direction (int) – One of the directions 0 or 1 or 2

  • float – Buffer

Return type

bool, str or float

Returns

True and position if no error. Otherwise False and the error message

anyAtomsTooClose(struct, decimals=3)

Check if structure has any atoms too close to the wall.

class schrodinger.application.matsci.desconfig.BarrierHeader(model=None, barriers=None)

Bases: object

Get header for the barrier based on the model property

__init__(model=None, barriers=None)

Instantiate the class to get for the barrier based on the model property

Parameters
  • model (cms.Cms) – model containing barrier information. Barrier information must be present in _raw_fsys_ct to be accessed.

  • barriers (list[BarrierInfo]) – List of barriers. Either this or model must be passed, not both.

static extractBarriers(struct)

Extract barrier information from the structure.

Parameters

struct (structure.Structure) – Structure to extract properties from.

Return type

list[BarrierInfo]

Returns

List of barriers. On error, return empty list

addBarrier(barrier)

Add a barrier.

Parameters

barrier (BarrierInfo) – Barrier to add

Raises

ValueError – If barrier is not of the BarrierInfo type

getBarrierTermMSJ()

Return barrier term

Returns

barrier force term

Return type

sea.Map

static getReciprocalVal(barriers)

Get reciprocal values for the barriers

Parameters

barriers (list[BarrierInfo]) – List of barriers

Return type

bool

Returns

return True if wall coordinates are defined in reciprocal space else False

writeBarriersToStructure(struct)

Write list of barriers to the structure property.

Parameters
  • struct (structure.Structure) – Structure to be modified

  • list[BarrierInfo] – List of barriers

static validateBarriers(barriers)

Check if all the barriers are either in reciprocal coordinates or in real coordinates. if not, raise RuntimeError.

Parameters

barriers (list[BarrierInfo]) – List of barriers

Raises

RuntimeError – If the barriers coordinate definition are not consistent

schrodinger.application.matsci.desconfig.create_msj(stringers, filename=None, task_stage=True, extra_task_text='', check_cg=None, check_infinite=None, msj_string_header='', remove_com_motion=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-grained. If it is, add the typical headers for the appropriate coarse-grained structure type. Note that the interplay between extra_task_test and the headers used for coarse-grained 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.

  • msj_string_header (when extra_task_text is empty, use this string as the header of the output msj) – str

  • remove_com_motion (bool) – None - default behavior, add remove_com_motion only to infinite atomic systems, if True add plugin to msj regardless. If False don’t add remove_com_plugin

Return type

str

Returns

The string that was written to the file

class schrodinger.application.matsci.desconfig.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.

DOT = '_dot_'
MAX_STEPS = 'max_steps'
TIME = 'time'
TEMP = 'temperature'
SEED = 'randomize_velocity.seed'
PRESSURE = 'pressure'
ENSEMBLE = 'ensemble'
ENSEMBLE_CLASS = 'ensemble.class'
ENSEMBLE_METHOD = 'ensemble.method'
TIMESTEP = 'timestep'
JOBNAME = 'jobname'
CHECKPOINT = 'checkpt'
DIR = 'dir'
COMPRESS = 'compress'
INTERVAL = 'trajectory_dot_interval'
ENE_INTERVAL = 'eneseq_dot_interval'
ANALYSIS_TYPE = 'analysis_type'
OTHERS = 'othertag'
TRJ_WRITE_VEL = 'trajectory_dot_write_velocity'
RANDOMIZE_VEL = 'randomize_velocity_dot_first'
ISOTROPY = 'backend_dot_integrator_dot_pressure_dot_isotropy'
MSJ_BASE = {'checkpt': 'no', 'jobname': '"$MASTERJOBNAME"'}
MSJ_LAST = {'compress': '""', 'dir': '"."'}
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']
KNOWN_LINES = {'analysis_type', 'checkpt', 'compress', 'dir', 'ensemble', 'ensemble.class', 'ensemble.method', 'jobname', 'max_steps', 'othertag', 'pressure', 'randomize_velocity.seed', 'temperature', 'time', 'timestep', 'trajectory_dot_interval'}
SIMULATE = 'simulate'
ANALYSIS = 'matsci_analysis'
SYSBUILD = 'assign_forcefield'
AVE_CELL = 'average_cell'
EN_ANALYSIS = 'analysis'
CONCATENATE = 'concatenate'
FROZEN_PHONON_CORR = 'frozen_phonon_correction'
SETTINGS = {'analysis': None, 'assign_forcefield': None, 'average_cell': None, 'concatenate': None, 'frozen_phonon_correction': None, 'matsci_analysis': None, 'simulate': <schrodinger.utils.sea.sea.Map object>}
PADDING = '           '
INDENT = '               '
__init__(stype, last=False, use_base=True, **kwargs)

Create a MSJStringer object

Parameters
  • stype (str) – The type of stage this is. Should be one of the class constants MINIMIZE, SIMULATE, SYSBUILD, ANALYSIS, or AVE_CELL

  • last (bool) – Whether the msj lines typically associated with the last stage (dir, compress) should be included

  • use_base (bool) – Whether the base msj lines (jobname, checkpoint) that are common to almost all stages should be included.

All other keyword arguments are turned into lines in the .msj file. Keys that have a ‘.’ in them should have that . replaced with the class constant string DOT (_dot_). For instance to include a line setting trajectory.write_velocity to true, use the keyword argument trajectory_dot_write_velocity=’true’

createString(concatenate=False)

Create and return the string that represents this stage in the .msj file

Parameters

concatenate (bool) – If True enable concatenate mode. In this mode, stage type is not printed

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
  • key (str) – Typically, the string before the key = value pair on an msj line.

  • value (str) – Typically, the string after the key = value pair on an msj line.

Return type

str

Returns

The line (or lines) to put in the .msj file for this key/value pair

getTitle()

This function returns a title for the stage describing the main parameters. The default implementation has no title.

Return type

str

Returns

The title for this stage

class schrodinger.application.matsci.desconfig.AveCellMSJStringer(**kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for post average cell stage.

PERCENT_TO_AVG = 'percent_to_avg'
__init__(**kwargs)

Create a MSJStringer object

Parameters
  • stype (str) – The type of stage this is. Should be one of the class constants MINIMIZE, SIMULATE, SYSBUILD, ANALYSIS, or AVE_CELL

  • last (bool) – Whether the msj lines typically associated with the last stage (dir, compress) should be included

  • use_base (bool) – Whether the base msj lines (jobname, checkpoint) that are common to almost all stages should be included.

All other keyword arguments are turned into lines in the .msj file. Keys that have a ‘.’ in them should have that . replaced with the class constant string DOT (_dot_). For instance to include a line setting trajectory.write_velocity to true, use the keyword argument trajectory_dot_write_velocity=’true’

getTitle()

This function returns a title for the stage describing the main parameters. The default implementation has no title.

Return type

str

Returns

The title for this stage

class schrodinger.application.matsci.desconfig.AnalysisMSJStringer(**kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for the analysis stage.

__init__(**kwargs)

Create a MSJStringer object

Parameters
  • stype (str) – The type of stage this is. Should be one of the class constants MINIMIZE, SIMULATE, SYSBUILD, ANALYSIS, or AVE_CELL

  • last (bool) – Whether the msj lines typically associated with the last stage (dir, compress) should be included

  • use_base (bool) – Whether the base msj lines (jobname, checkpoint) that are common to almost all stages should be included.

All other keyword arguments are turned into lines in the .msj file. Keys that have a ‘.’ in them should have that . replaced with the class constant string DOT (_dot_). For instance to include a line setting trajectory.write_velocity to true, use the keyword argument trajectory_dot_write_velocity=’true’

class schrodinger.application.matsci.desconfig.FrozenPhononStringer(**kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for the Frozen phonon correction stage.

__init__(**kwargs)

Create a MSJStringer object

Parameters
  • stype (str) – The type of stage this is. Should be one of the class constants MINIMIZE, SIMULATE, SYSBUILD, ANALYSIS, or AVE_CELL

  • last (bool) – Whether the msj lines typically associated with the last stage (dir, compress) should be included

  • use_base (bool) – Whether the base msj lines (jobname, checkpoint) that are common to almost all stages should be included.

All other keyword arguments are turned into lines in the .msj file. Keys that have a ‘.’ in them should have that . replaced with the class constant string DOT (_dot_). For instance to include a line setting trajectory.write_velocity to true, use the keyword argument trajectory_dot_write_velocity=’true’

class schrodinger.application.matsci.desconfig.MDMSJStringer(time=None, temp=None, pressure=None, random_seed=None, ensemble='NPT', method=None, timestep=None, last=False, **kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for Molecular Dynamics stages

__init__(time=None, temp=None, pressure=None, random_seed=None, ensemble='NPT', method=None, timestep=None, last=False, **kwargs)

Create a MDMSJStringer object

Any keyword that does not have a value supplied will use the default Desmond value for MD simulations.

Parameters
  • time (float) – Time in picoseconds

  • temp (float) – Temperature in Kelvin

  • pressure (float) – The pressure in bar

  • random_seed (int) – The seed for the random number generator

  • ensemble (str) – Valid Desmond ensemble such as NPT, NVT

  • method (str) – Valid Desmond ensemble method such as NH, Berendson, Langevin

  • timestep (int or float or str or list) – The timestep in picoseconds. If a string, will be treated as a float if it converts to float without error, otherwise it is used directly so must be in the proper [ x y z ] format used in .msj and .cfg files. If float or int, a string of the following format will be generated [ timestep timestep timestep * 3. ] If a list, the items will be converted to a string list of [ x y z ]

  • last (bool) – Whether the msj lines typically associated with the last stage (dir, compress) should be included

All other keyword arguments are turned into lines in the .msj file. See parent class for additional information.

getTitle()

Return a title for the stage describing the main parameters.

Return type

str

Returns

The title for this stage

class schrodinger.application.matsci.desconfig.MSAnalysisMSJStringer(analysis_type=None, **kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for MS MD Analysis stages

__init__(analysis_type=None, **kwargs)

Create a MSAnalysisMSJStringer object

Any keyword that does not have a value supplied will use the default Desmond value for MD simulations.

Parameters

analysis_type (str) – A string in the form of [ property property ] that lists the properties to be computed in the analysis.

All other keyword arguments are turned into lines in the .msj file. See parent class for additional information.

getTitle()

Return a title for the stage describing the main parameters.

Return type

str

Returns

The title for this stage

class schrodinger.application.matsci.desconfig.BrownieMSJStringer(time=100.0, temp=10.0, ensemble='NVT', timestep='[ 0.001 0.001 0.003 ]', delta_max=0.1, btau=None, ttau=None, **kwargs)

Bases: schrodinger.application.matsci.desconfig.MDMSJStringer

An MSJStringer class for Brownie stages

__init__(time=100.0, temp=10.0, ensemble='NVT', timestep='[ 0.001 0.001 0.003 ]', delta_max=0.1, btau=None, ttau=None, **kwargs)

Create a BrownieMSJStringer object

Desmond config does not have a specific set of defaults for Brownie stages, so the defaults are supplied here for all keywords.

Parameters
  • delta_max (float) – The value of delta_max

  • btau (float) – The value of the barostat tau

  • ttau (float) – The value of the thermostat tau

See parent class for additional information.

getTitle()

Return a title for the stage describing the main parameters.

Return type

str

Returns

The title for this stage

class schrodinger.application.matsci.desconfig.SysbuildMSJStringer(forcefield='OPLS_2005', compress='""', **kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for building systems

__init__(forcefield='OPLS_2005', compress='""', **kwargs)

Create a SysbuildMSJStringer object

Parameters

forcefield (str) – The forcefield to use

All other keyword arguments are turned into lines in the .msj file. See parent class for additional information.

class schrodinger.application.matsci.desconfig.ConcatMSJStringer(**kwargs)

Bases: schrodinger.application.matsci.desconfig.MSJStringer

An MSJStringer class for the concatenate stage.

STAGES = 'stages'
__init__(**kwargs)

Create a MSJStringer object

Parameters
  • stype (str) – The type of stage this is. Should be one of the class constants MINIMIZE, SIMULATE, SYSBUILD, ANALYSIS, or AVE_CELL

  • last (bool) – Whether the msj lines typically associated with the last stage (dir, compress) should be included

  • use_base (bool) – Whether the base msj lines (jobname, checkpoint) that are common to almost all stages should be included.

All other keyword arguments are turned into lines in the .msj file. Keys that have a ‘.’ in them should have that . replaced with the class constant string DOT (_dot_). For instance to include a line setting trajectory.write_velocity to true, use the keyword argument trajectory_dot_write_velocity=’true’

formLine(key, value)

Create the line that should go in the .msj file for the ‘stages’ key. Parent function creates strings for all other keys.

Parameters
  • key (str) – Typically, the string before the key = value pair on an msj line.

  • value (str) – Typically, the string after the key = value pair on an msj line.

Return type

str

Returns

The line (or lines) to put in the .msj file for this key/value pair

schrodinger.application.matsci.desconfig.get_materials_relaxation_stringers(temp=300.0, compress_last=True, pressure_isotropy='anisotropic')

Get a list of Stringer objects that reproduce the Materials Relaxation protocol

Parameters
  • temp (float) – The temperature for the last of the three stages

  • compress_last (bool) – If true, compress the last stage - the trajectory will not be available except as part of the tgz file. If False, the last stage will not be compressed and the trajectory will be available.

  • pressure_isotropy (str) – Barostat coupling between x, y, and z.

Return type

list

Returns

Each item of the list is a stage in the Materials Relaxation protocol

schrodinger.application.matsci.desconfig.get_semicrystalline_relaxation1_stringers(temp=300.0, compress_last=True, pressure_isotropy='anisotropic')

Get a list of Stringer objects that reproduce first Semi-Crystalline protocol

Parameters
  • temp (float) – The temperature for the last of the three stages

  • compress_last (bool) – If true, compress the last stage - the trajectory will not be available except as part of the tgz file. If False, the last stage will not be compressed and the trajectory will be available.

  • pressure_isotropy (str) – Barostat coupling between x, y, and z.

Return type

list

Returns

Each item of the list is a stage in the first Semi-Crysatlline relaxation protocol

schrodinger.application.matsci.desconfig.get_semicrystalline_relaxation2_stringers(temp=300.0, compress_last=True, pressure_isotropy='anisotropic')

Get a list of Stringer objects that reproduce second Semi-Crystalline Relaxation protocol

Parameters
  • temp (float) – The temperature for the last of the three stages

  • compress_last (bool) – If true, compress the last stage - the trajectory will not be available except as part of the tgz file. If False, the last stage will not be compressed and the trajectory will be available.

  • pressure_isotropy (str) – Barostat coupling between x, y, and z.

Return type

list

Returns

Each item of the list is a stage in the second Semi-Crysatlline relaxation protocol

schrodinger.application.matsci.desconfig.get_compressive_relaxation_stringers(temp=300.0, compress_last=True, pressure_isotropy='anisotropic')

Get a list of Stringer objects that reproduce the compressive relaxation protocol

Parameters
  • temp (float) – The temperature for the last of the three stages

  • compress_last (bool) – If true, compress the last stage - the trajectory will not be available except as part of the tgz file. If False, the last stage will not be compressed and the trajectory will be available.

  • pressure_isotropy (str) – Barostat coupling between x, y, and z.

Return type

list

Returns

Each item of the list is a stage in the compressive Relaxation protocol

schrodinger.application.matsci.desconfig.get_ladder_polymer_relaxation_stringers(pressure=1.01325, timestep=0.001)

Get a list of Stringer objects that reproduce the ladder polymer relaxation protocol (larsen relaxation protocol).

Parameters
  • pressure (float) – maximum value of pressue

  • timestep (int or float or str or list) – The timestep in picoseconds.

Return type

list

Returns

Each item of the list is a stage in the Larsen Relaxation protocol

schrodinger.application.matsci.desconfig.has_concatenated_stage(msjdata)

Check if the MSJData contains at least one concatenated stage.

Parameters

msjdata (sea.Map) – The MSJData object to be checked

Return type

bool

Returns

True if the MSJData object contains concatenated stages, else False

schrodinger.application.matsci.desconfig.expand_concatenated_stages(msjdata)

Remove concatenation from the MSJData. Search for concatenated simulation stages in the MSJData object and expand them.

Parameters

msjdata (sea.Map) – The MSJData object to be deconcatenated

Return type

tuple(bool, sea.Map)

Returns

A tuple containing a boolean indicating whether or not the MSJData object was deconcatenated and the deconcatenated MSJData object

schrodinger.application.matsci.desconfig.get_cfg_names_from_msj_data(data)

An iterator that yields the index, stage map and cfg file name for each stage in the given data that has a cfg file associated with it

Parameters

data (schrodinger.utils.sea.Map) – The data for all stages.

Raises

ValueError – If the data contains concatenated stages.

Return type

int, schrodinger.utils.sea.Map, str

Returns

(The stage index, the Map containing the stage data, and the name of the CFG file for that stage)

schrodinger.application.matsci.desconfig.get_cfg_names_from_msj_file(path)

An iterator that yields the index, stage map and cfg file name for each stage in the given a msj that has a cfg file associated with it

Parameters

path (str) – The path to the msj file.

Return type

int, schrodinger.utils.sea.Map, str

Returns

(The stage index, the Map containing the stage data, and the name of the CFG file for that stage)

schrodinger.application.matsci.desconfig.verify_cfg_files_exist(path)

Verify that the cfg files referenced in an msj file are present

Parameters

path (str) – The path to the msj file. cfg files will be searched for in the same directory.

Return type

list

Returns

Each item of the list is a name of a required cfg file

Raises

FileNotFoundError – If any of the cfg files do not exist in the same directory

schrodinger.application.matsci.desconfig.copy_msj_and_cfg(path, destination_dir='.')

Copy the specified msj file and any associated cfg files into the given directory

Parameters
  • path (str) – The path to the msj file

  • destination_dir (str) – The directory to copy the files to

Return type

list

Returns

Each item of the list is the name (not path) of a file that was copied, including the msj and any cfg files

Raises

FileNotFoundError – If any of the files are not found

schrodinger.application.matsci.desconfig.get_plane_trans_cart_to_frac(coord, direction, a_vec, b_vec, c_vec, rec=False)

Transform a plane defined by (coord, direction) from Cartesian ( reciprocal) to reciprocal(cartesian) coordinates.

Parameters
  • coord (float) – a float number defining the position of the plane in the direction vector

  • direction (float) – a float number defining the direction of the plane. 0, 1, 2 corresponds to x, y, z respectively

  • a_vec (list of 3 floats) – ‘a’ lattice vector

  • b_vec (list of 3 floats) – ‘b’ lattice vector

  • c_vec (list of 3 floats) – ‘c’ lattice vector

  • rec (bool) – If True, work in reciprocal space

schrodinger.application.matsci.desconfig.add_barrier_to_msj(struct, msj_str)

Add barrier information to MSJ task stage

Parameters
Return type

str

Returns

The update msj string with barrier information