schrodinger.rdkit.filtering module

PathFinder functions for filtering and for computing descriptors, including similarity metrics.

schrodinger.rdkit.filtering.NumChiralCenters(mol)

Wrapper for Chem.FindMolChiralCenters, so we can include it in DESCRIPTORS_DICT and pretend it’s an RDKit descriptor.

Return type

int

schrodinger.rdkit.filtering.TPSAIncludeSandP(mol)

The TPSA including S and P.

Return type

float

schrodinger.rdkit.filtering.MVCorrMW(mol)

The Molecular weight corrected for McGowan Volume, so it can be added to the DESCRIPTORS_DICT and pretend it is an RDKit descriptor.

Return type

float

schrodinger.rdkit.filtering.LongestConsecutiveRBCount(mol)

The maximum number of consecutive rotatable bonds in the molecule.

Return type

int

schrodinger.rdkit.filtering.MeanConsecutiveRBCount(mol)

The mean value of consecutive rotatable bonds in the molecule.

Return type

int

schrodinger.rdkit.filtering.LargestRingAtomCount(mol)

The size of the largest ring in mol.

Return type

int

schrodinger.rdkit.filtering.AlogP(mol: rdkit.Chem.rdchem.Mol) float
Returns

AlogP for the molecule as computed by RDKit

schrodinger.rdkit.filtering.NumSAtoms(mol)

The number of S atoms in the molecule.

Return type

int

schrodinger.rdkit.filtering.NumAlkyne(mol)

The number of alkynes in the molecule.

Return type

int

schrodinger.rdkit.filtering.FractionAromatic(mol)

The fraction of heavy atoms in the molecule that are aromatic atoms.

Return type

float

schrodinger.rdkit.filtering.logS(mol)

Calculate ESOL based on descriptors in the Delaney paper, coefficient refit for RDKit.

Return type

float

schrodinger.rdkit.filtering.NumNonSpiroCR4(mol)

The number of non spiro quaternary carbons attached to C, N, O or S.

Return type

int

schrodinger.rdkit.filtering.NumFiveFiveRings(mol)

The number of edge fused 5 atom ring pairs.

Returns

int

class schrodinger.rdkit.filtering.JSONFilterAdapter(json_data: str | dict)

Bases: object

An adapter to make a schrodinger.ui.qt.filter_dialog_dir.filter_core.Filter look like a schrodinger.structutils.filter.Filter.

__init__(json_data: str | dict)

Create a filter object given a JSON filename or raw data as a dict.

filter(mols)

A generator that yields only the mols that pass the filter conditions.

getPropertyNames()

Return the set of properties used by all the filters in this object.

Return type

set of str

class schrodinger.rdkit.filtering.ComparableMol(mol, prop, reverse=False)

Bases: object

A simple wrapper for a Mol object, adding the __lt__ operator so the mols can be put in a heap or sorted. Any double property may be used as the key.

__init__(mol, prop, reverse=False)
Parameters
  • mol (rdkit.Chem.rdchem.Mol) – molecule

  • prop (str) – key property name

  • reverse (bool) – if true, invert the the comparison (use > instead of <)

schrodinger.rdkit.filtering.keep_top_n(products, nkeep, nsample, prop, reverse=False)

A generator that yields only the best nkeep molecules out of the first nsample molecules in products, compared by prop. By default, the highest values of prop are kept; when reverse is true, the lowest values are kept instead.

NOTE: this function holds all nkeep molecules in memory at once.

Parameters
  • products (iterator of rdkit.Chem.Mol) – molecules to filter

  • nkeep (int) – maximum number of molecules to yield

  • nsample (int) – maximum number of molecules to consume from products

  • prop (str) – key property name

  • reverse (bool) – if true, keep the lowest instead of the highest values

Returns

filtered/sorted products

Return type

generator of rdkit.Chem.Mol

schrodinger.rdkit.filtering.get_filter(filter_data: str | dict, smarts_filter: bool = False) schrodinger.structutils.filter.Filter

Factory function to generate a Filter-like object from a filename or JSON data (i.e., a dict). Supports JSON and propfilter-like property filters, files as well as canvasSearch-like SMARTS filter files.

Parameters
  • filter_data – filename or JSON data. If it’s a file, the propfilter format is assumed unless the extension is .json. If it’s falsy, a do-nothing Filter will be returned.

  • smarts_filter – is this a SMARTS filter file?

Returns

Filter object.

Raise

if the filter_data is invalid, a ValueError from the underlying filter class may be propagated.

schrodinger.rdkit.filtering.get_fingerprint(mol)

A cached version of RDKit’s FingerprintMol, so if it’s called again with a recently used molecule, we’ll save the recalculation of the fingerprint.

Parameters

mol (rdkit.Chem.rdchem.Mol) – molecule

Returns

fingerprint

Return type

rdkit.DataStructs.cDataStructs.ExplicitBitVect

schrodinger.rdkit.filtering.compute_similarity(mol1, mol2)

Compute the Tanimoto similarity between the RDKit fingerprints of two molecules.

Parameters
  • mol1 (rdkit.Chem.rdchem.Mol) – molecule

  • mol2 (rdkit.Chem.rdchem.Mol) – molecule

Returns

similarity

Return type

float

schrodinger.rdkit.filtering.add_descriptors(mol, descriptor_names, refs)

Compute the requested RDKit descriptors and store them as properties of the Mol object.

Parameters

refs (sequence of Mol) – list of reference molecules (only used if similarity descriptors are requested)

Returns

input mol (modified in place)

Return type

Mol

schrodinger.rdkit.filtering.add_descriptors_gen(mols, descriptors, refs=None)

Given a generator of Mol, return a generator of Mol with descriptors added. The original Mol objects are modified.

Parameters
  • descriptors (sequence of str) – names of the descriptors to add

  • refs (sequence of Mol) – list of reference molecules (only used if similarity descriptors are requested)

schrodinger.rdkit.filtering.add_filters(products: Iterable[rdkit.Chem.rdchem.Mol], *, ref_mols: list[rdkit.Chem.rdchem.Mol] = None, ref_mols_file: str = None, property_filters: dict = None, property_filter_file: str = None, smarts_filter_file: str = None, descriptors: str = '') Iterator[rdkit.Chem.rdchem.Mol]

Return a generator that yields only the products passing the filters.

Parameters
  • products – an iterable of rdkit Mols.

  • ref_mols – list of reference molecules (only used if similarity descriptors are requested). Takes precedence over ref_mols_file.

  • ref_mols_file – file containing reference molecules (only used if similarity descriptors are requested)

  • property_filters – dictionary with JSON data describing the property filters, with the schema expected by filter_core.Filter. Takes precedence over property_filter_file.

  • property_filter_file – path to either a JSON file with the schema used by property_filters, or a propfilter input file.

  • smarts_filter_file – path to a canvasSearch input file.

  • descriptors – list of descriptors to compute as a comma-separated list. For supported names, see DESCRIPTORS_DICT.keys(). When using property filters, the properties used by the filters are added automatically, but with this argument it is possible to add even properties that are not required by the filters.

Raise

if the filter_data is invalid, a ValueError from the underlying filter class may be propagated.