schrodinger.application.phase.shape_screen_reporter.task_utils module

Performs task-based work for generating and using shape screen report databases.

Copyright Schrodinger LLC, All Rights Reserved.

schrodinger.application.phase.shape_screen_reporter.task_utils.check_user_query(reporter, user_features, user_tol=None, user_rules=None)

Returns a non-empty error message if any of the supplied query data are illegal.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • user_features – Feature names with 1-based numbering, e.g., [‘A1’, ‘D5’, ‘H9’, ‘R12’]

  • user_tol (dict{str, float} or NoneType) – Dictionary of <feature>:<tol> pairs, where <feature> consists of a feature name and <tol> is the matching tolerance, e.g., {‘A1’: 1.5, ‘R12’, 2.5}.

  • user_rules (dict{str, str} or NoneType) – Dictionary of <feature>:<permitted> pairs, where <feature> consists of a feature name and <permitted> contains the first character of <feature>, followed by any other types <feature> is allowed to match, e.g., {‘A1’:’AN’, ‘R12’:’RH’}

Returns

Non-empty error message if any data are invalid

Return type

str

schrodinger.application.phase.shape_screen_reporter.task_utils.cluster_hits(args, logger=None)

Clusters hits in a shape screen report database according to the query features they match or the largest Bemis-Murcko scaffold they contain.

Parameters
  • args (argparse.Namespace) – argparse.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

Returns

Dictionary of cluster descripion –> cluster size, where the description is a string of matched features or the scaffold SMILES/SMARTS.

Return type

dict{string: int}

schrodinger.application.phase.shape_screen_reporter.task_utils.cluster_hits_by_features(args, logger=None)

Clusters hits in a shape screen report database according to the query features they match. Any created hypotheses are copied into the archive <jobname>_hypos.zip to simplify file transfer.

Parameters
  • args (argparse.Namespace) – argparse.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

Returns

Dictionary of matched features –> cluster size

Return type

dict{string: int}

schrodinger.application.phase.shape_screen_reporter.task_utils.cluster_hits_by_scaffold(args, logger=None)

Clusters hits in a shape screen report database according to the largest Bemis-Murcko scaffold they contain.

Parameters
  • args (argparse.Namespace) – argparse.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

Returns

Dictionary of scaffold SMILES/SMARTS –> cluster size

Return type

dict{string: int}

schrodinger.application.phase.shape_screen_reporter.task_utils.create_cluster_hypo(reporter, subset=None, user_tol=None, user_rules=None)

Constructs a pharmacophore hypothesis from the shape query for use in the “cluster” task. All shape query sites are used to perform the initial clustering, whereas a subset of sites are used the create the hypothesis for a particular cluster. Positional tolerances and feature-matching rules in the hypothesis are modified according to dictionaries that contain any user-specified <feature>:<tol> and <feature>:<permitted> pairs, where <feature> consists of only a feature type, with no number.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • subset (list(int) or NoneType) – Zero-based list of query site numbers. All sites are used by default.

  • user_tol (dict{str, float} or NoneType) – Dictionary of <feature>:<tol> pairs, where <feature> consists of only a feature type and <tol> is the matching tolerance, e.g., {‘A’: 1.5, ‘R’, 2.5}.

  • user_rules (dict{str, str} or NoneType) – Dictionary of <feature>:<permitted> pairs, where <feature> consists of only a feature type and <permitted> contains <feature>, followed by any other types <feature> is allowed to match, e.g., {‘A’:’AN’, ‘H’:’HR’, ‘R’:’RH’}

Returns

The requested pharmacophore hypothesis

Return type

phase.PhpHypoAdaptor

schrodinger.application.phase.shape_screen_reporter.task_utils.create_database(args, logger=None)

Creates a new shape screen report database.

Parameters
  • args (argparser.Namespace) – argparser.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

schrodinger.application.phase.shape_screen_reporter.task_utils.create_user_hypo(reporter, user_features, user_tol=None, user_rules=None)

Constructs a pharmacophore hypothesis from the shape query based on a list of feature names supplied by the user. Positional tolerances and feature-matching rules in the hypothesis are modified according to dictionaries that contain any user-specified <feature>:<tol> and <feature>:<permitted> pairs, where <feature> consists of a feature type followed by a 1-based feature number.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • user_features (list(str)) – Feature names with 1-based numbering, e.g., [‘A1’, ‘D5’, ‘H9’, ‘R12’]

  • user_tol (dict{str, float} or NoneType) – Dictionary of <feature>:<tol> pairs, where <feature> consists of a feature name and <tol> is the matching tolerance, e.g., {‘A1’: 1.5, ‘R12’, 2.5}.

  • user_rules (dict{str, str} or NoneType) – Dictionary of <feature>:<permitted> pairs, where <feature> consists of a feature name and <permitted> contains the first character of <feature>, followed by any other types <feature> is allowed to match, e.g., {‘A1’:’AN’, ‘R12’:’RH’}

Returns

The requested pharmacophore hypothesis

Return type

phase.PhpHypoAdaptor

Raise

ValueError if any of the supplied feature names is illegal or not found in the shape query, or if any of the tolerances or permitted feature strings is illegal.

schrodinger.application.phase.shape_screen_reporter.task_utils.export_hits_or_hypo(args, logger=None)

Exports hits and/or hypothesis for a subset of query features.

Parameters
  • args (argparser.Namespace) – argparser.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

Raise

ValueError if any of the feature names, feature tolerances or feature rules are illegal.

schrodinger.application.phase.shape_screen_reporter.task_utils.filter_hits(args, logger=None)

Filters hits according to property and/or SMARTS filters.

Parameters
  • args (argparser.Namespace) – argparser.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

schrodinger.application.phase.shape_screen_reporter.task_utils.get_feature_overlap_mappings(base_features_hit, base_features_query, result)

