schrodinger.application.desmond.cmj module¶
This module provides fundamental facilities for writing a multisim driver script, for writing multisim concrete stage classes, and for dealing with protocol files.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.desmond.cmj.
JobStatus
(code=101)[source]¶ Bases:
object
-
WAITING
= 101¶
-
RUNNING
= 102¶
-
SUCCESS
= 103¶
-
BACKEND_ERROR
= 201¶
-
PERMANENT_LICENSE_FAILURE
= 202¶
-
NON_RETRIABLE_FAILURE
= 299¶
-
TEMPORARY_LICENSE_FAILURE
= 301¶
-
KILLED
= 302¶
-
FIZZLED
= 303¶
-
LAUNCH_FAILURE
= 304¶
-
FILE_NOT_FOUND
= 305¶
-
FILE_CORRUPT
= 306¶
-
STRANDED
= 307¶
-
CHECKPOINT_REQUESTED
= 308¶
-
CHECKPOINT_WITH_RESTART_REQUESTED
= 309¶
-
RETRIABLE_FAILURE
= 399¶
-
STRING
= {101: 'is waiting for launching', 102: 'is running', 103: 'was successfully finished', 201: 'died due to backend error', 202: 'could not run due to permanent license failure', 299: 'died on unknown non-retriable failure', 301: 'died due to temporary license failure', 302: 'was killed', 303: 'fizzled', 304: 'failed to launch', 305: 'was finished, but registered output files were not found', 306: 'was finished, but an essential output file was found corrupt', 307: 'was stranded', 308: 'user requested job be checkpointed', 309: 'user requested job be checkpointed and restarted', 399: 'died on unknown retriable failure'}¶
-
-
class
schrodinger.application.desmond.cmj.
JobOutput
[source]¶ Bases:
object
-
class
schrodinger.application.desmond.cmj.
JobInput
[source]¶ Bases:
schrodinger.application.desmond.cmj.JobOutput
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
-
__len__
()¶ Returns the number of registered output files.
-
add
(filename, checker=None, tag=None, type='file')¶ - Parameters
type – either “file” and “dir”.
-
check
(status)¶
-
get
(tag)¶
-
log_file
()¶
-
remove
(filename)¶
-
set_struct_file
(fname)¶
-
struct_file
()¶
-
update_basedir
(old_basedir, new_basedir)¶
-
-
class
schrodinger.application.desmond.cmj.
JobErrorHandler
[source]¶ Bases:
object
-
schrodinger.application.desmond.cmj.
exit_code_is_defined
(job)[source]¶ Return True if job has an exit code. Failed jobs may not have exit codes if they are killed by the queueing system or otherwise untrackable.
-
class
schrodinger.application.desmond.cmj.
Job
(jobname, parent, stage, jlaunch_cmd, dir, host_list=None, prefix=None, what=None, err_handler=<function JobErrorHandler.default>)[source]¶ Bases:
object
-
USE_GPU
= False¶
-
__init__
(jobname, parent, stage, jlaunch_cmd, dir, host_list=None, prefix=None, what=None, err_handler=<function JobErrorHandler.default>)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
process_completed_job
(jctrl: schrodinger.job.jobcontrol.Job, checkpoint_requested=False, restart_requested=False)[source]¶ Check for valid output and set status of job, assuming job is already complete.
- Parameters
checkpoint_requested – Set to True if the job should checkpoint. Default if False.
restart_requested – Set to True if the job should checkpoint and restart. Default if False.
-
requeue
(jctrl: schrodinger.job.jobcontrol.Job)[source]¶
-
-
class
schrodinger.application.desmond.cmj.
StageBase
(should_pack=True)[source]¶ Bases:
schrodinger.application.desmond.picklejar.Picklable
-
count
= 0¶
-
stage_cls
= {'generic': <class 'schrodinger.application.desmond.cmj.StructureStageBase'>}¶
-
stage_obj
= {}¶
-
NAME
= 'generic'¶
-
PARAM
= <schrodinger.utils.sea.sea.Map object>¶
-
migrate_param
(param: schrodinger.utils.sea.sea.Map)[source]¶ Subclasses can implement this to migrate params to provide backward compatibility with older msj files, ideally with a deprecation warning.
-
crunch
()[source]¶ This is where jobs of this stage are created. This function should be overriden by the subclass.
-
-
class
schrodinger.application.desmond.cmj.
StructureStageBase
(*args, **kwargs)[source]¶ Bases:
schrodinger.application.desmond.cmj.StageBase
StructureStageBase can be used for stages that take in a path to a structure, apply some transformation, and then write out an updated structure.
-
crunch
()[source]¶ This is where jobs of this stage are created. This function should be overriden by the subclass.
-
run
(jobname: str, input_fname: str) → Optional[str][source]¶ - Parameters
jobname – Jobname for this stage.
input_fname – Filename for the input structure.
- Returns
Filename for the output structure or
None
if there was an error generating the output.
-
NAME
= 'generic'¶
-
PARAM
= <schrodinger.utils.sea.sea.Map object>¶
-
capture
(job)¶
-
check_param
()¶
-
count
= 0¶
-
describe
()¶
-
determine
()¶
-
hook_captured_successful_job
(job)¶
-
migrate_param
(param: schrodinger.utils.sea.sea.Map)¶ Subclasses can implement this to migrate params to provide backward compatibility with older msj files, ideally with a deprecation warning.
-
pack_stage
(force=False)¶
-
poststage
()¶
-
prestage
()¶
-
push
(job)¶
-
release
(is_restarting=False)¶ Calls the ‘crunch’ method to generate new jobs objects and submits them to the ‘QUEUE’.
-
restart_subjobs
(jobs)¶ Subclass should override this if it supports subjob restarting.
-
stage_cls
= {'generic': <class 'schrodinger.application.desmond.cmj.StructureStageBase'>}¶
-
stage_obj
= {}¶
-
time_stage
()¶
-
-
class
schrodinger.application.desmond.cmj.
Engine
(opt=None)[source]¶ Bases:
object
-
JOBBE
= None¶
-
boot_setup
(base_dir=None)[source]¶ Set up an
Engine
object, but do not start the queue.- Parameters
base_dir – Set to the path for the base_dir or
None
, the default, to use the cwd.
-
run_set_family
(max_stage_idx=None)[source]¶ Re-run set_family for all task stages up to
max_stage_idx
.
-
-
exception
schrodinger.application.desmond.cmj.
StopRequest
[source]¶ Bases:
Exception
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
schrodinger.application.desmond.cmj.
StopAndRestartRequest
[source]¶ Bases:
Exception
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
schrodinger.application.desmond.cmj.
ParseError
[source]¶ Bases:
Exception
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
schrodinger.application.desmond.cmj.
build_stages
(stage_list, out_fname=None, stage_state=[])[source]¶ Build up the stages for the job, adding the initial Primer and final Concluder stages.
-
schrodinger.application.desmond.cmj.
append_stage
(cmj_fname, stage_type, cfg_file=None, jobname=None, dir=None, compress=None, parameter={})[source]¶
-
schrodinger.application.desmond.cmj.
concatenate_relaxation_stages
(raw)[source]¶ Attempts to concatenate relaxation stages by finding all adjacent non-production
simulate
stages. If no concatenatable stages are found, None is returned. Otherwise, a new raw map with the relaxationsimulate
stages replaced with a singleconcatenate
stage is returned.- Parameters
raw (
sea.Map
) – the raw map representing the MSJ- Returns
a new raw map representing the updated msj, or None.
- Return type
sea.Map
orNone
-
schrodinger.application.desmond.cmj.
get_concat_stages
(stages, param_attr='')[source]¶ Get a list of the stages that can be concatenated together, and the insertion point of the resulting concatenate stage. Stages can be concatenated if they are adjacent simulate stages with the same restraints, excluding the final production stage, which can be lambda hopping, replica exchange, or otherwise the last simulate stage.
- Parameters
stages (list of (sea.Map or stage.Stage)) – A list of objects representing multisim stages. For flexibility, these can be either maps or stages. For stages, a param attribute must be passed that will give the location of the param on the stage.
param_attr (str) – optional name of the attribute of the objects param, in case of a stage.Stage object.
-
schrodinger.application.desmond.cmj.
make_empty_restraints
(existing='ignore') → schrodinger.utils.sea.sea.Map[source]¶
-
schrodinger.application.desmond.cmj.
get_restrain
(sm: schrodinger.utils.sea.sea.Map) → schrodinger.utils.sea.sea.Sea[source]¶
-
schrodinger.application.desmond.cmj.
get_restraints
(sm: schrodinger.utils.sea.sea.Map) → schrodinger.utils.sea.sea.Map[source]¶
-
schrodinger.application.desmond.cmj.
get_restraints_xor_convert_restrain
(param: schrodinger.utils.sea.sea.Map) → schrodinger.utils.sea.sea.Map[source]¶ Returns
restrains
orrestrain
(converted intorestraints
format) from theparam
. RaisesValueError
if both are set.- Parameters
param – stage parameters
- Returns
restraints block
-
schrodinger.application.desmond.cmj.
restraints_incompatible
(param: schrodinger.utils.sea.sea.Map, initial_param: schrodinger.utils.sea.sea.Map, has_permanent_restrain: bool)[source]¶ Returns whether restraints parameters are compatible with switching during a concatenate stage. For compatibility the parameters has to differ from the initial ones by only a scaling factor (which can include zero). Furthermore, there can be no differences between restraints and initial restraints if
permanent_restrain
is truthy, as there is no way to selectively scale restraints.- Parameters
param (
sea.Map
) – the param for a given stageinitial_param (
sea.Map
) – parameters for the first stagehas_permanent_restrain (bool) – whether or not there are restraints applied to all stages via the
permanent_restraints
mechanism
- Returns
a message declaring how the restraints are incompatible, or an empty string if they are compatible
- Return type
str
-
schrodinger.application.desmond.cmj.
has_explicit_restraints
(param: schrodinger.utils.sea.sea.Map)[source]¶ - Parameters
param – the param for a given stage
- Returns
whether or not the
restraints
block has new or existing restraints
-
schrodinger.application.desmond.cmj.
check_restrain_diffs
(restrain, initial_restrain)[source]¶ See if the differences between two restrain blocks are concatenation-compatible, meaning they are both
sea.Map
objects and differ only by a force constant.- Parameters
restrain (
sea.Map
orsea.List
) – the restrain block for a given stageinitial_restrain (
sea.Map
orsea.List
) – the restraints for the first stage
- Returns
a message declaring how the restraints are incompatible, or an empty string if they are compatible
- Type
str
-
schrodinger.application.desmond.cmj.
msj2sea
(fname, msj_content=None)[source]¶ Parses a file as specified by ‘fname’ or a string given by ‘msj_content’ (if both are given, the former will be ignored), and returns a ‘sea.Map’ object that represents the stage settings with a structure like the following:
stage = [ { <stage 1 settings> } { <stage 2 settings> } { <stage 3 settings> } ... ]
Each stage’s name can be accessed in this way: raw.stage[1].__NAME__, where ‘raw’ is the returned ‘sea.Map’ object.
-
schrodinger.application.desmond.cmj.
parse_msj
(fname, msj_content=None, pset='')[source]¶ sea.update_macro_dict must be called prior to calling this function.
-
schrodinger.application.desmond.cmj.
write_msj
(stage_list, fname=None, to_str=True)[source]¶ Given a list of stages, writes out a .msj file of the name ‘fname’.
If ‘to_str’ is True, a string will be returned. The returned string contains the contents of the .msj file. If ‘to_str’ is False and not file name is provided, then this function does nothing.
-
schrodinger.application.desmond.cmj.
collect_inputfile
(stage_list)[source]¶ Returns a list of file names.
-
class
schrodinger.application.desmond.cmj.
AslValidator
[source]¶ Bases:
object
-
CTSTR
= 'hydrogen\n\n\n 1 0 0 0 1 0 999 V2000\n -1.6976 2.1561 0.0000 C 0 0 0 0 0 0\nM END\n$$$$\n'¶
-
CT
= None¶
-