Task tutorial
Filter a SMILES library with a SMARTS pattern
Screen a local list for a functional-group pattern and keep the matching SMILES in input order.
You will make
A reproducible local hit list for one explicit SMARTS query.
Steps
- Choose a SMARTS pattern and a local SMILES list.
- Run the parallel pattern screen once.
- Write the pattern, input version, and matching SMILES together before interpreting the hit list.
import chematic
smiles = ["CC(=O)O", "CCO", "O=C(O)c1ccccc1O"]
pattern = "[CX3](=O)[OX2H1]" # carboxylic acid
matches = chematic.bulk.substructure_search(pattern, smiles)
hits = [smiles[i] for i, matched in enumerate(matches) if matched]
print(hits)Expected result
The script returns the matching SMILES in the same order as the input list. The shown pattern matches acetic acid and salicylic acid, but not ethanol.
If it does not work
An invalid SMILES returns False from this screening API, which is indistinguishable from a non-match. Validate source data first when a negative result needs to be explained.