OBGREP(1)

πŸ’… OBGREP(1) β€” like, the advanced molecular search program bestie

okay so welcome to obgrep, from the User's Reference Manual ✨ this is genuinely one of my fave little Open Babel tools and I need you to know about it 🫢


✨ NAME ✨

obgrep β€” an advanced molecular search program using SMARTS πŸ§šβ€β™€οΈ

(no cap, it's literally grep but for molecules and honestly? iconic.)


🌸 SYNOPSIS 🌸

obgrep [OPTIONS] SMARTS-pattern filename

like, that's it. pattern, file, go πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe: the obgrep tool can be used to search for molecules inside multi-molecule database files (e.g., SMILES, SDF, etc.) or across multiple files.

that's the whole thing. it's giving "find the thing in the pile of things" and honestly it ate. πŸ”₯


πŸŽ€ OPTIONS πŸŽ€

lowkey important: if only a filename is given, obgrep will attempt to guess the file type from the filename extension. she's intuitive like that πŸ’–

  • -c β€” print the number of matches πŸ”’ (just the count, bestie)
  • -f β€” full match; print matching-molecules only when the number of heavy atoms is also equal to the number of atoms in the SMARTS-pattern ⭐ (so it's gotta be the whole molecule, not just contain it β€” main character energy)
  • -i format β€” specifies input and output format, see obabel(1) for available formats πŸ¦‹ (yes queen, go check the other manpage)
  • -n β€” only print the name of the molecules 🏷️ (names only, no structure spam)
  • -t # β€” print a molecule only if the pattern occurs # times inside the molecule 🌈 (exact count match, periodt)
  • -v β€” invert the matching, print non-matching molecules πŸ™ˆ (the "not this" girlie)

πŸ“ EXAMPLES πŸ“

note that in all examples, the SMARTS pattern is enclosed in single quotes '...' to ensure it is not changed by the shell. protect your pattern at all costs, she's fragile πŸ’€

print all the molecules with a methylamine group:

obgrep 'CN' database.smi

print all the molecules without a methylamine group:

obgrep -v 'CN' database.smi

print the number of molecules without a methylamine group:

obgrep -v -c 'CN' database.smi

print methylamine (if it exists in the file):

obgrep -f 'CN' database.smi

print methylamine and/or methanol (if they exist):

obgrep -f 'C[N,O]' database.smi

print all molecules with aromatic carbon in all SMILES files in the directory (i.e., *.smi):

obgrep 'c' *.smi

see how the wildcard just works? globbing is so underrated ngl 🌟


🌈 SEE ALSO 🌈

the web pages for Open Babel can be found at: <https://openbabel.org/> 🫢

a guide for constructing SMARTS patterns can be found at: <https://www.daylight.com/dayhtml/doc/theory/theory.smarts.html> 🧠✨ (fr fr read this one if SMARTS is confusing you, it's the blueprint)


πŸ‘‘ AUTHORS πŸ‘‘

the obgrep program was contributed by Fabien Fontaine πŸ’œ thank you legend!!

Open Babel is developed by a cast of many, including current maintainers Geoff Hutchison, Chris Morley, Michael Banck, and innumerable others who have contributed fixes and additions. for more contributors to Open Babel, see <https://openbabel.org/docs/Introduction/thanks.html> 🌸


Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. Some portions Copyright (C) 2001-2007 by Geoffrey R. Hutchison and other contributors.

this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.

⚠️ this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details. (like, legally speaking, no promises bestie 😭)

and that's the whole page!! this one's from Open Babel 3.2, dated May 26, 2026 β€” go grep some molecules, you're gonna slay πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from