schrodinger.application.jaguar.workflow_input module

Functions and classes for defining the input to a Workflow workflow.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.jaguar.workflow_input.WorkflowInput(inputfile: str | None = None, keywords: dict[str, Any] | None = None, jaguar_keywords: dict[str, Any] | None = None, jobname: str | None = None)

Bases: ABC

A Base class for specifying parameters in workflow calculations.

The following functions must be defined in the inheriting class:
  • validate(self)

abstract validate()

Perform a self-consistency check of all currently set keywords.

write for inheriting class

Return param:

Whether or no input passes workflow-specific validation checks

Return type:

bool

abstract property input_file_keys: list[str]

List of keys for all possible workflow input files. This is used to determine which keywords are input file paths.

Note, this property should be defined at the class level, but seemingly can’t use @classmethod and @property decorators together.

Returns:

List of keys for all possible workflow input files

abstract property keyword_source: dict[str, WorkflowKeyword]

Dictionary of all possible workflow keywords.

Note, this property should be defined at the class level, but seemingly can’t use @classmethod and @property decorators together.

Returns:

Dictionary of all possible workflow keywords

abstract static keyword_generator() None

Function to generate the keyword source dictionary. This is used to initialize the keyword_source property.

Returns:

None

abstract property workflow_name: str

Name of the workflow.

Returns:

Name of the workflow

classmethod generate_keywords() dict[str, WorkflowKeyword]

Initialize the list of possible keywords

Return param:

key, WorkflowKeyword pairs specific to this job’s input file

__init__(inputfile: str | None = None, keywords: dict[str, Any] | None = None, jaguar_keywords: dict[str, Any] | None = None, jobname: str | None = None)

Create a WorkflowInput instance. If a keyword is specified in both ‘inputfile’ and ‘keywords’, then the values in ‘keywords’ will be set preferrentially. This also applies to ‘jaguar_keywords’.

Parameters:
  • inputfile – Path to a Workflow input file

  • keywords – Workflow keyword/value pairs

  • jaguar_keywords – Jaguar &gen section keyword/value pairs

  • jobname – Name of job, if it is not None it will be set to the basename of the input file name.

getInputMolecule() Structure | None

Return input molecule. If no file found, return None.

Returns:

Input Structure

getInputMolecules() list[Structure] | None

Return list of input molecules. If no file(s) found, return None.

Returns:

Structures

classmethod keyword_options_string() str

Make a string describing all keywords that can be used with the workflow, except for hidden ones which are still in development

Returns:

String containing all keywords and descriptions

print_user_keywords(log: ~typing.Callable = <built-in function print>)

Print user-specified keywords.

Parameters:

log – Function to use for printing

get_user_input_keyword_string() tuple[str, str]

Generate plain text and HTML recording any user-specified non-default keyword/value pairs provided by the user, including an optional &JaguarKeywords section.

Returns:

plain text, HTML

property keywords
property values

Support access to WorkflowKeyword values via attribute syntax. e.g.:

wi = WorkflowInput()
print wi.values.optimize   # print 'optimize' keyword value
getValue(keyword: str)

Return the value for Workflow keyword. The return type depends on the keyword.

Parameters:

keyword – name of keyword

:raise WorkflowKeywordError if no keyword found

setValue(keyword: str, value: Any)

Set the Workflow keyword ‘keyword’ to value ‘value’. Note that there may be type-checking and conversion by the WorkflowKeyword class.

Parameters:
  • keyword – name of keyword

  • value – value of keyword. If ‘value’ is None, the keyword will be reset.

Raises:

WorkflowKeywordException – if no keyword found or there is an issue with the keyword or value

setValues(keywords)

Set multiple Workflow keywords.

Parameters:

keywords (dict of string/anytype pairs) – keyword/value pairs

getJaguarValue(key: str) Any

Return the value for Jaguar keyword ‘key’. The return type depends on the keyword.

Parameters:

key – name of keyword

setJaguarValue(key: str, value: Any)

Set the Jaguar &gen section keyword ‘key’ to value ‘value’. If ‘value’ is None then if the keyword was in the user keys then it is reset and removed from the dict.

