I'm new to SMARTS and have to identify substructures with the Python package
rdkit, so far so good. Let's say I have a SMILES with an carboxylic acid and a alcohol such as
and I want to get only the alcohol, then I would try something like this:
mol = Chem.MolFromSmiles("OC(C1=CC(CO)=CC=C1)=O") toSearch = Chem.MolFromSmarts("[#6][OX2H]") bool = mol.HasSubstructMatch(toSearch) subStruct = mol.GetSubstructMatches(toSearch) print(bool) print(subStruct)
True ((1, 0), (5, 6))
However, the substructure search also identifies the OH of the acid which I don't want. How can I exclude that? My idea was to use some kind of recursive smarts for the alcohol to exclude all those "alcohols" where the carbon is bonded to another oxygen like "=O".