rdkit.Chem.rdfiltercatalog module¶
Module containing FilterCatalog functionality for filtering molecules based on structural patterns.
- class rdkit.Chem.rdfiltercatalog.ExclusionList(self)¶
Bases:
FilterMatcher- AddPattern(self, base: rdkit.Chem.rdfiltercatalog.FilterMatcher) None¶
Add a FilterMatcherBase that should not appear in a molecule
- class rdkit.Chem.rdfiltercatalog.FilterCatalog(self)¶
- class rdkit.Chem.rdfiltercatalog.FilterCatalog(self, pickle: bytes)
- class rdkit.Chem.rdfiltercatalog.FilterCatalog(self, pickle: str)
- class rdkit.Chem.rdfiltercatalog.FilterCatalog(self, params: rdkit.Chem.rdfiltercatalog.FilterCatalogParams)
- class rdkit.Chem.rdfiltercatalog.FilterCatalog(self, catalogs: rdkit.Chem.rdfiltercatalog.FilterCatalogParams.FilterCatalogs)
Bases:
object- AddEntry(self, entry: rdkit.Chem.rdfiltercatalog.FilterCatalogEntry) None¶
Add a FilterCatalogEntry to the catalog
- GetEntry(self, idx: int) rdkit.Chem.rdfiltercatalog.FilterCatalogEntry¶
Return the FilterCatalogEntry at the specified index
- GetEntryWithIdx(self, idx: int) rdkit.Chem.rdfiltercatalog.FilterCatalogEntry¶
Return the FilterCatalogEntry at the specified index
- GetFilterMatches(self, mol: rdkit.Chem.rdchem.Mol) list[rdkit.Chem.rdfiltercatalog.FilterMatch]¶
Return every matching filter from all catalog entries that match mol
- GetFirstMatch(self, mol: rdkit.Chem.rdchem.Mol) rdkit.Chem.rdfiltercatalog.FilterCatalogEntry¶
Return the first catalog entry that matches mol
- GetMatches(self, mol: rdkit.Chem.rdchem.Mol) list[rdkit.Chem.rdfiltercatalog.FilterCatalogEntry]¶
Return all catalog entries that match mol
- GetNumEntries(self) int¶
Returns the number of entries in the catalog
- HasMatch(self, mol: rdkit.Chem.rdchem.Mol) bool¶
Returns True if the catalog has an entry that matches mol
- RemoveEntry(self, obj: object) bool¶
Remove the given entry from the catalog
- Serialize(self) bytes¶
- class rdkit.Chem.rdfiltercatalog.FilterCatalogEntry¶
Bases:
objectA filter catalog entry is an entry in a filter catalog. Each filter is named and is used to flag a molecule usually for some undesirable property.
For example, a PAINS (Pan Assay INterference) catalog entry be appear as follows:
>>> from rdkit.Chem.FilterCatalog import * >>> params = FilterCatalogParams() >>> params.AddCatalog(FilterCatalogParams.FilterCatalogs.PAINS_A) True >>> catalog = FilterCatalog(params) >>> mol = Chem.MolFromSmiles('O=C(Cn1cnc2c1c(=O)n(C)c(=O)n2C)N/N=C/c1c(O)ccc2c1cccc2') >>> entry = catalog.GetFirstMatch(mol) >>> print (entry.GetProp('Scope')) PAINS filters (family A) >>> print (entry.GetDescription()) hzone_phenol_A(479)
__init__(self) -> None __init__(self, name: str, matcher: rdkit.Chem.rdfiltercatalog.FilterMatcher) -> None
- GetDescription(self) str¶
Get the description of the catalog entry
- GetFilterMatches(self, mol: rdkit.Chem.rdchem.Mol) list[rdkit.Chem.rdfiltercatalog.FilterMatch]¶
Retrieve the list of filters that match the molecule
- GetProp(self, key: str) str¶
- GetPropList(self) list[str]¶
- HasFilterMatch(self, mol: rdkit.Chem.rdchem.Mol) bool¶
Returns True if the catalog entry contains filters that match the molecule
- IsValid(self) bool¶
- Serialize(self) bytes¶
- class rdkit.Chem.rdfiltercatalog.FilterCatalogParams(self)¶
- class rdkit.Chem.rdfiltercatalog.FilterCatalogParams(self, catalogs: rdkit.Chem.rdfiltercatalog.FilterCatalogParams.FilterCatalogs)
Bases:
objectOverloaded function.
__init__(self) -> None__init__(self, catalogs: rdkit.Chem.rdfiltercatalog.FilterCatalogParams.FilterCatalogs) -> None
Construct from a FilterCatalogs identifier (i.e. FilterCatalogParams.PAINS)
- AddCatalog(self, catalogs: rdkit.Chem.rdfiltercatalog.FilterCatalogParams.FilterCatalogs) bool¶
- class FilterCatalogs(*values)¶
Bases:
IntEnum- ALL = 16382¶
- BRENK = 16¶
- CHEMBL = 16256¶
- CHEMBL_BMS = 512¶
- CHEMBL_Dundee = 256¶
- CHEMBL_Glaxo = 128¶
- CHEMBL_Inpharmatica = 4096¶
- CHEMBL_LINT = 8192¶
- CHEMBL_MLSMR = 2048¶
- CHEMBL_SureChEMBL = 1024¶
- NIH = 32¶
- PAINS = 14¶
- PAINS_A = 2¶
- PAINS_B = 4¶
- PAINS_C = 8¶
- ZINC = 64¶
- class rdkit.Chem.rdfiltercatalog.FilterHierarchyMatcher(self)¶
- class rdkit.Chem.rdfiltercatalog.FilterHierarchyMatcher(self, matcher: rdkit.Chem.rdfiltercatalog.FilterMatcher)
Bases:
FilterMatcher- Hierarchical Filter
- basic constructors:
FilterHierarchyMatcher( matcher ) where can be any FilterMatcherBase (SmartsMatcher, etc)
- FilterHierarchyMatcher’s have children and can form matching
trees. When GetFilterMatches is called, the most specific ( i.e. lowest node in a branch) is returned.
- n.b. A FilterHierarchicalMatcher of functional groups is returned
by calling GetFunctionalGroupHierarchy()
>>> from rdkit.Chem import MolFromSmiles >>> from rdkit.Chem.FilterCatalog import * >>> functionalGroups = GetFunctionalGroupHierarchy() >>> [match.filterMatch.GetName() ... for match in functionalGroups.GetFilterMatches( ... MolFromSmiles('c1ccccc1Cl'))] ['Halogen.Aromatic', 'Halogen.NotFluorine.Aromatic']
Overloaded function.
__init__(self) -> None__init__(self, matcher: rdkit.Chem.rdfiltercatalog.FilterMatcher) -> None
Construct from a filtermatcher
- AddChild(self, hierarchy: rdkit.Chem.rdfiltercatalog.FilterHierarchyMatcher) rdkit.Chem.rdfiltercatalog.FilterHierarchyMatcher¶
Add a child node to this hierarchy.
- SetPattern(self, matcher: rdkit.Chem.rdfiltercatalog.FilterMatcher) None¶
Set the filtermatcher pattern for this node. An empty node is considered a root node and passes along the matches to the children.
- class rdkit.Chem.rdfiltercatalog.FilterMatch(self, filter: rdkit.Chem.rdfiltercatalog.FilterMatcher, atomPairs: collections.abc.Sequence[tuple[int, int]])¶
Bases:
objectObject that holds the result of running FilterMatcherBase::GetMatches
filterMatch holds the FilterMatchBase that triggered the match
atomPairs holds the [ (query_atom_idx, target_atom_idx) ] pairs for the matches.
Note that some matches may not have atom pairs (especially matches that use FilterMatchOps.Not
- property atomPairs¶
(self) -> list[tuple[int, int]]
- property filterMatch¶
(self) -> RDKit::FilterMatcherBase
- class rdkit.Chem.rdfiltercatalog.FilterMatcher(self, name: str)¶
Bases:
objectBase class for matching molecules to filters.
A FilterMatcherBase supplies the following API - IsValid() returns True if the matcher is valid for use, False otherwise - HasMatch(mol) returns True if the molecule matches the filter - GetMatches(mol) -> [FilterMatch, FilterMatch] returns all the FilterMatch data
that matches the molecule
print( FilterMatcherBase ) will print user-friendly information about the filter Note that a FilterMatcherBase can be combined from many FilterMatcherBases This is why GetMatches can return multiple FilterMatcherBases. >>> from rdkit.Chem.FilterCatalog import * >>> carbon_matcher = SmartsMatcher(‘Carbon’, ‘[#6]’, 0, 1) >>> oxygen_matcher = SmartsMatcher(‘Oxygen’, ‘[#8]’, 0, 1) >>> co_matcher = FilterMatchOps.Or(carbon_matcher, oxygen_matcher) >>> mol = Chem.MolFromSmiles(‘C’) >>> matches = co_matcher.GetMatches(mol) >>> len(matches) 1 >>> print(matches[0].filterMatch) Carbon
- GetMatches(self, mol: rdkit.Chem.rdchem.Mol) list[rdkit.Chem.rdfiltercatalog.FilterMatch]¶
Returns the list of matching subfilters mol matches any filter
- GetName(self) str¶
- HasMatch(self, mol: rdkit.Chem.rdchem.Mol) bool¶
Returns True if mol matches the filter
- IsValid(self) bool¶
Return True if the filter matcher is valid, False otherwise
- rdkit.Chem.rdfiltercatalog.FilterMatcherBase¶
alias of
FilterMatcher
- rdkit.Chem.rdfiltercatalog.PythonFilterMatcher¶
alias of
FilterMatcher
- class rdkit.Chem.rdfiltercatalog.SmartsMatcher(self, name: str)¶
- class rdkit.Chem.rdfiltercatalog.SmartsMatcher(self, rhs: rdkit.Chem.rdchem.Mol)
- class rdkit.Chem.rdfiltercatalog.SmartsMatcher(self, name: str, mol: rdkit.Chem.rdchem.Mol, minCount: int = 1, maxCount: int = 4294967295)
- class rdkit.Chem.rdfiltercatalog.SmartsMatcher(self, name: str, smarts: str, minCount: int = 1, maxCount: int = 4294967295)
Bases:
FilterMatcher- Smarts Matcher Filter
- basic constructors:
SmartsMatcher( name, smarts_pattern, minCount=1, maxCount=UINT_MAX ) SmartsMatcher( name, molecule, minCount=1, maxCount=UINT_MAX )
- note: If the supplied smarts pattern is not valid, the IsValid() function will
return False
>>> from rdkit.Chem.FilterCatalog import * >>> minCount, maxCount = 1,2 >>> carbon_matcher = SmartsMatcher('Carbon', '[#6]', minCount, maxCount) >>> print (carbon_matcher.HasMatch(Chem.MolFromSmiles('CC'))) True >>> print (carbon_matcher.HasMatch(Chem.MolFromSmiles('CCC'))) False >>> carbon_matcher.SetMinCount(2) >>> print (carbon_matcher.HasMatch(Chem.MolFromSmiles('C'))) False >>> carbon_matcher.SetMaxCount(3) >>> print (carbon_matcher.HasMatch(Chem.MolFromSmiles('CCC'))) True
Overloaded function.
__init__(self, name: str) -> None__init__(self, rhs: rdkit.Chem.rdchem.Mol) -> None
Construct from a molecule
__init__(self, name: str, mol: rdkit.Chem.rdchem.Mol, minCount: int = 1, maxCount: int = 4294967295) -> None
Construct from a name, molecule, minimum and maximum count
__init__(self, name: str, smarts: str, minCount: int = 1, maxCount: int = 4294967295) -> None
Construct from a name, smarts pattern, minimum and maximum count
- GetMaxCount(self) int¶
Get the maximum times pattern can appear for the filter to match
- GetMinCount(self) int¶
Get the minimum times pattern must appear for the filter to match
- GetPattern(self) rdkit.Chem.rdchem.Mol¶
- IsValid(self) bool¶
Returns True if the SmartsMatcher is valid
- SetMaxCount(self, count: int) None¶
Set the maximum times pattern can appear for the filter to match
- SetPattern(self, pat: rdkit.Chem.rdchem.Mol) None¶
- SetPattern(self, pat: str) None
Overloaded function.
SetPattern(self, pat: rdkit.Chem.rdchem.Mol) -> None
Set the pattern molecule for the SmartsMatcher
SetPattern(self, pat: str) -> None
Set the smarts pattern for the Smarts Matcher (warning: MinimumCount is not reset)