schrodinger.application.matsci.parserutils module

Utilities for working with argument parsers

Copyright Schrodinger, LLC. All rights reserved.

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_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_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_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_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_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.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_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_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_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.type_ranged_num(arg, top=None, bottom=0.0, top_allowed=False, bottom_allowed=False, typer=<type 'float'>)

Validate that the argument is a number over a given range.

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_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