schrodinger.active_learning.substruct_enrichment module

class schrodinger.active_learning.substruct_enrichment.SubstructEnrichCalculator(min_ratio=0.1, min_enrich=2, p_value_cut=0.01, keep_non_leaf_nodes=True, min_fragment_size=0, use_rgroup=False, core_smarts=None, single_pass=False)

Bases: object

Calculates the substructure enrichment of a query set of ligands against a reference library.

DEFAULT_MIN_RATIO = 0.1
DEFAULT_MIN_ENRICH = 2
DEFAULT_P_VALUE_CUT = 0.01
DEFAULT_KEEP_NON_LEAF_NODES = True
DEFAULT_MIN_FRAGMENT_SIZE = 0
__init__(min_ratio=0.1, min_enrich=2, p_value_cut=0.01, keep_non_leaf_nodes=True, min_fragment_size=0, use_rgroup=False, core_smarts=None, single_pass=False)

Initialize the Calculator.

Parameters:
  • min_ratio – minimum ratio of appearing in the query set to be considered as a candidate substructure

  • min_enrich – minimum enrichment to be considered as a candidate substructure

  • p_value_cut – minimum p-value to be considered as a candidate substructure

  • keep_non_leaf_nodes – whether to retain internal nodes of the BRICS fragmentation tree alongside the terminal leaves

  • min_fragment_size – minimum heavy-atom count for a BRICS fragment to be emitted

  • use_rgroup – whether to use R-groups instead of full molecules to generate fragments.

  • core_smarts – If using R-groups, the core smarts for R-group decomposition.

  • single_pass – Whether to do only a single pass of BRICS fragmentation. This is useful to make sure that the enriched fragments are not all too small.

make_rgroup_decomposer()
get_frags_from_mol(mol)

Get the fragments from a molecule using BRICS decomposition.

Parameters:

mol – RDKit molecule object

Returns:

set of SMILES strings of the fragments

static replace_dummies_with_H(mol: Mol) Mol

Strip RGroupDecomposition dummy attachment atoms (for instance [*:1]) so the R-group becomes a stand-alone molecule that BRICS can decompose.

Parameters:

mol – RDKit molecule object

Returns:

RDKit molecule object with dummy atoms replaced by hydrogens

get_rgroup_subfrags_from_mols(mol_list: list[rdkit.Chem.rdchem.Mol]) list[set[str]]

For each input mol, run R-group decomposition, BRICS-decompose each R-group, and return a per-mol set of sub-fragment SMILES. It omits the mols that did not match the core.

Parameters:

mol_list – list of RDKit molecule objects

Returns:

list of sets of fragment SMILES found in R-groups for each input molecule that matches the core.

get_frags_for_smiles_list(smiles_list)

Process a list of SMILES to get fragments and molecule count.

static remove_explicit_H(mol)
static dedup_frags(frags_count_dict)

If a fragment is a substructure of another (parent) fragment, and the substructure’s count is less than or equal to the parent’s count, then remove that substructure.

Parameters:

frags_count_dict – dictionary of SMILES strings and their counts

Returns:

dictionary of deduplicated SMILES strings and their counts

compute_and_save_fragment_frequency(library_smiles_list, json_output_file, min_count=1)

Calculate and save fragment frequencies for a library to a JSON file.

Parameters:
  • library_smiles_list – list of SMILES strings of the library

  • json_output_file – path to the output JSON file

  • min_count – minimum number of library compounds a fragment must appear in to be included in the output.

calculate(query_smiles_list, library_smiles_list) DataFrame

Run the calculation of substructure enrichment.

Parameters:
  • query_smiles_list – list of SMILES strings of the query set

  • library_smiles_list – list of SMILES strings of the reference library

Returns:

DataFrame of the enrichment results

calculate_from_json(query_smiles_list, library_json_file) DataFrame

Run the calculation of substructure enrichment using a precomputed library fragment JSON file.

Parameters:
  • query_smiles_list – list of SMILES strings of the query set

  • library_json_file – path to the JSON file containing precomputed library fragments

Returns:

DataFrame of the enrichment results