Skip to content
Oliver Beckstein edited this page Jul 26, 2019 · 14 revisions

Frequently (or at least sometimes) asked questions about MDAnalysis.

Feel free to add to this file.

Installation

Reading and Writing files

Working with groups of atoms

How do I add a new chain ID to a PDB file?

Based on user list: Add chain IDs to protein files.

For MDAnalysis 0.19.2:

Load the PDB file:

U = mda.Universe("protein.pdb")

Then create a new segment ('T' in this example) and assign the segment to the atoms of interest:

newseg = U.add_Segment(segid='T')
U.select_atoms('bynum 1201:2400').residues.segments = newseg

When you write out the atoms as a PDB file, MDAnalysis will set the ChainID to the segment identifier (or the first letter if you used more than one letter)

U.atoms.write("relabeled.pdb")
Clone this wiki locally