schrodinger.application.glide.sort_utils module

class schrodinger.application.glide.sort_utils.StructureType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.Enum

EPV_RECEP = 1
NON_EPV_RECEP = 2
POSE = 3
class schrodinger.application.glide.sort_utils.SortOrder(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.Enum

ASCENDING = <built-in function lt>
DESCENDING = <built-in function gt>
class schrodinger.application.glide.sort_utils.SortCriterion(prop_name: Optional[str], order: schrodinger.application.glide.sort_utils.SortOrder = <SortOrder.ASCENDING: <built-in function lt>>, default: Union[int, str, float, bool, NoneType] = None)

Bases: object

prop_name: Optional[str]
order: schrodinger.application.glide.sort_utils.SortOrder = <built-in function lt>
default: Optional[Union[int, str, float, bool]] = None
__init__(prop_name: Optional[str], order: schrodinger.application.glide.sort_utils.SortOrder = SortOrder.ASCENDING, default: Optional[Union[int, str, float, bool]] = None) None
class schrodinger.application.glide.sort_utils.CustomScoringFunction(gscore_coeff: float = 0.0, cvdw_coeff: float = 0.0, internal_coeff: float = 0.0, emodel_coeff: float = 0.0)

Bases: object

gscore_coeff: float = 0.0
cvdw_coeff: float = 0.0
internal_coeff: float = 0.0
emodel_coeff: float = 0.0
__init__(gscore_coeff: float = 0.0, cvdw_coeff: float = 0.0, internal_coeff: float = 0.0, emodel_coeff: float = 0.0) None
schrodinger.application.glide.sort_utils.get_structure_record_class(sort_criteria, default, custom_scoring_function)
class schrodinger.application.glide.sort_utils.ReceptorTable

Bases: object

Maintains a list of receptors for EPV mode.

Variables

structures (list[structure.Structure]) – A list of unique structures.

__init__()
update(ct)

Add the structure to the table. Determines the receptor link and updates the structure property accordingly. If the structure is not unique, the first receptor link value for that conformation is given.

As a side effect, this method can also be used to look up a receptor link if it is already in the table.

Parameters

ct (structure.Structure) – The structure to add.

Returns

The receptor link.

Return type

int

__len__()
schrodinger.application.glide.sort_utils.get_ct_property(ct, prop_name) Optional[Union[int, str, float, bool]]
schrodinger.application.glide.sort_utils.is_mmct_property_name(name: str) bool
schrodinger.application.glide.sort_utils.get_sd_property(ct, prop_name) Optional[Union[int, str, float, bool]]

Return the value of a property using the original property name from the SD file. For example, ‘VERIFIED_AMOUNT_MG’ would return the value of a property such as ‘i_sd_VERIFIED_AMOUNT_MG’. All possible types are tried, in the order real, int, bool, string, and the first one present is returned; otherwise return None.

class schrodinger.application.glide.sort_utils.TempFileNameIterator(file)

Bases: object

Iterator that generates temporary file names using a filename as a template. Honors PV/EPV file naming conventions. Can be used as a context manager that will delete all files at exit.

Variables

files (list[str]) – A list of file names that have been generated by the instance.

__init__(file)
schrodinger.application.glide.sort_utils.is_sd_file_list(files) bool
schrodinger.application.glide.sort_utils.validate_file_formats(files, epv)

Validates the file list is compatible with EPV mode. Implicitly checks that all files are the same format.

Parameters
  • files (list[str]) – The list of input and output files.

  • epv (bool) – Whether EPV mode is requested.

Raises

ValueError – If the file formats are invalid.

schrodinger.application.glide.sort_utils.write_output(outfile, receptors, poses, write_empty=False, renumber_ligands=False)

Write an output file with receptors at the top, followed by poses. Creates a directory and parents, if necessary. Can be used to write empty files.

Parameters
  • outfile (str) – The file location to write to.

  • receptors (Iterable[structure.Structure]) – The receptors to write to file.

  • poses (Iterable[structure.Structure]) – The poses to write to file.

  • write_empty (bool) – Ensure that a file is written even if there are no structures to write.

  • renumber_ligands (bool) – Whether the LIGNUM property for each pose should be renumbered. Ligand numbers will be monotonic increasing integers starting at 1.

Returns

Number of structures written to file.

Return type

int

schrodinger.application.glide.sort_utils.write_empty_file(outfile)

Write a valid empty file.

schrodinger.application.glide.sort_utils.get_max_batch_size()

Get the limit of open file handles for each platform.

exception schrodinger.application.glide.sort_utils.EmptyInputError

Bases: Exception

class schrodinger.application.glide.sort_utils.BestPoseFilter(nbest, ndistinct, nreport)

Bases: object

Callable class that will retain only the top poses, as specified by the criteria provided at initialization. It is a memory-efficient way to retain the best records from a list or other iterable object.

Filter will stop iteration once any of of the conditions are met.

__init__(nbest, ndistinct, nreport)
Parameters
  • nbest (int) – Retain the top N records by each ‘best_by_id’ property.

  • ndistinct (int) – Retain poses from the top N ‘best_by_id’s.

  • nreport (int) – Retain the top N total records.

class schrodinger.application.glide.sort_utils.SortValidator(reader)

Bases: object

Pass-thru filter iterator that verifies whether the records in a reader are sorted.

__init__(reader)
class schrodinger.application.glide.sort_utils.GlideSortUtility(files, output_file, *, batch_size=128, sort_criteria=None, custom_scoring_function=None, nosort=False, default=None, maxsize=3000000000, filters=None, no_recep=False, epv=False, nbest=0, nreport=0, ndistinct=0, best_by_prop=None, reset_lignum=False, allow_empty_output=False, quiet=False, logger=None, legacy_mode=False)

Bases: object

DEFAULT_SORT_CRITERIA = [SortCriterion(prop_name='r_i_docking_score', order=<SortOrder.ASCENDING: <built-in function lt>>, default=None)]
DEFAULT_FILTERS = {'r_i_docking_score': 100.0, 'r_i_glide_energy': 0.0, 'r_i_glide_gscore': 100.0, 'r_i_glide_hbond': 0.0, 'r_i_glide_metal': 10.0}
__init__(files, output_file, *, batch_size=128, sort_criteria=None, custom_scoring_function=None, nosort=False, default=None, maxsize=3000000000, filters=None, no_recep=False, epv=False, nbest=0, nreport=0, ndistinct=0, best_by_prop=None, reset_lignum=False, allow_empty_output=False, quiet=False, logger=None, legacy_mode=False)
Parameters
  • files (list[str]) – The list of files to be sorted or merged.

  • output_file (str) – The output file to write best-scoring poses.

  • batch_size (int) – Number of files to merge at a time; equal to the number of file handles open at once. If this is less than the number of pose files to merge, then merges will be done iteratively.

  • sort_criteria (Optional[list[SortCriterion]]) – A list of sort criteria used to sort poses. Cannot be used with ‘custom_scoring_function’. If unspecified, poses will be scored by Docking score ascending.

  • custom_scoring_function (Optional[CustomScoringFunction]) – Sort poses based on this callable function. Cannot be used in conjunction with ‘sort_criteria’.

  • nosort (bool) – Do no sort poses.

  • default (str) – The global default value to be used for missing properties. Individual ‘sort_criteria’ defaults supersede, if they exist. If unspecified, poses with missing sorting criteria are skipped.

  • maxsize (int) – The maximum amount of memory to use, in bytes. Zero means unlimited.

  • filters (dict[str, float]) – A dictionary of cutoff values for each property. The filter is not applied to missing properties. If unspecified, a default will be used.

  • no_recep (bool) – Don’t treat receptors specially. Receptors are identified by the presence of a ‘b_glide_receptor’ property with a value of 1. In a pose-viewer file, the first structure is a receptor found as the first structure, followed by ligands in order of score. Receptors beyond the first are ignored.

  • epv (bool) – Sort in ensemble pose-viewer mode. In this mode, all unique receptors are written at the beginning of the sorted output and there are properties linking each pose with its receptor.

  • nbest (int) – Number of poses to report for each ligand. May be combined with ‘nreport’ and ‘ndistinct’.

  • nreport (int) – Retain only the specified number of lowest-scoring poses. May be combined with ‘nbest’ and ‘ndistinct’. The total ligands reported will the lesser of all conditions.

  • ndistinct (int) – Retain poses for the specified number of lowest-scoring distinct ligands. No more ligands will be reported once this condition is satisfied. The ‘best_by_prop’ logic is used to determine distinctness. May be combined with ‘nreport’ and ‘nbest’.

  • best_by_prop (str) – Keep only the best pose(s) for each ligand with a given value to a user-specified property. By default, ‘nbest’ and ‘ndistinct’ report best by (file, ligand number). However, specifying ‘best_by_prop’ will override this and use the specified property instead. This param is only meaningful when also specifying ‘nbest’ and/or ‘ndistinct’.

  • reset_lignum (bool) – Reset the ligand numbers.

  • allow_empty_output (bool) – Write an empty output file when there are no poses.

  • quiet (bool) – Don’t write a summary output to STDOUT.

  • logger (Logger) – The logger.

  • legacy_mode (bool) – Legacy mode will defer to replicate behavior of the original perl script, even when improvements may have otherwise been introduced.

classmethod fromArgs(args, logger=None, legacy_mode=False)

Create a GlideSortUtility instance directly from the argument namespace generated by the command-line interface.

Parameters
  • args (argparse.Namespace) – Arguments passed from the command-line driver script.

  • logger (logging.Logger) – A logger.

  • legacy_mode (bool) – Legacy mode will defer to behavior of the original perl script, even when improvements may have otherwise been introduced.

Returns

An instance of GlideSortUtility constructed with the parameters provided.

Return type

GlideSortUtility

sort()
merge(file_map=None, delete_infiles=False, no_filter=False, n_reject_missing=0, n_reject_filter=0)

Merge multiple files together on sort criteria.

Parameters
  • file_map (Optional[FileMap]) – If supplied, it should contain a list of tuples. Each tuple contains the name of a file to be merged and an integer to map the file back to the _original_ file associated with it. This is done so that a large file can be broken into smaller files, but the provenance of the file can be tracked.

  • delete_infiles (bool) – Delete an infile once it has been merged?

  • no_filter (bool) – Perform any filtering on the input poses?

  • n_reject_missing (int) – The number of poses rejected for missing values. Used for reporting purposes.

  • n_reject_filter (int) – The number of poses rejected for filter cutoffs. Used for reporting purposes.