schrodinger.application.glide.utils module

Glide utility functions.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.glide.utils.OutfileNameAttributes(suffix, ext)

Bases: tuple

suffix: str

Alias for field number 0

ext: str

Alias for field number 1

__contains__(key, /)

Return key in self.


Return len(self).

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

exception schrodinger.application.glide.utils.GlideError

Bases: RuntimeError

Exception class for fatal errors raised by Glide.

__init__(*args, **kwargs)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class schrodinger.application.glide.utils.DictAction(option_strings, dest, default=None, *a, **k)

Bases: argparse.Action

Argparse action class that uses values of the form key=val (see parseKeyval for more details) to fill a dictionary. (Similar to the “append” action, but for dicts.)

__init__(option_strings, dest, default=None, *a, **k)

Return a (key, val) tuple given a string. The string must start with the key, which is made of word characters (alphanumeric or underscore). Any non-word character optionally followed by whitespace acts as a separator, and everything else is the value. If the value is delimited by brackets or braces, it is parsed as JSON. If there is no delimiter, the value is interpreted as “yes”.

class schrodinger.application.glide.utils.EnvAction(option_strings, dest, **k)

Bases: argparse.Action

Argparse action class that, in addition to “store_true”, sets SCHRODINGER_GLIDE_<dest>=1 in the environment.

__init__(option_strings, dest, **k)
schrodinger.application.glide.utils.m2io_type_convert(prop_name, value)

Convert a string into the correct Python type corresponding to a m2io property name.

  • prop_name (str) – The m2io property name.

  • value (str) – The value associated with that property


The value converted to the appropriate Python type.

schrodinger.application.glide.utils.convert_flags_to_underscore(argv=None, logger=None)

Convert all command-line flags to underscore-delimited words instead of dash-delimited words. Some legacy scripts allowed that either be used.

schrodinger.application.glide.utils.parse_size(size) int

Parse user input to convert human-readable file size into bytes. Accepted suffixes are {K, M, G, T} corresponding to SI file sizes (powers of 10). :param str size: A representation a file size. :return: The file size in bytes.

schrodinger.application.glide.utils.get_output_file_name(config: schrodinger.glide.Config, suffix_override: Optional[str] = None) str

Determines output file name depending on the job configuration. Filename suffix can be overridden.

schrodinger.application.glide.utils.get_raw_file_name(config: schrodinger.glide.Config) str

Returns the name of the raw file.

schrodinger.application.glide.utils.get_skipped_file_name(config: schrodinger.glide.Config) str

Returns the name of the skipped file.

schrodinger.application.glide.utils.get_job_output_filenames(config: schrodinger.glide.Config) List[str]

Returns list of filenames of the expected Glide docking job output files. Should be used in tandem with the new Glide API. this function only applies to serial docking jobs. Distributed jobs don’t write a state file, but a sqlite file instead. Work in progress: will add other output files when corresponding options are implemented in schrodinger.glide.runner module.

schrodinger.application.glide.utils.get_sort_filters_from_config(config) Dict[str, float]

Return a filters dictionary suitable for use with GlideSortUtility based on the given Glide input configuration.


config (glide.Config) – Glide configuration

schrodinger.application.glide.utils.sort_output_file(config, output_filename, raw_filename, logger)

Sorts and filters final poses stored in the raw file and saves the resulting file.

  • config (glide.Config) – Glide configuration

  • output_filename (str) – name of the output file

  • raw_filename (str) – name of the raw file to be sorted

  • logger (logging.Logger) – logger

schrodinger.application.glide.utils.format_human_time(seconds: float) str

Returns a string representation of the time duration in seconds. Calculates the number of days, hours, minutes, and seconds.

Example outputs:

"1 day, 10 hours, 17 minutes, and 36 seconds"
"1 hour, 1 minute, and 1 second"
"1 minute and 1 second"
schrodinger.application.glide.utils.is_valid_pv_file(file_name, require_poses=False)

Returns bool indicating if the file appears to be a valid PV file.

This function with throw an exception is the file is not a valid Maestro structure file.

The checks for this are simple, and may not be conclusive. The test is content, and not file-extension based, since there are valid PV or EPV files that lack any indication that they are PV files in the file extension. If you need to check the extension as well see fileutils.is_poseviewer_file.

A PV file has exactly one structure with a true value for b_glide_receptor.

An EPV file has one or more structures with a true value for b_glide_receptor at the beginning of the file. Single-receptor EPV files are therefore considered PV files, but not EPV files with two or more receptors.

  • file_name (str) – path to the structure file

  • require_poses (bool) – pv file must contain more than one structure


bool indicating if the file appears to be a valid PV file

Return type



Returns bool indicating if the file appears to be a valid EPV file.


file_name (str) – path to the structure file


bool indicating if the file appears to be a valid EPV file

Return type



Return a Structure object given a grid file (may be .grd or .zip)

schrodinger.application.glide.utils.is_grid_good_for_ligand(gridfile, lig_st) bool

Check whether the ligand structure fits in the outer box of the grid.


Check whether all required gridfiles exist for the given uncompressed gridfile


gridfile (str) – Path to the grid file (.grd)

schrodinger.application.glide.utils.extract_file_from_grid(grid_file, ext)

Extract the file with requested extension form the given grid file archive. Will return None if the requested file is not present in the archive. If the specified grid file is uncompressed, will simply return the file with the same extension in the same location as the grid.

  • grid_file (str) – Path to the grid file (.zip or .grd)

  • ext (str) – Extension of the requested file.

Return type

str or None


File path or None


Returns a list of excluded volumes in the specified excluded volumes file.


xvol_file (str) – Path to the excluded volumes file

