medchem.constraints
¶
medchem.constraints.Constraints
¶
Complex query system for performing substructure matches with additional constraints
Example
mol1 = dm.to_mol("CN(C)C(=O)c1cncc(C)c1")
mol2 = dm.to_mol("c1ccc(cc1)-c1cccnc1")
core = dm.from_smarts("c1cncc([*:1])c1")
[atom.SetProp("query", "my_constraints") for atom in core.GetAtoms() if atom.GetAtomMapNum() == 1]
constraint_fns = dict(my_constraints=lambda x: dm.descriptors.n_aromatic_atoms(x) > 0)
constraint = Constraints(core, constraint_fns)
matches = [constraint(mol1), constraint(mol2)] # False, True
__call__(mol)
¶
Check if input molecule respect the constraints
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
input molecule |
required |
__init__(core, constraint_fns, prop_name='query')
¶
Initialize the constraint matcher
Parameters:
Name | Type | Description | Default |
---|---|---|---|
core |
Mol
|
the scaffold/query molecule to match against. Needs to be a molecule |
required |
constraint_fns |
Dict[str, Callable]
|
a dictionary of constraint functions that defines the required constraints after the substructure match |
required |
prop_name |
str
|
the property name to use in the match at each atom defined by the core for further matches against the constraints functions |
'query'
|
get_matches(mol, multiple=True)
¶
Get matches that respect the constraints in the molecules
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
input molecule |
required |
multiple |
bool
|
if True, return all the matches, if False, return the first match |
True
|
has_match(mol)
¶
Check if input molecule respect the constraints
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
input molecule |
required |
validate(mol, constraints)
staticmethod
¶
Validate a list of constraint object against a molecule
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Mol
|
the molecule object |
required |
constraints |
List[Constraints]
|
list of Contraints object to validate against the molecule |
required |