Three small PyMOL scripts for preparing protein structures for design and interface analysis. Each is standalone — drop it next to your structure and run.
Fetches a PDB entry, renumbers all protein chains into one continuous residue series, and merges them into a single chain.
run renumber_and_merge_chains.py
renumber_and_mergeChains 1crn # merge into chain A (default)
renumber_and_mergeChains 1crn, B # merge into chain B
Why this matters: many design and folding tools want a single chain with
monotonic numbering, but deposited structures arrive as multiple chains with
overlapping or gapped numbering. This flattens them. Non-protein content (DNA,
RNA, ligands) is left alone — the chain selection is restricted to
polymer.protein.
Insertion codes are sidestepped by reading residue numbers off name CA and
skipping any resi that isn't purely numeric.
Same operation, but leaves a 3-residue numbering gap between consecutive chains.
run renumber_and_merge_chains_with_gap.py
renumber_and_mergeChainsGap 1crn
Use this variant when the merged chain feeds a structure-prediction or design tool that infers chain breaks from numbering discontinuity. A flat continuous series (the other script) implies the chains are covalently connected, which will make a folding model try to bridge termini that are actually separate. The gap preserves the break.
Given a set of hotspot residues, finds every residue outside a distance shell around them and prints the list sorted by chain and residue number.
pymol -cq hotspot_selection.pyEdit the top of main() to set your inputs:
pdb_file = "myprotein.pdb"
hotspot_res_list = ["A/10", "A/25", "A/100"] # chain/resi
threshold = 5.0 # AngstromsThe selection uses byres, so whole residues are returned rather than stray
atoms. Handy for building the "everything I'm allowed to redesign" set — the
complement of the interface — e.g. as a fixed/mutable residue mask for
ProteinMPNN or an RFdiffusion contig.
There's a commented-out block at the end that renumbers the selected residues
consecutively via cmd.alter. It's off by default because the script is usually
wanted for the residue list alone; uncomment it if you want the structure
modified in place.
PyMOL with Python scripting — open-source build is fine:
conda install -c conda-forge pymol-open-sourceThe two renumber_and_merge_* scripts call cmd.fetch, so they need network
access to pull from RCSB. Point them at a local file with cmd.load instead if
you're working offline.
MIT — see LICENSE.