Return type

List of tuples


Each tuple defines an excluded volume. First item is the name (str), second item is a tuple of XYZ coordinates, third item is a radius (float).

class schrodinger.application.glide.utils.PoseWriter(filename, *, is_pv, overwrite, grid, **kwargs)

Bases: schrodinger.structure._io.StructureWriter

StructureWriter that will prepend the receptor to the top of the file when entering its context, if is_pv argument is True. The append argument is used to determine whether StructureWriter should overwrite the file or append.

__init__(filename, *, is_pv, overwrite, grid, **kwargs)

kwargs – Passed down to parent class.


Append the provided structure to the open file.


Close the file.


Append all provided structures to the open file.

setOption(option, value)

Set a single option for this writer. This method is meant for options that may not be supported for all writer formats. See the StructureWriter class documentation for details on the available options.

Raises an OptionError subclass (either UnsupportedOption or UnsupportedOptionValue) if unsuccessful.

  • option (str) – The name of the option to set.

  • value – The value for the option. The data type of this parameter depends on the option being set.

static write(st, filename)

Writes the given Structure to the specified file, overwriting the file if it already exists.

  • st (structure.Structure) – structure object to write to file

  • filename (str or pathlib.Path) – filename to write to

class schrodinger.application.glide.utils.LigandNumberIterator(sts, offset=0)

Bases: object

A pass-through iterator that will assign a ligand number (“i_i_glide_lignum”) to structures. Integers start at 1 (plus specified offset) and increase with each new structure.

__init__(sts, offset=0)
  • sts (Iterable[structure.Structure]) – An iterable of ligands.

  • offset (int) – Offset the ligand numbers by this amount.


Return a string of git hashes for the relevant products using existing .git_hash files in the corresponding directories.

schrodinger.application.glide.utils.add_output_file(*output_files, incorporate=False)

Add files to jobcontrol output files.

  • output_files (str) – files to be transferred.

  • incorporate (bool) – marked files for incorporation by maestro.

schrodinger.application.glide.utils.add_input_file(jsb, *input_files)

Check the existence of input file(s). Add it as jobcontrol input file if it exists, otherwise exit with error.

schrodinger.application.glide.utils.concatenate_logs(combined_logfile, subjob_logfile_list, logger=None)

Combine subjob logfiles into single combined logfile.

  • combined_logfile (str) – combined log file name

  • subjob_logfile_list (list(str)) – list of subjob logfile names to be combined.

  • logger (Logger or None) – logger for receiving the info and error message.


Convert a keywords dict into a list of -set key=value arguments suitable for the command line.


Returns a dict combining multiple inputconfig-compatible sources (e.g, filenames or dicts). Values from latter sources take precedence. Note: the merging is shallow!


Get the job name from the environment, if set. If not, get it from the basename of the provided input filename.


Return a set with the known developer keywords.


Return True if st is a receptor Structure.

schrodinger.application.glide.utils.unzip_grids(grid_archive, jobname)

Extract the contents of the grid archive to a temporary directory if the subjobs will be running locally.


2-tuple with the path to the temporary directory and the .grd file.

Return type

tuple of str


Write a README file to a directory explaining the temporary nature of said directory.


Find the *.grd file in a directory. There must be one and only one!


Return the host and number of CPU that should be used to submit subjobs. This function works both running under job control and not.

Return type

str, int

schrodinger.application.glide.utils.timer(obj, propname)

A context manager that computes the elapsed time and sets it as a property of the given object. If the property already has a value, the time is added to it.

@param obj: object to modify @type obj: object

@param propname: name of property to set @type propname: str


A context manager that temporarily disables MMSTEREO_IGNORE_STEREO_PROP and MMSTEREO_USE_GEOM_STEREO.


Return a set with the path to an optional data file, which may be found in the CWD or in the glide user data directory. The set may be empty.


Return the header row if the ligands come from CSV file(s). Raises a GlideError if different files have different headers.


first line on the file, including EOL

Return type


schrodinger.application.glide.utils.get_csv_props(glide_job, ligfile_fields=None)

Return the list of the names of properties that should be stored in the properties table, based on the value of CSV_PROPS_FILE, if present, or else the default CSV config file. Will also inspect the ligand file column names and append them.

  • glide_job (glide_input.GlideJob) – Glide job object (dict of SIF keyword-value pairs)

  • ligfile_fields (Optional[list[str]]) – The fields found in the input CSV file(s).


A list of CSV properties.

Return type


schrodinger.application.glide.utils.parse_csv_props_file(filename, precision)

Parse the CSV props config file. This is the file specified by the CSV_PROPS_FILE keyword.


precision (str) – SP, XP, or WScore


A list of CSV properties

Return type


schrodinger.application.glide.utils.get_prop(st, prop)

Retrieve the property from a structure, even if the name is mangled by an upstream process. Is able to access properties based on their original name in a CSV header, even if the structure has been processed by the mmshare CSV reader or Ligprep.


The property, if found. Otherwise an empty string.

schrodinger.application.glide.utils.get_props(st, props)

Return a list with the values of all the Structure properties listed in props. If a property is not preset, this will try several variants of the property name by adding prefixes that are used by the mmshare CSV reader and Ligprep.

schrodinger.application.glide.utils.format_row(row, precision=4)

Format the numeric values in a CSV row to a fixed precision.


Generate ligprep argparse instance and return it.


ligprep argument parser

Return type



Get the paths of files in ligprep arguments.


args (str) – ligprep argument string


set of ligprep option input file paths.

Return type


schrodinger.application.glide.utils.read_json(source: str) dict

Parse a JSON object, either from a string or from a filename.