Skip to content

Instantly share code, notes, and snippets.

@tbrittoborges
Last active March 20, 2024 09:17
Show Gist options
  • Save tbrittoborges/929ced78855945f3e296 to your computer and use it in GitHub Desktop.
Save tbrittoborges/929ced78855945f3e296 to your computer and use it in GitHub Desktop.
guide to read .pdb files with pandas
import pandas as pd
colspecs = [(0, 6), (6, 11), (12, 16), (16, 17), (17, 20), (21, 22), (22, 26),
(26, 27), (30, 38), (38, 46), (46, 54), (54, 60), (60, 66), (76, 78),
(78, 80)]
names = ['ATOM', 'serial', 'name', 'altloc', 'resname', 'chainid', 'resseq',
'icode', 'x', 'y', 'z', 'occupancy', 'tempfactor', 'element', 'charge']
pdb = pd.read_fwf(pdb_path, names=names, colspecs=colspecs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment