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)-iformat β specifies input and output format, seeobabel(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 π
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
- arch rolling: openbabel 3.2.1-1 Β· GPL-2.0-only
- opensuse-leap 16.0: openbabel 3.2.0-bp160.1.1 Β· GPL-2.0-only
- opensuse-leap 16.0: openbabel 3.2.0-bp160.1.1 Β· GPL-2.0-only
- opensuse-leap 16.0: openbabel 3.2.0-bp160.1.1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms