PDB File Format Explained: ATOM, HETATM and Columns
Skip to content

PDB File Format Explained: ATOM, HETATM and Every Column

PDB File Format Explained: ATOM, HETATM and Every Column

A PDB file is a fixed-column text format: every ATOM (standard residue) or HETATM (ligand, ion, water) line stores one atom, with its name in columns 13 to 16, residue name in 18 to 20, chain ID in 22, residue number in 23 to 26, X/Y/Z coordinates in 31 to 54, occupancy in 55 to 60, B-factor in 61 to 66 and element in 77 to 78. Read it by column position, never by spaces.

Most first-week failures in docking and molecular dynamics are not software bugs. A pdb2gmx run that stops with “residue not found”, a receptor that AutoDock Vina tools refuse to convert, or a protein that suddenly has two copies of a lysine side chain all come from a structure file the student has not read line by line. This guide walks the format as the wwPDB Format v3.3 coordinate section defines it, using real lines from real entries, and ends with the five faults to fix before any preparation step.

The examples use four entries you can download yourself from RCSB: 1HSG (HIV-1 protease with the inhibitor MK1, 2.00 Å), 4LZT (hen egg-white lysozyme at 0.95 Å), 2PTC (beta-trypsin with BPTI) and 1L2Y (the Trp-cage miniprotein, solved by solution NMR). If you have never downloaded a structure, start with our guide on how to download a protein structure from RCSB PDB.

What is inside a PDB file, record by record?

