schrodinger.application.matsci.parserutils module¶
Utilities for working with argument parsers
Copyright Schrodinger, LLC. All rights reserved.
- schrodinger.application.matsci.parserutils.type_ranged_num(arg, top=None, bottom=0.0, top_allowed=False, bottom_allowed=False, typer=<class 'float'>)¶
Validate that the argument is a number over a given range. By default, it is (0, +inf)
- Note
This function can be used to directly create argparse typing for numbers within a specified range using a lambda function such as:
eqopts.add_argument( FLAG_TEMP, action='store', type=lambda x:parserutils.type_ranged_num(x, top=423, bottom=273), metavar='KELVIN', help='Simulation temperature for MD equilibration step')
- Parameters
arg (str) – The argument to validate
top (float or int) – The upper limit of the allowed range
bottom (float or int) – The lower limit of the allowed range
top_allowed (bool) – Whether arg may take the top value or not (whether the upper limit is inclusive or exclusive)
bottom_allowed (bool) – Whether arg may take the bottom value or not (whether the bottom limit is inclusive or exclusive)
typer (callable) – Should be one of the built-in float or int functions and defines the type of the value returned from this function.
- Return type
float or int
- Returns
The argument converted to a float or int, depending on the value of the typer keyword argument
- Raises
argparse.ArgumentTypeError – If the argument cannot be converted to a ranged floating point number in the given range
- schrodinger.application.matsci.parserutils.type_ranged_int(*args, **kwargs)¶
Validate that the argument is an int over a given range
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.get_ranged_int_typer(bottom_allowed=True, top_allowed=True, **kwargs)¶
Get a validator that will validate an integer over a custom range
- Usage::
- parser.add_argument(
A_FLAG, type=get_ranged_int_typer(bottom=4, top=12, bottom_allowed=False))
See type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.get_ranged_float_typer(bottom_allowed=True, top_allowed=True, **kwargs)¶
Get a validator that will validate a float over a custom range
- Usage::
- parser.add_argument(
A_FLAG, type=get_ranged_float_typer(bottom=-5.0, top=5.0, top_allowed=False))
See type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_smarts(args)¶
Validate that the argument is a valid smarts
- Note
This function can be used to directly create argparse typing for list of smarts or single smarts string.
- eqopts.add_argument(
FLAG_SMARTS, action=’append’, type=parserutils.type_smarts, help=’Define smarts’)
- Parameters
args (str, list) – The argument to validate
- Return type
str, list
- Returns
The validated smarts list or string
- Raises
argparse.ArgumentTypeError – If the argument is not a valid smarts raise exception
- schrodinger.application.matsci.parserutils.type_positive_float(arg)¶
Validate that the argument is a positive float
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_negative_float(arg)¶
Validate that the argument is a negative float
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_positive_int(arg)¶
Validate that the argument is a positive int
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_nonnegative_int(arg)¶
Validate that the argument is a nonnegative int
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_exclusive_percent(arg)¶
Validate that the argument is a percent, but neither zero nor 100
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_nonpositive_float(arg)¶
Validate that the argument is a nonpositive float
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_nonzero_percent(arg)¶
Validate that the argument is a percent but not zero
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_random_seed(arg, seed_min=0, seed_max=2147483647)¶
Validate that the argument is a valid random seed value. If a random value is requested, that value is generated and returned.
- Parameters
arg (str) – The argument to validate
seed_min (int) – The minimum allowed random number seed
seed_max (int) – The maximum allowed random number seed
- Return type
int
- Returns
The random seed
- Raises
argparse.ArgumentTypeError – If the argument is not RANDOM_SEED_RANDOM or an integer
- schrodinger.application.matsci.parserutils.type_file(arg)¶
Validate that the argument is an existing filename
- Parameters
arg (str or unicode) – The argument to validate
- Return type
str
- Returns
The str-ed argument
- Raises
argparse.ArgumentTypeError – If the given filename does not exist
- schrodinger.application.matsci.parserutils.type_msj(arg, return_msj=False)¶
Validate that the argument is a valid MSJ file.
- Parameters
arg (str) – the argument to validate
return_msj (bool) – Whether to return arg or msj object
- Raises
argparse.ArgumentTypeError – if the given argument is not a valid MSJ
- Return type
str or sea.Map
- Returns
the str-ed argument or MSJ object
- schrodinger.application.matsci.parserutils.type_nonnegative_float(arg)¶
Validate that the argument is a nonnegative float
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.get_trj_dir_name(st)¶
Get the trajectory directory name from the given structure.
- Parameters
st (schrodinger.structure.Structure) – the structure
- Return type
str or None
- Returns
the trajectory directory name or None if there isn’t one
- schrodinger.application.matsci.parserutils.type_csv_file(arg)¶
Validate that the argument is a CSV file.
- Parameters
arg (str) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a CSV file
- Return type
str
- Returns
the validated argument
- schrodinger.application.matsci.parserutils.type_out_file(arg)¶
Validate that the argument is a
*.out
file (intended to use for Jaguar output file)- Parameters
arg (str) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the argument is not a
*.out
file- Return type
str
- Returns
the validated argument
- schrodinger.application.matsci.parserutils.type_cms_file(arg, ensure_trj=False)¶
Validate that the argument is a cms file.
- Parameters
arg (str or unicode) – the argument to validate
ensure_trj (bool) – ensure that the cms file has trajectory information, for example is a Desmond output file
- Raises
argparse.ArgumentTypeError – if the given argument is not a cms file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_xyz_file(arg)¶
Validate that the argument is an existing filename with xyz extension and can be converted into sdf format.
- Parameters
arg (The argument to validate) – str
- Returns
str
- Return type
The validated argument
- Raises
argparse.ArgumentTypeError – If the given filename does not exist
argparse.ArgumentTypeError – If the given filename does not have xyz as file extension.
argparse.ArgumentTypeError – If the given filename cannot be converted
- schrodinger.application.matsci.parserutils.type_cms_with_trj(arg)¶
Validate that the argument is a cms file with trajectory information.
- Parameters
arg (str or unicode) – the argument to validate
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_json_file(arg)¶
Validate that the argument is a json file.
- Parameters
arg (str or unicode) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a json file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_yaml_file(arg)¶
Validate that the argument is a yaml file.
- Parameters
arg (str or unicode) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a yaml file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_toml_file(arg)¶
Validate that the argument is a toml file.
- Parameters
arg (str or unicode) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a toml file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_structure_file(arg)¶
Validate that the argument is a structure file that can be read by StructureReader.
- Parameters
arg (str or unicode) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a readable structure file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_element(value)¶
Validate that the argument is a valid atomic atymbol
- Parameters
value (str) – The argument to validate
- Return type
str
- Returns
The validated argument
- Raises
argparse.ArgumentTypeError – If the argument is not a valid atomic symbol
- schrodinger.application.matsci.parserutils.get_forcefield_typer(opls5_ok)¶
Get a validator that will validate a force field name while forcing OPLS5 to be allowed (or not allowed) regardless of MS_USE_OPLS5 feature flag state
- Usage::
- parser.add_argument(
A_FLAG, type=get_forcefield_typer(True|False)
- Parameters
opls5_ok (bool or None) – If True then ignore the MS_USE_OPLS5 feature flag and whether OPLS5 is available depends only on the OPLS5_SELECTABLE feature flag. If False then ignore MS_USE_OPLS5 and OPLS5 will not be available regardless of OPLS5_SELECTABLE. If None then OPLS5 will be available if and only if both OPLS5_SELECTABLE and MS_USE_OPLS5 are enabled.
See type_forcefield for documentation of return values and exceptions raised by the returned function
- schrodinger.application.matsci.parserutils.is_opls5_not_matsci_allowed(opls5_ok)¶
Check if OPLS5 is specifically not allowed by a MatSci setting. The state of the company-wide OPLS5_SELECTABLE setting is ignored.
- Parameters
opls5_ok (bool or None) – If True, OPLS5 will be allowed, if False, OPLS5 will not be allowed. Both bool settings override the state of the MS_USE_OPLS5 feature flag. The default value of None obeys MS_USE_OPLS5.
- Return type
bool
- Returns
True if OPLS5 is not allowed due to a MatSci setting, False if no MatSci setting disallows it
- schrodinger.application.matsci.parserutils.type_forcefield(value, opls5_ok=None)¶
Validate that the argument is a valid force field name
This accepts any valid name (OPLS3, OPLS3e, OPLS4, etc) for force field #16
- Parameters
value (str) – The argument to validate
opls5_ok (bool or None) – If True then ignore the MS_USE_OPLS5 feature flag and whether OPLS5 is available depends only on the OPLS5_SELECTABLE feature flag. If False then ignore MS_USE_OPLS5 and OPLS5 will not be available regardless of OPLS5_SELECTABLE. If None then OPLS5 will be available if and only if both OPLS5_SELECTABLE and MS_USE_OPLS5 are enabled.
- Return type
str
- Returns
The canonical force field name
- Raises
argparse.ArgumentTypeError – If the argument is not a valid atomic symbol
- schrodinger.application.matsci.parserutils.get_forcefield_typer_and_number_getter(opls5_ok)¶
Get a validator that will validate a force field name while forcing OPLS5 to be allowed (or not allowed) regardless of MS_USE_OPLS5 feature flag state
- Usage::
- parser.add_argument(
A_FLAG, type=get_forcefield_typer_and_number_getter(True|False)
- Parameters
opls5_ok (bool or None) – If True then ignore the MS_USE_OPLS5 feature flag and whether OPLS5 is available depends only on the OPLS5_SELECTABLE feature flag. If False then ignore MS_USE_OPLS5 and OPLS5 will not be available regardless of OPLS5_SELECTABLE. If None then OPLS5 will be available if and only if both OPLS5_SELECTABLE and MS_USE_OPLS5 are enabled.
See type_forcefield_and_get_number for documentation of return values and exceptions raised by the returned function
- schrodinger.application.matsci.parserutils.type_forcefield_and_get_number(value, opls5_ok=None)¶
Validate that the argument is a valid force field name and returns both the canonical force field name and number.
This accepts both OPLS3 and OPLS3e for force field #16
- Parameters
value (str) – The argument to validate
opls5_ok (bool) – If True, OPLS5 will be allowed, if False, OPLS5 will not be allowed. Both bool settings override the state of the MS_USE_OPLS5 feature flag. The default value of None obeys the feature flag.
- Return type
str, int
- Returns
The canonical force field name and the corresponding force field int
- Raises
argparse.ArgumentTypeError – If the argument is not a valid atomic symbol
- schrodinger.application.matsci.parserutils.type_desmond_ensemble(value)¶
Validate that the argument is a valid desmond ensemble
- Parameters
value (str) – The argument to validate
- Return type
str
- Returns
The validated argument
- Raises
argparse.ArgumentTypeError – If the argument is not a valid desmond ensemble
- schrodinger.application.matsci.parserutils.valid_forcefield_info(opls5_ok=None)¶
Get an informative sentence that can be included in help messages that indicate the valid force field names.
Note that these are the default names and type_forcefield will accept many variants of them, including OPLS3 for OPLS3E.
- Parameters
opls5_ok (bool or None) – If True then ignore the MS_USE_OPLS5 feature flag and whether OPLS5 is available depends only on the OPLS5_SELECTABLE feature flag. If False then ignore MS_USE_OPLS5 and OPLS5 will not be available regardless of OPLS5_SELECTABLE. If None then OPLS5 will be available if and only if both OPLS5_SELECTABLE and MS_USE_OPLS5 are enabled.
- Return type
str
- Returns
A full sentence describing the valid force field names
- class schrodinger.application.matsci.parserutils.NoArgCustomAction(*args, **kwargs)¶
Bases:
argparse.Action
An action that allows giving an argparse flag a custom action so that the flag does not require an argument
One possible use is the implementation of a flag like ‘-doc’ which immediately performs an action when it is found on the command line - such as printing out detailed documentation and then exiting. This avoids the user having to specify any other flags even if they are marked as required.
- __init__(*args, **kwargs)¶
- class schrodinger.application.matsci.parserutils.KeyPairDict¶
Bases:
dict
This is a subclass of dict so that the {a:b} can be displayed as “a=b” (e.g, as the help message”
- class schrodinger.application.matsci.parserutils.StoreDictKeyPair(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶
Bases:
argparse._StoreAction
This is the action used with nargs=”+” and values=’KEYWORD=VALUE KEYWORD=VALUE’
By default nargs=”+” and action=’store’ save the multiple values “k1=v1 k2=v2” as list. With this StoreDictKeyPair as the action, “k1=v1 k2=v2” will be stored as {k1:v1, k2:v2} in the options.
- schrodinger.application.matsci.parserutils.type_keywords_to_dict(value)¶
Convert a string of ‘keyword=value keyword=value …’ to a dictionary keyed by keyword. Values are the keyword values.
- Note
When calling parser.add_argument for the flag that uses this function, do not use “nargs=+”. That will result in the return value from this function being placed as an item in a list. Instead, do not use nargs at all and simply use “action=’store’”. All of the keyword=value pairs will then be passed into this function as a single string. Example:
parser.add_argument( FLAG_KEYWORDS, action='store', metavar='KEYWORD=VALUE KEYWORD=VALUE ...', type=parserutils.type_keywords_to_dict, help='Jaguar keywords given as a space-separated keyword=value ' ' pairs' )
will result in options.keyword = the dictionary returned by this function
- Parameters
value (str) – The argument to validate
- Return type
dict
- Returns
A dictionary with keywords as key keyword values as values
- Raises
argparse.ArgumentTypeError – If the argument is not a valid keyword string
- schrodinger.application.matsci.parserutils.type_keywords_to_string(value)¶
Validate the format of a string of ‘keyword=value keyword=value …’
- Note
When calling parser.add_argument for the flag that uses this function, do not use “nargs=+”. That will result in the return value from this function being placed as an item in a list. Instead, do not use nargs at all and simply use “action=’store’”. All of the keyword=value pairs will then be passed into this function as a single string. Example:
parser.add_argument( FLAG_KEYWORDS, action='store', metavar='KEYWORD=VALUE KEYWORD=VALUE ...', type=parserutils.type_keywords_to_string, help='Jaguar keywords given as a space-separated keyword=value ' ' pairs' )
will result in options.keyword = the string returned by this function
- Parameters
value (str) – The argument to validate
- Return type
string
- Returns
The original command line string
- Raises
argparse.ArgumentTypeError – If the argument is not a valid keyword string
- schrodinger.application.matsci.parserutils.type_num_list(value, delimiter=', ', typer=<class 'float'>, bottom=None, bottom_allowed=False)¶
Validate that the argument is a list of numbers separated by the delimiter
- Parameters
value (str) – string containing numbers separated by delimiter
delimiter (str) – the char to split the input value
typer (callable) – Should be one of the built-in float or int functions and defines the type of the value returned from this function.
bottom (float or int) – The lower limit of the allowed range
bottom_allowed (bool) – Whether arg may take the bottom value or not (whether the bottom limit is inclusive or exclusive)
- Return type
list
- Returns
The validated argument converted to a list of numbers
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of numbers
- schrodinger.application.matsci.parserutils.type_num_comma_list(value, typer=<class 'float'>, bottom=None, bottom_allowed=False)¶
Validate that the argument is a list of numbers separated by comma
- Parameters
value (str) – string containing numbers separated by commas
typer (callable) – Should be one of the built-in float or int functions and defines the type of the value returned from this function.
bottom (float or int) – The lower limit of the allowed range
bottom_allowed (bool) – Whether arg may take the bottom value or not (whether the bottom limit is inclusive or exclusive)
- Return type
list
- Returns
The validated argument positive integers coverted to list
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of floats
- schrodinger.application.matsci.parserutils.type_num_colon_list(value, typer=<class 'float'>, bottom=None, bottom_allowed=False)¶
Validate that the argument is a list of numbers separated by colon
- Parameters
value (str) – string containing numbers separated by colon
typer (callable) – Should be one of the built-in float or int functions and defines the type of the value returned from this function.
bottom (float or int) – The lower limit of the allowed range
bottom_allowed (bool) – Whether arg may take the bottom value or not (whether the bottom limit is inclusive or exclusive)
- Return type
list
- Returns
The validated argument positive integers coverted to list
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of floats
- schrodinger.application.matsci.parserutils.type_float_comma_list(value)¶
Validate that the argument is a float list separated by comma
- Parameters
value (str) – string containing numbers separated by commas
- Return type
list
- Returns
The validated argument positive integers converted to list
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of floats
- schrodinger.application.matsci.parserutils.type_nonnegative_float_comma_list(value)¶
Validate that the argument is a nonnegative float list separated by comma
- Parameters
value (str) – string containing numbers separated by commas
- Return type
list
- Returns
The validated argument positive integers converted to list
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of floats
- schrodinger.application.matsci.parserutils.type_positive_integer_comma_list(value)¶
Validate that the argument is a integer list separated by comma
- Parameters
value (str) – string containing numbers separated by commas
- Return type
list
- Returns
The validated argument positive integers coverted to list
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of positive integers
- schrodinger.application.matsci.parserutils.type_element_comma_list(value)¶
Validate that the argument is a element separated by comma
- Return type
list
- Returns
The validated argument list of element symbols
- Raises
argparse.ArgumentTypeError – If the argument is not a valid list of strings
- schrodinger.application.matsci.parserutils.type_percentage(value)¶
Validate that the argument is a percentage between 0 and 100
see type_ranged_num for documentation of arguments, return values and exceptions raised
- schrodinger.application.matsci.parserutils.type_asl(asl)¶
Validate ASL.
- Return type
str
- Returns
ASL
- Raises
argparse.ArgumentTypeError – If ASL is not valid
- schrodinger.application.matsci.parserutils.type_desmond_cfg(arg)¶
Validate that the argument is a desmond CFG file.
- Parameters
arg (str or unicode) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a readable CFG file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_desmond_msj(arg)¶
Validate that the argument is a desmond msj file. MSJ file contains multiple cfg stages.
- Parameters
arg (str or unicode) – the argument to validate
- Raises
argparse.ArgumentTypeError – if the given argument is not a readable CFG file
- Return type
str
- Returns
the str-ed argument
- schrodinger.application.matsci.parserutils.type_host(value)¶
Check the format of a host command line argument. These are expected to be in the format of hostname:X.
- Parameters
value (str) – The host command line argument to check
- Return type
(str, int)
- Returns
The hostname and number of subjobs
- Raises
argparse.ArgumentTypeError – If the command line argument is not in the correct format.
- class schrodinger.application.matsci.parserutils.SubscriptableNameSpace(**kwargs)¶
Bases:
argparse.Namespace
Extend the default namespace to allow getting options using “options[flag]”
- getNameFromFlag(flag)¶
Get the option variable name from the flag
- Parameters
flag (str) – The commandline flag
- Return str
The variable name in the parsed options
- __contains__(key)¶
Check if the option contains the passed flag or variable name
- Parameters
key (str) – The flag or variable name
- Return type
bool
- Returns
True if the option exists, False otherwise
- get(flag, default=None)¶
Get the option value for the flag, or return the default value if the option doesn’t exist
- Parameters
flag (str) – The flag to get the option for
default (Any) – The default value
- Return Any
The option value or default value
- copy()¶
Return a copy of this namespace
- Return SubscriptableNameSpace
A copy of this namespace
- extract_dict(*flags)¶
Extract the options for the passed flags and return a dict containing them
- Parameters
flags (tuple) – The flags to extract options for
- Return type
dict
- Returns
The extracted options
- class schrodinger.application.matsci.parserutils.DriverParser(*args, add_help=False, formatter_class=<class 'argparse.ArgumentDefaultsHelpFormatter'>, allow_abbrev=False, **kwargs)¶
Bases:
argparse.ArgumentParser
Subclass that shows driver usage relative to python/scripts or python/common directories and adds a help argument by default
- __init__(*args, add_help=False, formatter_class=<class 'argparse.ArgumentDefaultsHelpFormatter'>, allow_abbrev=False, **kwargs)¶
Accepts all arguments normally given for an ArgumentParser
- parse_args(args=None, namespace=None)¶
Overwrite parent method to use SubscriptableNameSpace as default namespace
- Parameters
args (list or None) – List of commandline arguments
namespace (None or argparse.Namespace) – The namespace to use. Uses SubscriptableNameSpace by default
- Return argparse.Namespace
The parsed commandline arguments
- set_defaults(**defaults)¶
Overwrite parent method to set defaults only for arguments that have been added to the parser
- Parameters
defaults (dict) – Dict mapping arguments to their default values
- error(message, *args, **kwargs)¶
Overwrite to store the error message.
- schrodinger.application.matsci.parserutils.modify_help_message(parser, flag, msg)¶
Modify the help message of an existing parser argument
- Parameters
parser (DriverParser) – The populated parser
flag (str) – The flag whose help message should be modified
msg (str) – The new help message
- Raises
ValueError – If the flag is not recognized by the parser
- schrodinger.application.matsci.parserutils.parse_keyword_list(options, exit_on_error=True, logger=None, validate=False)¶
Adds keystring and keydict properties to the argparse options object that are the list of keyword arguments turned into, respectively, a string or a dictionary. Valid keyword syntax is checked for.
Typical usage:
parserutils.add_keyword_parser_argument(parser) options = parser.parse_args(args) parserutils.parse_keyword_list(options) print options.keystring, options.keydict
- Parameters
options (
argparse.Namespace
) – The parser Namespace object with a keywords attributeexit_on_error (bool) – True if the ValueError for keyword syntax should result in a message being printed and sys.exit() being called, False if the error should just be raised.
logger (
logging.Logger
) – The logger to use for recording error messages, otherwise they’ll be printed.validate (bool) – Whether keywords/values not recognized by Jaguar should be considered an error.
- Raises
ValueError – If an invalid keyword pair syntax is detected and handle_error is False
- :raises
schrodinger.application.jaguar.validation.JaguarKeywordException
if validate=True, exit_on_error=False and an invalid Jaguar keyword/value has been used.
- schrodinger.application.matsci.parserutils.get_stripped_defaults(adict)¶
Remove dashes in the beginning of the keys. Used with ArgumentParser.
- Parameters
adict (dict{string:any}) – Dictionary of defaults
- Return type
dict{string:any}
- Returns
Dictionary of defaults with dashed stripped from the keys
- schrodinger.application.matsci.parserutils.argparser_set_defaults(parser, defaults)¶
Set default values to the arguments already present in the parser. Note that, parser.set_defaults contaminates namespace with the arguments that might be absent from the parser.
- Parameters
parser (
argparse.ArgumentParser
) – The parser to set defaultsdefaults (dict{string:any}) – Dictionary of the defaults
- class schrodinger.application.matsci.parserutils.PhysicalFlag(name, unit, default)¶
Bases:
schrodinger.application.matsci.parserutils.PhysicalFlag
namedtuple
containing the information needed to create an argument flag for a physical property.- Variables
name (str) – The name of the physical property being flagged
unit (str) – The displayed units of the physical property (e.g., ‘K’ for temperature)
default – The default value to use for the given physical flag. If
None
, a default value will be chosen for you.
- schrodinger.application.matsci.parserutils.add_physical_arguments(parser, flags)¶
Add physical arguments to the parser
- Parameters
parser (argparse.ArgumentParser) – The parser to add arguments to
flags (list(PhysicalFlag)) – List of physical flags to add to the parser. Each element should be an instance of the
PhysicalFlag
namedtuple.
- Raises
argparse.ArgumentTypeError – If an argument is not recognized as a physical argument.
- schrodinger.application.matsci.parserutils.add_restart_parser_arguments(parser)¶
Add restart arguments to the parser
- Parameters
parser (
argparse.ArgumentParser
) – The parser to add arguments to
- schrodinger.application.matsci.parserutils.add_keyword_parser_argument(parser, keyword_flags=None, default='', arghelp=None, action='store')¶
Add a keyword argument to the parser
- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument tokeyword_flags (None or list of str) – the customized flags for this argument
default (str or None) – The customized default values for this argument
arghelp (str or None) – The customized help message for this argument
action (
argparse.Action
or str) – The customized action for this argument or the standard ones: ‘store’, ‘store_true’, ‘store_false’, ‘append’ and so on.
- schrodinger.application.matsci.parserutils.add_save_desmond_files_parser_argument(parser)¶
Add a
SAVE_FLAG
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_compress_subjobs_parser_argument(parser, help=None)¶
Add a
FLAG_COMPRESS_SUBJOBS
argument to the parser- Parameters
parser (argparse.ArgumentParser) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_desmond_parser_arguments(parser, args, defaults=None, time_use_ps=False, opls5_ok=None)¶
Add desmond related arguments to the parser
- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument toargs (list) – List of arguments to add to the parser
defaults (dict or None) – Default values for the arguments
time_use_ps (bool) – If true use pico-second for time else nanosecond
opls5_ok (bool) – If True, OPLS5 will be allowed, if False, OPLS5 will not be allowed. Both bool settings override the state of the MS_USE_OPLS5 feature flag. The default value of None obeys the feature flag.
- schrodinger.application.matsci.parserutils.add_cg_forcefield_parser_arguments(parser, local_path, defaults=None)¶
Add desmond related arguments to the parser
- Parameters
parser (argparse.ArgumentParser) – The parser to add the arguments to
local_path (str) – We can search for CG forcefield files in either an “installed” directory or a “local” directory. This argument is the location of the “local” directory.
defaults (dict) – Default values for the arguments
- schrodinger.application.matsci.parserutils.add_traj_analysis_parser_arguments(parser, trj_optional=False)¶
Add trajectory analysis parser arguments/
- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument totrj_optional (bool) – Whether trajectory is optional
- schrodinger.application.matsci.parserutils.add_random_seed_parser_argument(parser, additional_args=(), help='Seed for random number generator.')¶
Add the command line flag for the random number seed
- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument toadditional_args (tuple) – Arguments that should also be accepted in addition to FLAG_RANDOM_SEED
help (str) – The help string to show for random seed. The default string will be used if nothing is supplied.
- schrodinger.application.matsci.parserutils.add_conformational_search_to_parser(parser, seed_min=0, seed_max=2147483647)¶
Add flags related to the conformational search to the parser.
- Parameters
parser (argparse.ArgumentParser) – The parser to add this argument to
seed_min (int) – The minimum allowed random number seed
seed_max (int) – The maximum allowed random number seed
- schrodinger.application.matsci.parserutils.add_tpp_parser_argument(parser)¶
Add a
FLAG_TPP
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_out_rep_parser_argument(parser)¶
Add a
FLAG_OUT_REP
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_dedup_geom_eps_parser_argument(parser)¶
Add a
FLAG_DEDUP_GEOM_EPS
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_mopac_parser_argument(parser)¶
Add a
FLAG_MOPAC
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_xtb_parser_argument(parser)¶
Add a
FLAG_XTB
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_robust_jaguar_argument(parser)¶
Add a
FLAG_ROBUST
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_boltzmann_energy_argument(parser, lowest=True, prop_required=True)¶
Add parser arguments for Boltzmann averaging
- Parameters
parser (argparse.ArgumentParser) – The parser to add this argument to
lowest (bool) – Whether to add the -lowest flag
prop_required (bool) – Whether the energy prop flag is required
- schrodinger.application.matsci.parserutils.add_max_retries_argument(parser)¶
Add a
FLAG_MAX_RETRIES
argument to the parser- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_smarts_method_argument(parser, default=SMARTS_METHOD.internal)¶
Add a
FLAG_SMARTS_METHOD
argument to the parser.- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument todefault (msconst.SMARTS_METHOD) – Default method
- schrodinger.application.matsci.parserutils.add_metal_center_element_argument(parser)¶
add an
ATOMIC_SYMBOL
argument to the parser, for metal center in coordination complex.- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument to
- schrodinger.application.matsci.parserutils.add_geom_argument(parser, default_choice=None)¶
add a
VSEPR_GEOMETRY
argument to the parser, for geometry of coordination complex.- Parameters
parser (
argparse.ArgumentParser
) – The parser to add this argument todefault_choice (str) – Default geometry to use. Must be in buildcomplex.CMDLINE_GEOMETRIES
- schrodinger.application.matsci.parserutils.add_cpu_gpu_host_arguments(parser, required=False, cpu_default=None, gpu_default=None)¶
Add a flags for setting the cpu host and gpu host to the parser.
- Parameters
parser (
argparse.ArgumentParser
) – The parser to add these arguments torequired (bool) – Whether the arguments are required
cpu_default (type_host) – The default value for the cpu host
gpu_default (type_host) – The default value for the gpu host
- schrodinger.application.matsci.parserutils.add_jaguar_dict_keywords_flag(parser, default=None, msg=None)¶
Add a flag for keywords to be stored in a keyword/value dict
- Parameters
parser (argparse.ArgumentParser) – The parser to add this argument to
default (str) – The default keyword string to use
msg (str) – A custom help message for the flag
- schrodinger.application.matsci.parserutils.get_cpu_and_gpu_hosts(options)¶
Get the command line options for the cpu and gpu hosts
- Parameters
options (SubscriptableNameSpace) – The command line options
- Return type
tuple
- Returns
The first item in the tuple is the result for the CPU host, the second is for the GPU host. Each item is either a (hostname, #_procs) tuple or None if that option was not given.
- schrodinger.application.matsci.parserutils.get_jobname(options, default_jobname)¶
Gets the job name from the parsed options. If there is no job name, use the default specified in this driver.
- Parameters
options (argparse.Namespace) – The parsed command line options
default_jobname (str) – The job name to use if no explicit name is found in
options
- Returns
The name of the job. Prioritizes the name given in the options, but falls back to a default job name.
- Return type
str