schrodinger.application.phase.packages.phase_utils module¶
Module with common functionality for all Phase backends.
Copyright Schrodinger LLC, All Rights Reserved.
-
class
schrodinger.application.phase.packages.phase_utils.
RestrictedRange
(lower_limit, upper_limit, lower_inclusive=True, upper_inclusive=True)¶ Bases:
object
Provides generalized range checking suitable for the add_argument function of argparser.ArgumentParser. For example:
parser = argparse.ArgumentParser() parser.add_argument(“-dihed”, type=float, metavar=”<degrees>”,
choices=[RestrictedRange(-180.0, 180.0)], help=”Dihedral angle in degrees.”)- parser.add_argument(“-path”, type=int, metavar=”<length>”,
- choices=[RestrictedRange(1, None)], help=”Non-zero path length in bonds.”)
More general usage is as follows:
legal_range = RestrictedRange(-180.0, 180.0) dihed = 120.0 if dihed in legal_range:
print(“Dihedral is legal”)-
__init__
(lower_limit, upper_limit, lower_inclusive=True, upper_inclusive=True)¶ Constructor taking lower and upper limits and whether those limits are inclusive. Use None for a limit that doesn’t exist.
Parameters: - lower_limit (Any numeric type or None) – Lower limit of legal range
- upper_limit (Any numeric type or None) – Upper limit of legal range
- lower_inclusive (bool) – True if lower limit is inclusive
- upper_inclusive (bool) – True if upper limit is inclusive
-
__contains__
(value)¶ The “in” operator for the provided value.
-
__eq__
(value)¶ The “==” operator for the provided value, which is equivalent to “in”. argparse needs this.
-
__repr__
()¶ Returns the representation string.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.application.phase.packages.phase_utils', '__doc__': '\n Provides generalized range checking suitable for the add_argument function\n of argparser.ArgumentParser. For example:\n\n parser = argparse.ArgumentParser()\n parser.add_argument("-dihed", type=float, metavar="<degrees>",\n choices=[RestrictedRange(-180.0, 180.0)],\n help="Dihedral angle in degrees.")\n parser.add_argument("-path", type=int, metavar="<length>",\n choices=[RestrictedRange(1, None)],\n help="Non-zero path length in bonds.")\n\n More general usage is as follows:\n\n legal_range = RestrictedRange(-180.0, 180.0)\n dihed = 120.0\n if dihed in legal_range:\n print("Dihedral is legal")\n\n ', '__init__': <function RestrictedRange.__init__>, '__contains__': <function RestrictedRange.__contains__>, '__eq__': <function RestrictedRange.__eq__>, '__repr__': <function RestrictedRange.__repr__>, '_make_repr': <function RestrictedRange._make_repr>, '__dict__': <attribute '__dict__' of 'RestrictedRange' objects>, '__weakref__': <attribute '__weakref__' of 'RestrictedRange' objects>, '__hash__': None})¶
-
__dir__
() → list¶ default dir() implementation
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
= None¶
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.application.phase.packages.phase_utils'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
schrodinger.application.phase.packages.phase_utils.
combine_log_files
(subjobs, logger)¶ Concatenates the contents of subjob log files.
Parameters: - subjobs (list(str)) – Subjob names
- logger (Logger) – Logger to which concatenated log files are to be written
-
schrodinger.application.phase.packages.phase_utils.
convert_to_sd
(maefile, sdfile)¶ Converts a Maestro file to a compressed SD file. Fails only if maefile is missing or defective.
Parameters: - maefile (str) – Maestro file to be converted
- sdfile – Output SD file, which is assuemd to be compressed
- sdfile – str
-
schrodinger.application.phase.packages.phase_utils.
get_file_names_from_list_file
(list_file)¶ Returns the names of the files in the provided list file, taking proper account of whether the current process is running under job control and whether any of the files are Phase databases.
Parameters: list_file – Name of the .list file Returns: Names of files in the .list file Return type: list(str)
-
schrodinger.application.phase.packages.phase_utils.
get_jobname
(args, filename=None)¶ Returns a job name derived in the following order of precedence:
- args.subjob if defined
- SCHRODINGER_JOBNAME if defined
- jobcontrol.get_backend().getJob().name if defined
- The basename of filename. Must be supplied if other methods fail.
Parameters: - args (argparse.Namespace) – Command line arguments
- filename (str) – Name of file to use as a last resort job name
Returns: job name
Return type: str
-
schrodinger.application.phase.packages.phase_utils.
get_internal_zip_path
(*argv)¶ Joins the components of a path within a Zip file using forward slashes, as per the Zip spec.
Parameters: argv (tuple of str) – Components in path Returns: Components in path joined with forward slashes Return type: str
-
schrodinger.application.phase.packages.phase_utils.
get_proper_path
(file_path, use_runtime=False)¶ Returns the appropriate path to use for the provided file, taking into account whether the current process is running under job control and whether file_path is a Phase database.
Parameters: - file_path (str) – File whose proper path is being sought
- use_runtime (bool) – Forces use of runtime path even if not running as job
Returns: The proper path to use for the provided file
Return type: str
-
schrodinger.application.phase.packages.phase_utils.
get_subjob_names
(num_subjobs, prefix)¶ Returns a list of subjobs names of the form <prefix>_sub_<n>, where <n> runs from 1 to num_subjobs.
Parameters: - num_subjobs (int) – Number of subjobs
- prefix (str) – Prefix for all subjob names
Returns: Subjob names
Return type: list(str)
-
schrodinger.application.phase.packages.phase_utils.
is_numeric
(value)¶ Returns True if the provided string value can be cast to a float.
Parameters: value (str) – The string to be tested Returns: Whether value is numeric Return type: bool
-
schrodinger.application.phase.packages.phase_utils.
is_phase_database_path
(source)¶ Returns whether the provided source of structures is a Phase database.
Parameters: source (str) – Path to source of structures Returns: whether the source is a Phase database Return type: bool
-
schrodinger.application.phase.packages.phase_utils.
is_phase_project_path
(file_path, zipped=False)¶ Returns True if the file_ path corresponds to a Phase project. Set zipped to True to check for a zipped project.
Parameters: - file_path – Path to file
- file_path – str
Returns: Whether file_path is a Phase project (or zipped project)
Return type: bool
-
schrodinger.application.phase.packages.phase_utils.
read_lines_in_file
(file_name)¶ Reads and returns the non-empty lines in a file.
Parameters: file_name (str) – The file to read Returns: The lines in the file, minus any leading/trailing whitespace Return type: list(str)
-
schrodinger.application.phase.packages.phase_utils.
write_list_to_file
(file_name, list_of_strings)¶ Writes a list of strings to a file with newlines after each string.
Parameters: - file_name (str) – Name of file to which the strings should be written
- list_of_strings – The list of strings to write
-
schrodinger.application.phase.packages.phase_utils.
write_string_to_file
(file_name, s)¶ Writes a string to a file with a trailing newline.
Parameters: - file_name (str) – Name of file to which the string should be written
- s (str) – The string to write