# Obtaining number of functional groups in a compound from SMILES, SDF or MOL2 format

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.

• 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! – user3508066 May 5 '17 at 18:50