A PDB file is a list of 80-character lines. The first six characters name the record type, and the rest of the line is interpreted according to that type. You will meet these records most often:

  • HEADER, TITLE, COMPND, SOURCE: what the molecule is and where it came from. 1HSG’s COMPND line reads MOLECULE: HIV-1 PROTEASE.
  • REMARK 2: resolution. For 1HSG it is RESOLUTION. 2.00 ANGSTROMS.
  • REMARK 465 and REMARK 470: residues and atoms that were in the sample but were not modelled. These are your missing loops and truncated side chains.
  • SEQRES: the full sequence of each chain, including the residues that REMARK 465 says are missing.
  • HET, HETNAM, FORMUL: the ligands and other non-standard groups. 1HSG’s HETNAM line names MK1 as N-[2(R)-HYDROXY-1(S)-INDANYL]-5-[(2(S)-TERTIARY..., the inhibitor better known as indinavir.
  • CRYST1: unit-cell dimensions and space group for crystal structures.
  • ATOM and HETATM: the coordinates. This is the part every program actually reads.
  • TER: marks the end of the ATOM/HETATM list for one chain.
  • MODEL and ENDMDL: wrap each model in a multi-model file, which is the normal layout for NMR ensembles.
  • CONECT: explicit bonds, mainly for HETATM groups.
  • END: the last line.

Docking and MD preparation tools mostly ignore the header. You should not. REMARK 465 tells you if you need to model missing residues and loops before you simulate, and REMARK 2 tells you how much to trust the coordinates.

How do you read an ATOM line column by column?

Here are the first three ATOM lines of 1HSG, exactly as RCSB serves them:

ATOM      1  N   PRO A   1      29.361  39.686   5.862  1.00 38.10           N
ATOM      2  CA  PRO A   1      30.307  38.663   5.319  1.00 40.62           C
ATOM      3  C   PRO A   1      29.760  38.071   4.022  1.00 42.64           C

Each field sits at a fixed position. This table is the column layout from the wwPDB v3.3 specification:

ColumnsFieldExample (1HSG atom 2)What it means in practice
1 to 6Record nameATOMATOM for standard residues, HETATM for ligands, ions, waters, modified residues
7 to 11Atom serial2Running atom number, 5 digits, so 99,999 at most
13 to 16Atom nameCAAlpha carbon here, matched against force-field residue templates
17altLoc(blank)Alternate conformation label, usually A or B
18 to 20Residue namePROThree-letter code; ligands use their Chemical Component code (MK1)
22Chain IDAOne character only
23 to 26Residue number1Author numbering, not always starting at 1 and not always continuous
27Insertion code(blank)Letter that lets two residues share one number (184, 184A)
31 to 54X, Y, Z30.307 38.663 5.319Cartesian coordinates in ångströms, 8.3 format each
55 to 60Occupancy1.00Fraction of molecules in the crystal with the atom at this position
61 to 66B-factor40.62Temperature factor, a measure of positional uncertainty or motion
77 to 78ElementCElement symbol, right-justified; the safest way to tell atom types apart
79 to 80Charge(blank)Formal charge such as 2+ or 1-, blank in most files

Two details catch beginners. First, the atom name field has its own alignment rule. The spec states that a one-letter element name such as C starts at column 14, while a two-letter name such as FE starts at column 13. That is how a reader tells the alpha carbon CA from a calcium ion CA . Hand-edited files that shift these by one column are a classic cause of a calcium being read as carbon, or the reverse. The element column at 77 to 78 removes the ambiguity, so make sure it is filled in (pdb_element assigns it from the atom names if it is empty).

Second, fields can touch. Coordinates are 8 characters wide, so a large negative value fills its field and leaves no space before the next one. A script that does line.split() will then merge two numbers. Always slice by column, for example x = float(line[30:38]) in Python, or use a parser such as Biopython’s PDBParser or the pdb-tools suite (Rodrigues et al., F1000Research, 2018).

What is the difference between ATOM and HETATM?

ATOM records hold the standard polymer residues: the 20 amino acids and the standard nucleotides. HETATM (“hetero atom”) records hold everything else: ligands, cofactors, metal ions, waters and chemically modified residues such as selenomethionine (MSE). In 1HSG the inhibitor appears as:

HETATM 1517  N1  MK1 B 902       9.280  23.763   3.004  1.00 28.25           N

The layout is identical to ATOM; only the record name changes. This matters in practice because many cleaning steps work by record type. Delete all HETATM lines and you remove the ligand, the waters, any structural zinc and any MSE residue at once, which is rarely what you want. 1HSG has 127 water lines (residue name HOH) alongside the single MK1 molecule. To remove only what you mean to remove, filter by residue name. Our guides on removing water molecules from a PDB file and extracting a ligand from a PDB file show both routes.

A quick inventory of residue names, read by column, tells you what is in a file before you touch it:

grep -E '^(ATOM|HETATM)' 1HSG.pdb | cut -c18-20 | sort | uniq -c | sort -rn | head

On 1HSG the top four lines are 208 ILE, 192 LEU, 127 HOH and 112 THR. The counts are atoms, not residues, which is why isoleucine leads.

PDB 1HSG: HIV-1 protease (2 chains, A and B) with indinavir (ligand code MK1) and 127 crystallographic water molecules, at 2.00 Å resolution.
PDB 1HSG: HIV-1 protease (2 chains, A and B) with indinavir (ligand code MK1) and 127 crystallographic water molecules, at 2.00 Å resolution. Source: RCSB PDB entry 1HSG.

What do altLoc and occupancy mean?

When part of a protein exists in two conformations in the crystal, the depositor can model both. Each copy gets a label in column 17 (the altLoc) and an occupancy that says what fraction of molecules adopt it. The spec requires a non-blank altLoc on each of the alternate atomic positions. Here is lysine 1 of the 0.95 Å lysozyme structure 4LZT:

ATOM      8  CE ALYS A   1      -0.975   8.165  10.101  0.67 16.48           C
ATOM      9  CE BLYS A   1      -0.963   8.369  10.347  0.33 11.01           C
ATOM     10  NZ ALYS A   1      -2.393   8.077   9.689  0.67 16.86           N
ATOM     11  NZ BLYS A   1      -0.618   8.282   8.901  0.33 12.77           N

Conformer A has occupancy 0.67 and conformer B has 0.33, and the two add up to 1.00. In a simulation, though, one molecule cannot hold two side chains. If both copies survive into pdb2gmx or a docking prep script, you get duplicated atoms, an error, or a silently wrong structure, depending on the tool. 4LZT has alternate conformations on 14 residues, which adds 19 extra ATOM lines (1,020 ATOM lines before cleaning, 1,001 after).

Keep one conformer before anything else. With pdb-tools (install with pip install pdb-tools):

pdb_selaltloc 4LZT.pdb > 4LZT_clean.pdb      # keeps the highest-occupancy conformer
pdb_selaltloc -A 4LZT.pdb > 4LZT_A.pdb       # keeps conformer A

The default keeps the highest-occupancy position for each atom and removes all altLoc labels, which is the right choice for most docking and MD work. Use pdb_wc -o to check whether a file has alternate locations at all.

Want the guided, hands-on version?

Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.

Join the waitlist (free) →

What does the B-factor column tell you?

The B-factor (temperature factor, columns 61 to 66) describes how smeared out an atom’s electron density is. For an isotropic B-factor, B = 8π²⟨u²⟩, where ⟨u²⟩ is the mean-square displacement of the atom. High values mean a mobile or poorly defined atom; low values mean a well-ordered one. In 1HSG the backbone N, CA and C of proline 1 sit at 38.10, 40.62 and 42.64, typical of a chain terminus.

Three practical uses follow. Surface loops with very high B-factors are less reliable starting points for docking. B-factors are not comparable across entries refined differently, so compare within one structure. And the column is reused by other tools: AlphaFold models store the per-residue confidence score pLDDT in the B-factor field, as described in the AlphaFold Protein Structure Database 2024 update (Varadi et al., Nucleic Acids Research, 2024). A value of 90 in an AlphaFold file means high confidence, the opposite of what 90 means in a crystal structure. See our guide to reading AlphaFold pLDDT and PAE scores before you treat that column as mobility.

What are chain IDs and insertion codes for?

The chain ID in column 22 separates molecules in the file. In 1HSG, chain A and chain B are the two halves of the protease dimer, and the inhibitor is listed under chain B with residue number 902. Only one character is allowed, which limits a legacy PDB file to 62 chains (A to Z, a to z, 0 to 9). If you need just one chain, follow our guide to extracting a single chain from a PDB file.

Insertion codes (column 27) let a structure keep a reference numbering scheme even when its sequence has extra residues. Trypsin in 2PTC uses chymotrypsinogen numbering, so a glycine inserted after residue 184 becomes 184A:

ATOM   1196  N   GLY E 184A     23.158  63.752  24.989  1.00 24.72           N

This is useful for comparing homologous enzymes, but many tools key residues on chain plus number alone. Two residues numbered 184 can collide, and some programs drop or renumber one of them without warning. If your downstream tool does not respect insertion codes, renumber them away and record the mapping in your notes:

pdb_fixinsert 2PTC.pdb > 2PTC_renum.pdb

pdb_fixinsert deletes each insertion code and shifts the numbering of the downstream residues. Your residue numbers will then no longer match published papers on that enzyme, which is why you write the mapping down.

How do multi-model NMR files differ?

NMR structures are usually deposited as an ensemble of models, each wrapped in a MODEL / ENDMDL pair. The Trp-cage entry 1L2Y holds 38 models of a 20-residue peptide, so the file contains 11,552 atom lines for a molecule with 304 atoms. Most docking and MD tools either read only the first model or fail outright. Split the ensemble and pick one model deliberately (often model 1, or the representative model named in the entry):

pdb_selmodel -1 1L2Y.pdb > 1L2Y_model1.pdb

NMR entries have no meaningful REMARK 2 resolution and no B-factors from crystallographic refinement, so do not apply crystal-structure rules of thumb to them.

When should you use mmCIF instead of PDB format?

The legacy format has hard limits built into its columns. The wwPDB v3.3 spec says plainly: “A model cannot have more than 99,999 atoms.” According to the RCSB help page on structures without legacy PDB format files, entries with more than 62 chains, more than 99,999 atom coordinates, multi-character chain IDs, B-factors above 999.99, or five-character ligand codes cannot be written as PDB files at all. Large cryo-EM assemblies, ribosomes and viral capsids often fall in this group and come only as PDBx/mmCIF.

The limit is about to bite more often. The archive already holds over 233,000 structures (Hudson et al., Structural Dynamics, 2025), and four-character PDB IDs are running out. RCSB has announced that from 21 July 2027, new entries receive only 12-character extended IDs (an existing ID such as 1ABC becomes pdb_00001abc), and data deposited after 20 July 2027 will be released only in PDBx/mmCIF and PDBML, with no legacy PDB file generated.

QuestionLegacy PDB formatPDBx/mmCIF
LayoutFixed 80-column linesLabelled key-value pairs and tables
Atom limit per model99,999No practical limit
Chain IDsOne character, 62 chains maximumMulti-character IDs allowed
Ligand codesThree charactersUp to five characters
Status at wwPDBLegacy; not generated for entries deposited after 20 July 2027The archive’s primary format
Best use for a studentInput to AutoDock tools, pdb2gmx and older scriptsDownloading, archiving, large complexes

A sensible habit: download mmCIF as your master copy, and convert to PDB only for the tool that needs it. PyMOL and ChimeraX open both formats and can save a PDB file, and pdb-tools offers a rudimentary pdb_fromcif that refuses to convert files that do not fit the legacy format.

What are the five PDB format faults to fix before docking or MD?

  1. Alternate locations left in. Symptom: duplicated side-chain atoms, odd pdb2gmx complaints, two overlapping copies in PyMOL. Fix: pdb_selaltloc before any other step.
  2. Unwanted HETATM groups, or wanted ones deleted. Symptom: GROMACS stops with Residue 'MK1' not found in residue topology database (or HOH, SO4, GOL). Fix: remove crystallisation additives and waters by residue name, keep cofactors and structural metals, and parameterise the ligand separately. Our pdb2gmx tutorial and common GROMACS errors guide cover the error in detail.
  3. Hydrogens with names the force field does not expect. Symptom: Atom ... in residue ... was not found in rtp entry. Fix: drop the deposited hydrogens with gmx pdb2gmx -ignh and let pdb2gmx rebuild them, after deciding protonation states for histidines and titratable residues.
  4. Missing residues and atoms. Symptom: chain breaks, a long bond across a gap, or errors about missing atoms. Fix: read REMARK 465 and 470, run pdb_gap to find breaks, then rebuild loops rather than simulating across a hole.
  5. Multiple models or several chains when you need one. Symptom: the docking box covers the wrong copy or MD prep sees 38 overlapping peptides. Fix: pdb_selmodel and pdb_selchain, then pdb_tidy to restore TER and END records.

The AutoDock side has its own receptor-conversion failures, which our guide to AutoDock Vina errors and how to fix them lists. A clean PDB file is the input to the full preparation walk-through in how to prepare a protein and ligand for docking.

How do you check a PDB file is clean before you start?

Run three checks and read the output, which takes under a minute:

pdb_wc 4LZT_clean.pdb        # models, chains, residues, atoms, HETATM, altLocs, insertions
pdb_gap 4LZT_clean.pdb       # chain breaks by distance or numbering
pdb_validate 4LZT_clean.pdb  # ATOM/HETATM lines against the format spec

You want one model, the chains you intended, “Multiple Occ.: False”, the insertion-code line matching what your next tool can handle, and no unexplained gaps. Format validity is not structural quality, so follow it with geometry checks from our guide on how to validate a protein structure.

Reading structure files is step one of the bootcamp syllabus, and it is the foundation of every later stage in the computational biology skills roadmap. The StemSkills Lab team, with more than 10 years in structural bioinformatics, drug design and molecular modelling, sees the same pattern in every cohort: the students who look at their PDB file in a text editor first spend far less time debugging later.

Frequently asked questions

Can I open a PDB file in a text editor?

Yes. A PDB file is plain text with 80-character lines. Use an editor with a monospaced font and column numbers (VS Code, Notepad++, nano), and never let it reflow or convert tabs, because the format depends on exact column positions.

Why does my PDB file have both ATOM and HETATM records for the same chain?

Ligands, ions, waters and modified residues use HETATM even when they belong to a protein chain. A selenomethionine (MSE) inside chain A is a HETATM record. Convert MSE to MET deliberately if your force field has no MSE template, rather than deleting all HETATM lines.

Which altLoc should I keep, A or the highest occupancy?

For most docking and MD work, keep the highest-occupancy conformer, which is the default of pdb_selaltloc. Choose a specific label only when the alternate conformation matters to your question, for example a side chain that changes the shape of the binding site.

Is a high B-factor a problem for docking?

A high B-factor means the atom position is uncertain or mobile. Residues lining your binding site with B-factors far above the rest of the structure deserve caution and are a reason to consider several receptor conformations. Compare values within one structure, not across entries.

Does GROMACS need PDB format?

gmx pdb2gmx is usually given a PDB file, and most GROMACS tutorials assume one. If your entry exists only as mmCIF, open it in PyMOL or ChimeraX and save a PDB file, provided it fits the legacy limits on atoms and chains.

Will old four-character PDB IDs stop working?

No. Existing IDs stay valid and map to the extended form by adding pdb_0000, so 1HSG becomes pdb_00001hsg. The change affects new depositions after July 2027, which will be distributed in PDBx/mmCIF only.

Want the guided, hands-on version?

Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.

Join the waitlist (free) →

Think you know Molecular Docking?
Take the free StemSkills assessment and earn a verifiable certificate you can download and add to your LinkedIn profile.
Start the free assessment

Keep going

MD Simulation at Different Temperatures in GROMACS Set up a 300 K vs 350 K vs 400 K thermal stability study in GROMACS, keep the… SAVES Server Tutorial: ERRAT, Verify3D and PROCHECK Upload a homology or AlphaFold model to SAVES v6.1 and learn to read ERRAT, Verify3D and PROCHECK scores.… TIP3P vs SPC/E vs TIP4P: Which Water Model in GROMACS? Pick the water model your force field was built with. See the pairing rule, real property data and…
See live workshops