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

New contributor
dideldideldum is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
  • 2
    $\begingroup$ Hello! You may also be interested in the Matter Modeling 'sister site'. (though please don't post questions twice) $\endgroup$
    – orthocresol
    Aug 5 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 at 13:37
  • 1
    $\begingroup$ @dideldideldum - that does seem to work: i.stack.imgur.com/VIfOp.png $\endgroup$
    – Jason B.
    2 days ago
  • 1
    $\begingroup$ The smarts.plus website is also useful for visualizing / debugging SMARTS patterns. $\endgroup$ 2 days ago

Your Answer

dideldideldum is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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