schrodinger.application.glide.runner module¶
This module contains functions for running Gridgen and Docking workflows. The calculation will run within the current process using Glide library calls, not as a separate job.
To run Gridgen jobs, use the run_gridgen_workflow_from_config
function.
There are two ways to run docking jobs. The ‘simple’ call is
run_docking_workflow_from_config
, which is a wrapper around
run_docking_workflow
with parameters selected from a glide.Config object.
For more advanced control over the workflow, you can call run_docking_workflow
directly. This offers fine-tuned control, such as modifying the source of
input structures and destination(s) of output poses and skipped ligands. One
may also customize ligand creation, scoring, and post-processing steps.
Example API usage:
from schrodinger import glide
from schrodinger.application.glide import runner
from schrodinger.application.glide.glide import get_glide_job
job = get_glide_job('dock.in')
config = glide.Config(job)
runner.run_docking_workflow_from_config(config)
- class schrodinger.application.glide.runner.GlideDockingResult(annotated_input_st: Structure, poses: List[Structure], skip_reason: str = None, message: str = None)¶
Bases:
object
Class to store result of a docking calculation.
- Variables:
annotated_input_st – A possibly modified copy of the input structure. Annotations may include properties such as CPU time or reason for skipping a ligand.
poses – List of scored structures. Will be empty if ligand was skipped.
skip_reason – Reason for skipping the current ligand, if any.
message – Error message to be logged, if any.
- skip_reason: str = None¶
- message: str = None¶
- class schrodinger.application.glide.runner.GlideDockingFunnelTimings(confgen: float = 0.0, docking: float = 0.0, refinement: float = 0.0, minimization: float = 0.0, sampling: float = 0.0, post_minimization: float = 0.0, scoring: float = 0.0)¶
Bases:
object
Class to store timings of the docking funnel.
- confgen: float = 0.0¶
- docking: float = 0.0¶
- refinement: float = 0.0¶
- minimization: float = 0.0¶
- sampling: float = 0.0¶
- post_minimization: float = 0.0¶
- scoring: float = 0.0¶
- report()¶
Returns a string representation of the timings in order: confgen, docking, minimization, sampling, post_minimization, scoring. :rtype: str
- __init__(confgen: float = 0.0, docking: float = 0.0, refinement: float = 0.0, minimization: float = 0.0, sampling: float = 0.0, post_minimization: float = 0.0, scoring: float = 0.0) None ¶
- class schrodinger.application.glide.runner.DockingWorkflowOptions(ligand_fatal: int = 0)¶
Bases:
object
Options for configuring run_docking_workflow.
Instance Attributes:
- Variables:
ligand_fatal – Number of ligands to process before intentionally triggering a fatal crash. Default of 0 represents no fatal crash, 1 means crash before processing the first ligand, etc.
- ligand_fatal: int = 0¶
- __init__(ligand_fatal: int = 0) None ¶
- schrodinger.application.glide.runner.format_pose(st: Structure, pose_idx: int = 0) str ¶
Returns ligand score report string to be printed in the log file.
- Parameters:
pose_idx – 0-based pose counter for the current ligand. When there are multiple poses per ligand, the first one gets formatted differently.
Writes footer to the log file. Footer contains information about the current date and timings details of the job.
- Parameters:
timings (profiling.SystemResourceTimes) – An object containing user, system, and real times.
logger (logging.Logger) – A logger.
- schrodinger.application.glide.runner.get_energy_options(config, *, hard=False)¶
Convenience wrapper for creating an EnergyOptions instance.
- Parameters:
config (glide.Config) – job keywords
hard (bool) – whether to use the “hard” version of the Coulomb / van der Waals potentials.
- Return type:
glide.EnergyOptions
- schrodinger.application.glide.runner.post_minimize(poses, grid, config, lig_cons_data=None)¶
Perform a post-docking minimization (optimize the Cartesian coordinates of each atom freely, using the hard potential).
- schrodinger.application.glide.runner.get_scored_input_st(lig, grid, config, min_energy, datafiles, lig_cons_data)¶
Score the input structure, optionally after minimizing it. The structure is tagged with the b_i_glide_inputpose property.
- Parameters:
lig (glide.Ligand) – The original input ligand
config (glide.Config) – config
min_energy (float) – energy of the lowest-energy ensemble member
datafiles (glide.DataFiles) – datafiles
- Returns:
scored structure of input pose
- Return type:
pose.Structure
- schrodinger.application.glide.runner.select_poses_for_pdm(refined_pose_ensemble: RefinedPoseEnsemble, config: Config, lig_cons_data: LigandConstraintData) [<class 'glide.Pose'>] ¶
Take the best RefinedPoses from the ensemble, excluding near-duplicates and poses not satisfying applicable constraints.
- Returns:
a list of Pose objects, with the size of the list capped by the job configuration.
- class schrodinger.application.glide.runner.GlideRunnerState(config, *, set_progress=False)¶
Bases:
object
Class that stores the current state of Glide Runner. Allows reading/writing the state from/to a json file.
If an instance of this class is used as a context manager, a signal handler will be installed to ensure that if the job crashes with a SIGSEGV or similar signal, the state file will be written. (Not supported on Windows.)
- SCHEMA = <voluptuous.Schema object>¶
- __init__(config, *, set_progress=False)¶
Initialize state variables using job config object. :param config: Glide configuration :type config: glide.Config
- Parameters:
set_progress (bool) – if true, report job progress to job control.
- update(lignum, timings, skip_reason=None, done=False)¶
Update the current state of GlideRunner.
- Parameters:
lignum (int) – Current ligand number.
timings (profiling.SystemResourceTimes) – The runtimes provided by the timer.
skip_reason (str) – Reason for skipping the current ligand.
done (bool) – Whether the job is completed.
- toDict()¶
- Returns:
Current state of GlideRunner in dictionary format
- Return type:
GlideStateDict
- write()¶
Write the state file, <jobname>_state.json for GlideRunner.
- class schrodinger.application.glide.runner.StructureToLigandConverter(config, grid, datafiles)¶
Bases:
object
Callable class that screens a given structure using filters. Filters ligands based on if the user has requested to skip ligands that require require metal binding and if the ligand requires it. “Good” structures are converted Ligand objects and returned.
- __init__(config, grid, datafiles)¶
- Parameters:
config (glide.Config) – Glide configuration
grid (glide.GridArchive) – Glide grid archive
- class schrodinger.application.glide.runner.AbstractDockingMethod(config, grid, datafiles, logger, message_on_invocation=None)¶
Bases:
ABC
Abstract class that outlines the API of processing a glide.Ligand into a list of scored Structure objects.
- __init__(config, grid, datafiles, logger, message_on_invocation=None)¶
- Parameters:
config (glide.Config) – Glide configuration
grid (glide.GridArchive) – glide grid object to score a ligand in
datafiles (glide.DataFiles) – data file cache (used for getting the contents of files such as grid.pts)
logger (logging.Logger) – Logger object
message_on_invocation (str) – Message to log when the method is invoked, should be added in the __call__ method.
- class schrodinger.application.glide.runner.InplaceDockingMethod(config, grid, datafiles, logger, message_on_invocation=None)¶
Bases:
AbstractDockingMethod
Performs scoring-in-place of a ligand and returns the scored structure. Used by jobs with
DOCKING_METHOD inplace
.
- class schrodinger.application.glide.runner.MininplaceDockingMethod(config, grid, datafiles, logger, message_on_invocation=None)¶
Bases:
AbstractDockingMethod
Performs minimization-in-place of a ligand and returns the scored structure. Used by jobs with
DOCKING_METHOD mininplace
.
- class schrodinger.application.glide.runner.FullFunnelDockingMethod(*args)¶
Bases:
AbstractDockingMethod
Parent class for docking methods that implement the full docking funnel, including confgen, docking, partial minimization, post-docking minimization, and scoring.
- __init__(*args)¶
- Parameters:
config (glide.Config) – Glide configuration
grid (glide.GridArchive) – glide grid object to score a ligand in
datafiles (glide.DataFiles) – data file cache (used for getting the contents of files such as grid.pts)
logger (logging.Logger) – Logger object
message_on_invocation (str) – Message to log when the method is invoked, should be added in the __call__ method.
- class schrodinger.application.glide.runner.PoseInfoLogger(config, grid, logger)¶
Bases:
object
Callable class that performs logging of a scored Structure.
- __init__(config, grid, logger)¶
- Parameters:
config (glide.Config) – Glide configuration
logger (logging.Logger) – Logger object
grid (glide.GridArchive) – A glide grid archive.
- schrodinger.application.glide.runner.run_docking_workflow(st_source, st_sinks, docking_funnel, *, skipped_st_sinks=None, lignum_start=1, lignum_end=None, options=None, timer=None, state=None, logger=<Logger glide.runner (INFO)>)¶
Docks ligands and writes output poses to the output file.
Performs processing of ligands, writes resulting poses to an output raw file. Does not perform sorting or postprocessing of the raw file.
- Parameters:
st_source (Iterable[Structure]) – The source of structures. Likely a
StructureReader
instance.st_sinks (list[Callable[[list[Structure]], None]] | None) – List of callables where final structures can be written. Must accept a list of structure objects per call. Likely an
extend
method of aStructureWriter
instance. NOTE: sinks are not called for ligands that produced no poses.docking_funnel – A callable that performs docking of a single structure and returns a list of scored structures. Likely produced by
get_docking_funnel
.lignum_start (int) – Lignum to start docking structures.
lignum_end (int or None) – Lignum to stop docking structures.
options (DockingWorkflowOptions or None) – Options for configuring the docking workflow.
skipped_st_sinks (list[Callable[[Structure], None]] | None) – List of callables where skipped structures can be written. Must accept a single structure per call, such as an
append
method of aStructureWriter
instance. Default is not to write skipped ligands.state (GlideRunnerState) – State object used for storing information about the progress of the job, such as number of ligands processed and timings.
timer (profiling.SystemResourceTimer) – Timer used for log messages and for writing job timings to the state file.
logger (logging.logger) – A logger object.
offset (int) – Offset the ligand numbers by this amount. Used for subjobs.
- schrodinger.application.glide.runner.raise_if_skipped(st: Structure)¶
Raise a SkipLigand exception if the Structure has been tagged with the s_glide_skip_exception property. Also clear the property; this is so that future attempts at docking won’t always be skipped. For example, let’s say the structure was written to a
<jobname>_skipped.maegz
, and then retried in another docking job with different settings.- Raises:
- schrodinger.application.glide.runner.get_docking_funnel(docking_methods, *, ligand_converter=None, pose_info_logger=None, report_cpu_time=False)¶
Returns a callable that performs docking of a single structure and returns a GlideDockingResult containing the list of structures with poses and other information.
- Parameters:
docking_method (List[Callable[[glide.Ligand], list[Structure]]]) – List of Callable functions to convert ligand to scored structures. Each callable must take a glide.Ligand and return a list of poses to be written, or raise a glide.SkipLigand exception. The callables will be used one by one until one of them returns a list of poses. glide.SkipLigand exception will be raised if all callables raise it.
ligand_converter (Callable[[Structure], glide.Ligand]) – Callable to convert a
Structure
to aLigand
. Default is to do a simple conversion without further validation of the ligand.pose_info_logger (Callable[[Structure]]) – Callable to log scored structure info. Takes a list of output structures for the current ligand.
report_cpu_time (bool) – Whether to include the elapsed processing time in the output reports. If True, the structures will contain a property named “r_glide_cpu_time”.
- Returns:
A callable that performs docking of a single structure and returns a GlideDockingResult containing the list of structures with poses.
- schrodinger.application.glide.runner.enter_timing_context(stack, logger)¶
- schrodinger.application.glide.runner.enter_info_context(stack)¶
- schrodinger.application.glide.runner.enter_reader_context(stack, config, logger=<Logger glide.runner (INFO)>)¶
Returns an open a StructureReader context based on the ‘LIGANDFILE’ keyword. Receptor structures are ignored.
Sets the starting index of the StructureReader based on LIGAND_START and ignored receptor structures.
- schrodinger.application.glide.runner.get_pose_writer(filename, stack, config, grid)¶
- schrodinger.application.glide.runner.get_skipped_st_writer(stack, config)¶
- schrodinger.application.glide.runner.get_csv_writers(stack, config)¶
Create writer objects for the raw CSV pose file and the raw CSV skipped ligand file.
- Returns:
two callables, one to be used for the poses, taking a list of structures, and the other to be used for the skipped ligands, taking a single structure.
- schrodinger.application.glide.runner.get_runner_io(stack, config, grid, logger)¶
Creates readers and writers, enters their context, and then returns the callables in the format expected by
run_docking_workflow
.- Parameters:
stack (contextlib.ExitStack) – An exit stack.
config (glide.Config) – The job config.
grid (glide.GridArchive) – The grid.
logger (logging.Logger) – A logger.
- Returns:
The reader, list of pose writers, and list of skipped st writers.
- Return type:
tuple[Iterable, list[Callable], list[Callable]]
- schrodinger.application.glide.runner.postprocess_docking_job(config, state, logger=<Logger glide.runner (INFO)>)¶
Final cleanup and post-processing; depending on config settings, some of the following may happen:
sort raw file
remove raw file
compress CSV files
remove state file
- Parameters:
config (glide.Config) – A glide config.
GlideRunnerState – the state of the job
logger (logging.Logger) – A logger.
- schrodinger.application.glide.runner.get_lignum_ranges(config, logger)¶
Gets the starting and ending ligand numbers with an offset applied, if any.
- Parameters:
config (glide.Config) – A glide config.
logger (logging.Logger) – A logger.
- Returns:
The starting ligand number and ending ligand number.
- Return type:
a tuple of (int, int or None)
- schrodinger.application.glide.runner.dock_from_structures(st_source, config, *, grid=None, docking_method=None, ligand_converter=None, pose_info_logger=None, logger=<Logger glide.runner (INFO)>, setup_context=True)¶
Generator that performs docking of an iterable of structures with settings derived from the Config object, although some aspects of the config may be overridden by the optional keyword arguments. For example, GRIDDFILE is ignored if the grid argument is not None.
Yields a list of scored structures per ligand; lists might be empty.
- Parameters:
st_source (Iterable[Structure]) – The source of structures. Likely a list of structures.
config (glide.Config) – A glide config.
grid (glide.GridArchive) – The grid. By default, the grid is read from the file defined in config.
docking_method (Callable[[glide.Ligand], list[Structure]]) – Callable to convert ligand to scored structures. By default, the docking method is read from the config.
ligand_converter (Callable[[Structure], glide.Ligand]) – Callable to convert a
Structure
to aLigand
. By default, a simple conversion is used.pose_info_logger (Callable[[Structure]]) – Callable to log scored structure info. Takes a list of output structures for the current ligand.
logger (logging.Logger) – A logger.
setup_context – if true, set up the various context managers for the job, including license checkout and force field library initialization
- Returns:
scored poses; a list is yielded for each ligand, even for ligands that fail to dock (those yield an empty list)
- Return type:
Generator[list[Structure]]
- schrodinger.application.glide.runner.run_docking_workflow_from_config(config, *, set_progress=False, logger=<Logger glide.runner (INFO)>)¶
Runs a docking job with settings derived from the Config object.
- Parameters:
config (glide.Config) – A glide config.
set_progress (bool) – if true, report job progress to job control.
logger (logging.Logger) – A logger.
- Returns:
The final state of the job.
- Return type:
- schrodinger.application.glide.runner.run_gridgen_workflow_from_config(config, logger=<Logger glide.runner (INFO)>)¶
Run a gridgen job with settings derived from config object. This includes checking out the license, setting up the Receptor, doing the calculations, and writing the output file(s).
- Parameters:
config (glide.Config) – a Glide config.
logger (logging.Logger) – A logger.
- Returns:
(grid file(s) written, timings)
- Return type:
tuple[tuple[str, …], profiling.SystemResourceTimes]
- class schrodinger.application.glide.runner.CombinedRunner(combined_config: dict)¶
Bases:
object
Run gridgen followed by docking, with settings derived from a combined keywords dictionary.
- __init__(combined_config: dict)¶
- Parameters:
combined_config – a keyword dictionary that must have the keys GRIDGEN and DOCKING, the values of which are the dictionaries of keywords for that stage.
- getDockingOutputFiles() list[str] ¶
Return the names of the expected output files from the docking stage.
- run(*, gridfile: ~typing.Optional[str] = None, set_progress: bool = False, logger: ~logging.Logger = <Logger glide.runner (INFO)>)¶
- Parameters:
gridfile – if specified, write the grid file to this filename.
set_progress – if true, report job progress to job control.
- Returns:
The final state of the docking job (CPU and elapsed times also include the gridgen time), and the grid files that were written, if any.
- Return type:
tuple(GlideRunnerState, tuple(str, …))