3
$\begingroup$

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

OC(C1=CC(CO)=CC=C1)=O

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)

which would return: enter image description here

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".

$\endgroup$
1
  • 2
    $\begingroup$ Hello! You may also be interested in the Matter Modeling 'sister site'. (though please don't post questions twice) $\endgroup$ Aug 5, 2022 at 16:03

1 Answer 1

5
$\begingroup$

The simplest change to make for your SMARTS pattern would be specifying the total degree of the attached carbon is 4 with "[#6X4][OX2H]". This is enough to discriminate against the carboxylic acid.

You could use the alcohol SMARTS from here, which has the comment

nonspecific definition, no acetals, aminals, and the like

The SMARTS pattern is "[OX2H][CX4;!$(C([OX2H])[O,S,#7,#15])]", which stipulates that the carbon attached to the oxygen not also be connected to O, S, N, or P.

I made a little interactive widget that takes a molecule name or SMILES in the first field and a SMARTS pattern in the second.

$\endgroup$
3
  • $\begingroup$ Awesome!!!! Thanks for the answer and the two great links! I have one more question. This smart doesn't hit if the alcohol is on an aromatic carbon. In this Case this smarts "[OX2H][CX4,c;!$(C([OX2H])[O,S,#7,#15])]" should work, shouldn't it? thx! $\endgroup$ Aug 6, 2022 at 13:37
  • 1
    $\begingroup$ @dideldideldum - that does seem to work: i.sstatic.net/VIfOp.png $\endgroup$
    – Jason B.
    Aug 6, 2022 at 16:57
  • 1
    $\begingroup$ The smarts.plus website is also useful for visualizing / debugging SMARTS patterns. $\endgroup$ Aug 6, 2022 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.