I'm looking for a tool that can give how many methyl groups, hydroxyl groups etc are in a compound's structure presented as SMILES, SDF or MOL2 format.


There are numerous programs, but it's pretty easy to use the obgrep tool in Open Babel to do this using SMARTS for the various functional groups:

  • obgrep -c '[CX3]' file.sdf # count the number of methyl groups
  • obgrep -c '[#6][OX2H]' file.sdf # count the number of hydroxyl groups

etc. Examples of functional groups using SMARTS can be found on the Daylight SMARTS examples page.

I've also written scripts in Python for these purposes - depends on how you want to run the SMARTS searches.

  • $\begingroup$ Thanks a lot. For testing I've used this file, it contains two methyl groups but the command: obgrep -c '[CX3]' HMDB37025.sdf returning 0! $\endgroup$
    – Ruhshan
    May 5 '17 at 18:50

Your Answer

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.