Command Palette

Search for a command to run...

Back to skills
skill № 08588

bio-structural-biology-structure-io

Reads, writes, downloads, and converts macromolecular structures with Biopython Bio.PDB. Use when choosing a format (mmCIF/PDBx vs legacy PDB vs BinaryCIF)…

FreeRuns bundled scripts
lilinjiby lilinji★ 18 GitHub stars

Install bio-structural-biology-structure-io in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Version Compatibility

Reference examples tested with: biopython 1.85+

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(module.function) to check signatures

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Structure I/O

"Read a structure file" -> Parse a deposited coordinate file into an in-memory SMCRA tree, or fetch it from a wwPDB mirror.

  • Python: Bio.PDB.MMCIFParser().get_structure('id', 'file.cif'), Bio.PDB.PDBParser(), Bio.PDB.PDBList()

Governing Principle

mmCIF (PDBx) is the canonical modern format; the legacy fixed-column PDB format is a frozen, lossy container, and a "parse everything as PDB" reflex silently truncates or fails on anything large. The PDB format was frozen in 2012 and cannot physically exceed 99,999 atoms (5-digit serial), ~62 chains (single alphanumeric chain id), or 9,999 residues per chain (wwPDB file-format documentation; the PDB archive itself is Berman et al. 2000 Nucleic Acids Res 28:235-242). Large assemblies (ribosomes, capsids, spliceosomes, most big cryo-EM structures) therefore exist ONLY as mmCIF, and converting a big mmCIF down to PDB renames multi-character chains and overflows serial numbers, silently corrupting any downstream tool that keys on chain id. mmCIF has been the wwPDB archive standard since 2014 and mandatory for crystallographic depositions since July 2019.

Two further traps compound this. First, Bio.PDB is PERMISSIVE by design: it reads malformed files, and it silently drops anisotropic B-factors (ANISOU), collapses each disordered atom to its highest-occupancy alternate, and never models most metadata (resolution, method, R-free, entity graph, assembly operators). Parse-success is not data integrity. Second, the deposited coordinates for an X-ray entry are usually the ASYMMETRIC UNIT, a crystallographic bookkeeping object that is frequently NOT the biologically functional oligomer -- so any interface, oligomeric-state, or buried-surface question must first obtain the biological assembly (Krissinel & Henrick 2007 J Mol Biol 372:774). "One chain in the file" is never evidence of a monomer.

The escape hatch for all three ceilings (assembly generation, very large structures, full mmCIF fidelity) is gemmi (Wojdyr 2022 JOSS 7:4200); Bio.PDB cannot apply the assembly operators itself. Prefer Bio.PDB for teaching, small structures, and hierarchy walks; reach for gemmi when the questions above appear.

Decision: which format

Format Best when Fails when Hard limits
mmCIF / PDBx (.cif, .cif.gz) Any modern default; large assemblies; full metadata; auth+label numbering; ANISOU/entities A legacy tool only reads fixed-column PDB None
Legacy PDB (.pdb, .ent) Small structure feeding an old tool that demands PDB columns Structure exceeds the format's limits (silently truncates/renames) 99,999 atoms, ~62 chains, 9,999 resseq/chain, single-char chain id
BinaryCIF (.bcif, .bcif.gz) Compact binary transport at bandwidth/scale; the current binary format An ecosystem still expects the retired MMTF None (lossless mmCIF encoding)
MMTF (.mmtf) Nothing new -- RCSB stopped serving MMTF on 2 July 2024 Any live download (the endpoint is decommissioned); treat as read-only-legacy Retired upstream

Decision: Bio.PDB vs gemmi

Task Tool Why
Hierarchy walk, small X-ray/NMR structure, teaching Bio.PDB Readable SMCRA tree, pure Python, ubiquitous
Read metadata Bio.PDB drops (resolution, method, R-free, assembly ops) Bio.PDB MMCIF2Dict Raw category access without object-model loss
Generate the biological assembly from deposited coords gemmi Applies _pdbx_struct_oper_list; Bio.PDB has no operator-application code
Very large structure (>100k atoms), many structures, fast neighbor search gemmi C++ core scales; Bio.PDB's pure-Python tree is slow/memory-heavy
mmCIF round-trip without data loss (entities, label scheme, ANISOU) gemmi Full PDBx data model; writes hybrid-36 serials when >99,999

Required Imports

from Bio.PDB import PDBParser, MMCIFParser, PDBIO, MMCIFIO, PDBList, Select
from Bio.PDB.MMCIF2Dict import MMCIF2Dict
from Bio.PDB.binary_cif import BinaryCIFParser

Parse an mmCIF File (the modern default)

from Bio.PDB import MMCIFParser

# auth_residues/auth_chains default to True: numbering matches the paper/UniProt.
parser = MMCIFParser(QUIET=True)
structure = parser.get_structure('4hhb', '4hhb.cif')

# label numbering is contiguous 1..N with no insertion codes -- a DIFFERENT scheme.
label_parser = MMCIFParser(QUIET=True, auth_residues=False, auth_chains=False)
label_structure = label_parser.get_structure('4hhb', '4hhb.cif')

Setting `auth_residues

Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • examples/download_structure.py
  • examples/extract_chain.py
  • examples/parse_pdb.py
  • usage-guide.md

FAQ

What does the bio-structural-biology-structure-io skill do?

Reads, writes, downloads, and converts macromolecular structures with Biopython Bio.PDB. Use when choosing a format (mmCIF/PDBx vs legacy PDB vs BinaryCIF) for a structure that may exceed PDB's ~62-chain / 99,999-atom limits; when residue numbers do not match the paper because of auth_* vs label_* numbering (MMCIFParser defaults auth_residues=True); when metadata (resolution, method, R-free) is missing because Bio.PDB drops it and MMCIF2Dict is needed; when the deposited coordinates are the asymmetric unit and the biological assembly must be downloaded separately; when downloading from RCSB (files.rcsb.org, PDBList); and when a legacy MMTF path is dead (RCSB retired MMTF July 2024, use BinaryCIF).

How do I install the bio-structural-biology-structure-io skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the bio-structural-biology-structure-io skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare bio-structural-biology-structure-io with