schrodinger.application.phase.packages.mmp2d module

This module provides functions that perform various types of queries on a matched molecular pairs 2D database.

class schrodinger.application.phase.packages.mmp2d.MMPDatabaseConnection(db_path)

Bases: object

Context manager for a 2D MMP SQLite database connection.

__init__(db_path)

Initialize self. See help(type(self)) for accurate signature.

schrodinger.application.phase.packages.mmp2d.get_activity_cliffs(mmp2d_db_path, property_name, property_diff)

Given an MMP 2D SQLite database, this function returns all pairs of compound ids from the pair table for which the absolute difference in the indicated property is greater than or equal to property_diff.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Property_name:Name of the property for activity cliffs
Property_diff:Threshold on absolute property difference
Returns:Pairs of compound ids that exhibit an activity cliff
Return type:list[(int, int)]
schrodinger.application.phase.packages.mmp2d.get_compound_smiles(mmp2d_db_path)

Returns the compound id –> SMILES dictionary created from the compound table of the supplied MMP 2D SQLite database.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Returns:compound id –> SMILES dictionary
Return type:dict{int: str}
schrodinger.application.phase.packages.mmp2d.get_ids_from_pairs(compound_pairs)

Returns all unique compound ids in the provided pairs of compound ids.

Parameters:compound_pairs (list[(int, int)]) – Pairs of compound ids
Returns:Unique compound ids in increasing order
Return type:list[int]
schrodinger.application.phase.packages.mmp2d.get_pair_rule_env_ids(mmp2d_db_path, compound_pairs)

Returns a dictionary that maps each of the provided pairs of compound ids to a sorted list of rule environment ids, which are primary keys in the rule_environment table. For each pair (id1, id2), both the input order and the reverse order (id2, id1) are considered and are entered into the dictionary if rule environment ids are found for the given order. Thus, both orders should be checked when using the returned dictionary, and if a given pair must be reversed to find a match in the dictionary, the order-sensitive data in the transformation must be reversed/negated.

Parameters:
  • mmp2d_db_path (str) – Path to MMP 2D database
  • compound_pairs (set((int, int))) – Pairs of compound ids
Returns:

(compound1_id, compound2_id) –> rule environment ids

Return type:

dict{(int, int): list[int]}

schrodinger.application.phase.packages.mmp2d.get_property_names(mmp2d_db_path)

Returns the property name –> property id dictionary created from the property_name table of the supplied MMP 2D SQLite database.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Returns:property name –> property id dictionary
Return type:dict{str: int}
schrodinger.application.phase.packages.mmp2d.get_property_values(mmp2d_db_path, prop_name)

Returns the compound id –> property value dictionary created from the compound_property table of the supplied MMP 2D SQLite database.

Parameters:
  • mmp2d_db_path (str) – Path to MMP 2D database
  • property_name (str) – Property name whose values are desired
Returns:

compound id –> property value dictionary

Return type:

dict{int: float}

schrodinger.application.phase.packages.mmp2d.get_public_ids(mmp2d_db_path)

Returns the compound id –> public id dictionary created from the compound table of the supplied MMP 2D SQLite database.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Returns:property id –> public id dictionary
Return type:dict{int: str}
schrodinger.application.phase.packages.mmp2d.get_rule_env_rule_id(mmp2d_db_path)

Returns the rule_environment id –> rule_id dictionary created from the rule_environment table of the supplied MMP 2D SQLite database.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Returns:rule environment id –> rule id dictionary
Return type:dict{int: int}
schrodinger.application.phase.packages.mmp2d.get_rule_env_stats(mmp2d_db_path)

Returns the rule_environment id –> [min, max, avg, std, count] dictionary for the corresponding statistics in the rule_environment_statistics table. If a particular statistic is NULL (e.g., std when count is 1), a value of None is returned for that statistic.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Returns:rule environment id –> statistics dictionary
Return type:dict{int: [float, float, float, float, int]}
schrodinger.application.phase.packages.mmp2d.get_rule_id_rule_smiles(mmp2d_db_path)

Returns the rule_id –> [from_smiles, to_smiles] dictionary created from the rule and rule_smiles tables of the supplied MMP 2D SQLite database.

Parameters:mmp2d_db_path (str) – Path to MMP 2D database
Returns:rule_id –> [from_smiles, to_smiles] dictionary
Return type:dict{int: [str, str]}
schrodinger.application.phase.packages.mmp2d.get_transformations(compound_pair, pair_to_rule_env_ids, env_id_to_rule_id, rule_id_to_rule_smiles, env_id_to_stats)

Given a pair of compound ids and various dictionaries created from the database tables, this function returns a list of dictionaries that hold data for one or more MMP transformations that relate the first compound to the second compound. Each dictionary in the returned list contains the following key, value pairs:

Key Value — —– TRANS_KEYS.FROM_SMILES MMP fragment SMIRKS for the first compound (str) TRANS_KEYS.TO_SMILES MMP fragment SMIRKS for the second compound (str) TRANS_KEYS.MIN The min statistic for the transformation (float) TRANS_KEYS.MAX The max statistic for the transformation (float) TRANS_KEYS.AVG The avg statistic for the transofrmation (float) TRANS_KEYS.STD The std statistic for the transformation (float) TRANS_KEYS.COUNT The count statistic for the transformation (int)

Parameters:
  • mmp2d_db_path (str) – Path to MMP 2D database
  • compound_pair ((int, int)) – A pair of compound ids from the compound table. The input order and reverse order of the ids are considered, with reversal of from_smiles and to_smiles and negation of min, max and avg in the latter case.
  • pair_to_rule_env_ids (dict{(int, int): list[int]}) – Dictionary that maps compound id pairs to to rule environment ids. See get_pair_rule_env_ids.
  • env_id_to_rule_id (dict{int: int}) – Dictionary that maps rule_environment id to rule_id. See get_rule_env_rule_id.
  • rule_id_to_rule_smiles (dict{int: (str, str)}) – Dictionary that maps rule_id to the (from_smiles, to_smiles) pair that defines the transformation. See get_rule_id_rule_smiles.
  • env_id_to_stats (dict{int: (float, float, float, float, int)}) – Dictionary that maps rule_environment id to the tuple (min, max, avg, std, count). See get_rule_env_stats.
Returns:

List of transformation dictionaries

Return type:

list[dict{str: str/str/float/float/float/float/int}]

Raises:

KeyError if neither the input compound_pair nor its reverse is found in pair_to_rule_env_ids

schrodinger.application.phase.packages.mmp2d.select_dictionary(mmp2d_db_path, select_stmt)

Executes a select statement on the supplied MMP 2D SQLite database and returns the results as a dictionary.

Parameters:
  • mmp2d_db_path (str) – Path to MMP 2D database
  • select_stmt (str) – SELECT statement containing two fields
Returns:

field1 –> field2 dictionary

Return type:

dict{type(field1): type(field2)}

schrodinger.application.phase.packages.mmp2d.table_exists(mmp2d_db_path, table_name)

Returns true if the specified table exists in the supplied MMP 2D SQLite database.

Parameters:
  • mmp2d_db_path (str) – Path to MMP 2D database
  • table_name (str) – Table whose existence is sought
Returns:

Whether the table exists

Return type:

bool