Parameters:
  • key – name of keyword

  • value – value of keyword. If ‘value’ is None, the keyword will be reset.

:raise JaguarKeywordException if keyword is invalid

setJaguarValues(keywords: dict[str, Any])

Set multiple Jaguar &gen section keywords.

Parameters:

keywords – Jaguar &gen section keyword/value pairs

getJaguarNonDefault() dict[str, Any]

Return a dictionary of all non-default Jaguar keys except ‘multip’ and ‘molchg’, which must be retrieved explicitly.

resetKey(keyword: str)

Reset keyword to default state.

Parameters:

keyword – name of keyword

resetAll()

Reset all keywords to their default states.

getDefault(keyword: str)

Return the default value for Workflow keyword ‘keyword’. The return type depends on the keyword.

Parameters:

keyword – name of keyword

:raise WorkflowKeywordError if no keyword found

getNonDefaultKeys()

Return a dictionary of all non-default-value WorkflowKeyword instances indexed by name.

isNonDefault(keyword: str) bool

Has the specified keyword been set to a non-default value?

Parameters:

keyword – The key to check

Returns:

True if the specified keyword is set to a non-default value. False otherwise.

setConstraints(constraints: dict[str, list[Coordinate]])

Set the constraints.

Parameters:

constraints (dict of str: Coordinate instance) – dictionary relating structure title to a list of Coordinate instances which define the constraints

getConstraints()

Return the constraints defined in the input file

Returns:

a dict relating structure titles to constraints the constraints are given as a list of Coordinate instances and the titles refer to the titles of the input molecules.

setFrozenAtoms(frozen_atoms: dict[str, list[Coordinate]])

Set the constraints.

Parameters:

frozen_atoms – dictionary relating structure title to a list of Coordinate instances which define the frozen atoms

getFrozenAtoms() dict[str, list[Coordinate]]

Return the frozen atoms defined in the input file

Returns:

a dict relating structure titles to constraints the constraints are given as a list of Coordinate instances and the titles refer to the titles of the input molecules.

validate_jaguar_keywords(sts: list[Structure])

Perform a check to ensure that Jaguar keywords are not set in a way that cannot be handled.

Parameters:

sts – Structures whose basis needs validating

save(name: str)

Create a Workflow input file called ‘name’ in the current working directory based on this class instance. Only write the non-default keyword values.

Parameters:

name – Path to a Workflow input file

setJobname(jobname: str)

Set the attribute jobname.

Parameters:

jobname – input name of job. If jobname is None we try to use self._inputfile. If that is also None we assign a unique name.

read(inputfile: str)

Read an existing Workflow input file.

Any keywords specified in the input file will override existing values in this WorkflowInput instance.

Jaguar &gen section keywords are defined as below. Section header can be &JaguarKeywords(_StageName). If &JaguarKeywords, the keys are both stored in self._jaguar_user_keys and used to set values in self._jaguarinput. If &JaguarKeywords_StageName, they are only stored in self.jaguar_stage_user_keys, keyed by “StageName”:

&JaguarKeywords
  key=val
  key=val
  ...
&
&JaguarKeywords_StageName1
  key=val
  ...
&
&JaguarKeywords_StageName2
  key=val
  ...
&

Constraints can be defined with:

&Constraints
    st_title atom_index1 atom_index2... value
&
Parameters:

inputfile – Path to a Workflow input file

remove_input_file_paths()

Remove full paths from file specifications. A new input file is no longer written, if that is desired the user must call the save method.

update_input_file_paths()

Update full paths for file specifications to reflect the CWD. This is useful if running this job in a subdirectory or on a remote host.

have_constraints() bool

Do we have internal coordinate constraints

have_frozen_atoms() bool

Do we have frozen atom constraints

get_input_files() set[str]

Return set of expected input files.

prep_input_molecules(structures: list[Structure] | Structure | None) list[Structure] | Structure | None

Prepare input molecules for the workflow. Typically called from the getInputMolecule(s) method of the inheriting class.

Parameters:

structures – List of input structures to be prepared.

Returns:

List of prepared structures.