$npx -y skills add jinzhezenggroup/computational-chemistry-agent-skills --skill openbabelA versatile CLI tool for converting molecular file formats, generating 3D atomic coordinates from SMILES, rendering 2D chemical structure images, and preparing or extracting structures for computational workflows. USE WHEN you need to convert between chemical file formats (e.g.,
| 1 | # Open Babel |
| 2 | |
| 3 | This skill provides practical Open Babel command patterns for common chemistry data tasks. |
| 4 | |
| 5 | ## Quick Start |
| 6 | |
| 7 | Check installation through uvx: |
| 8 | |
| 9 | ```bash |
| 10 | uvx --from openbabel obabel -V |
| 11 | ``` |
| 12 | |
| 13 | Typical conversion syntax: |
| 14 | |
| 15 | ```bash |
| 16 | uvx --from openbabel obabel input.ext -i<input_format> -o<output_format> -O output.ext |
| 17 | ``` |
| 18 | |
| 19 | ## Core Tasks |
| 20 | |
| 21 | ### 1) File format conversion |
| 22 | |
| 23 | Convert XYZ to PDB: |
| 24 | |
| 25 | ```bash |
| 26 | uvx --from openbabel obabel C.xyz -ixyz -opdb -O C.pdb |
| 27 | ``` |
| 28 | |
| 29 | Open Babel supports a large set of chemistry formats (e.g., xyz, mol, mol2, pdb, smi, Gaussian gjf/log/fchk, etc.). |
| 30 | |
| 31 | ### 2) Build structures from SMILES |
| 32 | |
| 33 | Generate methane (3D coordinates required): |
| 34 | |
| 35 | ```bash |
| 36 | uvx --from openbabel obabel -:C --gen3d -omol -O C.mol |
| 37 | ``` |
| 38 | |
| 39 | Generate a single carbon atom: |
| 40 | |
| 41 | ```bash |
| 42 | uvx --from openbabel obabel -:[C] --gen3d -omol -O C.mol |
| 43 | ``` |
| 44 | |
| 45 | Generate methyl radical: |
| 46 | |
| 47 | ```bash |
| 48 | uvx --from openbabel obabel -:[CH3] --gen3d -omol -O CH3.mol |
| 49 | ``` |
| 50 | |
| 51 | > Important: quote SMILES when they contain brackets or special characters. |
| 52 | |
| 53 | Equivalent explicit form: |
| 54 | |
| 55 | ```bash |
| 56 | uvx --from openbabel obabel -:"[C]([H])([H])[H]" --gen3d -omol -O CH3.mol |
| 57 | ``` |
| 58 | |
| 59 | ### 3) Export SMILES from one or more structure files |
| 60 | |
| 61 | ```bash |
| 62 | uvx --from openbabel obabel C.mol C.mol2 C.pdb C.xyz --osmi -O C.smi |
| 63 | ``` |
| 64 | |
| 65 | ### 4) Render 2D structure images |
| 66 | |
| 67 | Generate PNG: |
| 68 | |
| 69 | ```bash |
| 70 | uvx --from openbabel obabel -:"C([C@@H](C(=O)O)N)S" -opng -O cys.png |
| 71 | ``` |
| 72 | |
| 73 | Generate SVG: |
| 74 | |
| 75 | ```bash |
| 76 | uvx --from openbabel obabel -:"C([C@@H](C(=O)O)N)S" -osvg -O cys.svg |
| 77 | ``` |
| 78 | |
| 79 | Convert Gaussian log directly to image: |
| 80 | |
| 81 | ```bash |
| 82 | uvx --from openbabel obabel phosphate.log -ilog -opng -O phosphate.png |
| 83 | ``` |
| 84 | |
| 85 | ### 5) Gaussian workflow helper |
| 86 | |
| 87 | Generate Gaussian input from SMILES, then patch header with `sed`: |
| 88 | |
| 89 | ```bash |
| 90 | uvx --from openbabel obabel -:CC --gen3d -ogjf | sed "1c %nproc=28\n#opt b3lyp/6-31g(d,p)" > CC.gjf |
| 91 | ``` |
| 92 | |
| 93 | Generate next-step input from a previous Gaussian log: |
| 94 | |
| 95 | ```bash |
| 96 | uvx --from openbabel obabel CC.log -ilog -ogjf | sed "1c %nproc=28\n#freq b3lyp/6-31g(d,p)" > CC2.gjf |
| 97 | ``` |
| 98 | |
| 99 | ## Agent Checklist |
| 100 | |
| 101 | When using this skill for users: |
| 102 | |
| 103 | 1. Confirm source file(s) and desired target format. |
| 104 | 1. Prefer explicit `-i` and `-o` format flags for reproducibility. |
| 105 | 1. Add `--gen3d` when converting SMILES to coordinate-bearing structures. |
| 106 | 1. Quote SMILES strings that contain brackets/parentheses. |
| 107 | 1. For Gaussian workflows, verify route section and resource lines (`%nproc`, method/basis) after generation. |
| 108 | 1. Use `uvx --from openbabel obabel ...` consistently to minimize local dependency setup. |
| 109 | |
| 110 | ## References |
| 111 | |
| 112 | - Open Babel project: https://openbabel.org/ |
| 113 | - Open Babel GitHub: https://github.com/openbabel/openbabel |
| 114 | - openbabel package: https://pypi.org/project/openbabel/ |