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)
Another simplified API is dock_from_structures
, which deals with iterables of
schrodinger.structure.Structure objects:
from schrodinger import structure
with structure.StructureReader('ligands.maegz') as reader, structure.StructureWriter('poses.maegz') as writer:
for poses in runner.dock_from_structures(reader, config):
writer.extend(poses)
Finally, if you just want to dock a single Structure, another option is to create a “docking funnel”, which is a function that takes a Structure and returns a GlideDockingResult, but note that in this case the caller is responsible for additional setup:
grid = glide.GridArchive.readArchive('grid.zip')
datafiles = glide.DataFiles()
docking_method = runner.FullFunnelDockingMethod(config, grid, datafiles)
dock = runner.get_docking_funnel([docking_method])
with glide.DockingLicense():
st = structure.Structure.read('ligand.maegz')
result = dock(st)
structure.StructureWriter.write(result.poses, 'poses.maegz')
- 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.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 ¶
- 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 (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 (Config) – Glide configuration
grid (GridArchive) – Glide grid archive
- class schrodinger.application.glide.runner.AbstractDockingMethod(config, grid, datafiles, logger=<Logger glide.runner (INFO)>, 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=<Logger glide.runner (INFO)>, message_on_invocation=None)¶
- Parameters:
config (Config) – Glide configuration
grid (GridArchive) – glide grid object to score a ligand in
datafiles (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=<Logger glide.runner (INFO)>, 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=<Logger glide.runner (INFO)>, 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 (Config) – Glide configuration
grid (GridArchive) – glide grid object to score a ligand in
datafiles (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 (Config) – Glide configuration
logger (logging.Logger) – Logger object
grid (GridArchive) – A glide grid archive.
- 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, …))
- 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 (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.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[[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], 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.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 (Config) – A glide config.
grid (GridArchive) – The grid. By default, the grid is read from the file defined in config.
docking_method (Callable[[Ligand], list[Structure]]) – Callable to convert ligand to scored structures. By default, the docking method is read from the config.
ligand_converter (Callable[[Structure], 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 (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 (Config) – a Glide config.
logger (logging.Logger) – A logger.
- Returns:
(grid file(s) written, timings)
- Return type:
tuple[tuple[str, …], SystemResourceTimes]
- schrodinger.application.glide.runner.enter_timing_context(stack, 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 (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)