Constructs a list of FeatureOverlapMapping objects from the base features of the hit, the base features of the query and the PhpShapeScreenResult from screening the hit against the query.

Parameters
  • base_features_hit (list(phase.PhpBaseFeature)) – All base features in the hit

  • base_features_query (list(phase.PhpBaseFeature)) – All base features in the query

  • result (phase.PhpShapeScreenResult) – The result from screening the hit against the query

Returns

List of FeatureOverlapMapping objects

Return type

list(canvas2d.FeatureOverlapMapping)

schrodinger.application.phase.shape_screen_reporter.task_utils.get_jobname(dbfile, task)

Determines the job name from SCHRODINGER_JOBNAME or from the base name of the shape screen report database and the task.

Parameters
  • dbfile (str) – Shape screen report database file

  • task (str) – The task being performed

Returns

Job name

Return type

str

schrodinger.application.phase.shape_screen_reporter.task_utils.get_structures(reporter, rows, max_in_memory=1000)

Generator that yields structures from a shape screen report database while limiting the number of structures held in memory.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • rows (list(int)) – The rows to read. Row 0 corresponds to the shape query, while rows 1, 2, etc. correspond to the hits. Rows may be in any order.

  • max_in_memory (int) – The maximum number of structures that will be held in memory while reading

Yield

The next structure in the list of rows

Ytype

structure.Structure

schrodinger.application.phase.shape_screen_reporter.task_utils.print_images(images, ncols, pdf_file, page_size=PageSize.Letter)

Prints a list of images to a table in PDF format.

Parameters
schrodinger.application.phase.shape_screen_reporter.task_utils.print_report(args, logger=None)

Generates a PDF file containing a table of annotated 2D hits that match a set of features in the shape query. Must construct a QApplication before calling this function.

Parameters
  • args (argparser.Namespace) – argparser.Namespace with command line arguments

  • logger (logging.Logger) – Logger for info level output

Raise

ValueError if any of the feature names, feature tolerances or feature rules are illegal.

schrodinger.application.phase.shape_screen_reporter.task_utils.run_diversity_filter(reporter, diverse_fraction, rows=None, logger=None)

Returns row numbers for a diverse fraction of structures in a shape screen report database.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • diverse_fraction (float) – Fraction on the interval (0.0, 0.2].

  • rows (list(int)) – The rows to screen. Row 0 corresponds to the shape query, while rows 1, 2, etc. correspond to the hits. Rows may be in any order. If omitted, rows for all hits are screened.

  • logger (logging.Logger) – Logger for info level output

Returns

Row numbers for the diverse structures

Return type

list(int)

schrodinger.application.phase.shape_screen_reporter.task_utils.run_filters(reporter, property_filter=None, smarts_filter=None, diverse_fraction=None, logger=None)

Returns row numbers of structures in a shape screen report database which satisfy the provided property, SMARTS and diversity filters.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • property_filter (phase.PhpDbPropertyQuery or NoneType) – Property filter to be satisfied

  • smarts_filter (filter.SmartsFilter or NoneType) – SMARTS filter to be satisfied

  • diverse_fraction (float or NoneType) – Optional diverse fraction of rows to retain after applying other filters. Must lie on (0.0, 0.2].

  • logger (logging.Logger or NoneType) – Logger for info level output

Returns

Row numbers that satisfy the filter

Return type

list(int)

schrodinger.application.phase.shape_screen_reporter.task_utils.run_property_filter(reporter, property_filter, logger=None)

Returns row numbers of structures in a shape screen report database which satisfy the provided property filter.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • property_filter (phase.PhpDbPropertyQuery) – Property filter to be satisfied

  • logger (logging.Logger) – Logger for info level output

Returns

Row numbers that satisfy the filter

Return type

list(int)

schrodinger.application.phase.shape_screen_reporter.task_utils.run_smarts_filter(reporter, smarts_filter, rows=None, logger=None)

Returns row numbers of structures in a shape screen report database which satisfy the provided SMARTS filter.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • smarts_filter (filter.SmartsFilter) – SMARTS filter to be satisfied

  • rows (list(int)) – The rows to screen. Row 0 corresponds to the shape query, while rows 1, 2, etc. correspond to the hits. Rows may be in any order. If omitted, rows for all hits are screened.

  • logger (logging.Logger) – Logger for info level output

Returns

Row numbers that satisfy the filter

Return type

list(int)

schrodinger.application.phase.shape_screen_reporter.task_utils.setup_screen(reporter, features, tol, rules)

Creates a pharmacophore hypothesis from user-supplied strings of features, tolerances and feature-matching rules.

Parameters
  • reporter (phase.PhpShapeScreenReporter) – Connection to a shape screen report database

  • features (str or NoneType) – String containing a comma-delimited list of query features to match. If None, all features in the query will be used.

  • tol (str) – String containing a dictionary-like specification of matching tolerances

  • rules (str) – String containing a dictionary-like specification of feature type matching rules

Returns

The pharmacophore hypothesis with which to perform the screen

Return type

phase.PhpHypoAdaptor

Raise

ValueError if any of the supplied feature names is illegal or not found in the shape query, or if any of the tolerances or permitted feature strings is illegal.

schrodinger.application.phase.shape_screen_reporter.task_utils.truncate_hits(args: argparse.Namespace, logger: Optional[logging.Logger] = None) None

Writes a truncated hits file if args.max_hits is smaller than the number of hits in arg.hits. If the query isn’t supplied in a separate file, it’s assumed that the first structure in args.hits is the query, in which case the number of hits is assumed to be the total number of structures - 1. If truncation is done, the file <jobname>_truncated.<ext> is created, where <ext> is .maegz or .sdfgz, and arg.hits is reset to to that file name.