Many tasks we are performing in Integrative Modelling involve 3D structures of molecules. Visualising them, modifying them to fit a particular program requirements or just parsing them to analyse them can sometimes be time-consuming.
We are presenting here two approaches to quickly and easily manipulate PDB files.

Shell scripting (based on PDB-tools suite)

Several short and efficient python scripts have been gathered in the PDB-tools repository, developed and maintained by Joao Rodrigues and other contributors within the Computational Structural Group of Pr. Alexandre Bonvin lab. The main strength of these scripts relies on their simplicity of usage and the possibility to concatenate them in a full and complex pipeline, together with basic shell commands if needed, in the same way you pipe your favorite shell commands everyday. Last but not least, this suite of scripts do not required anything else than Python2.7+ and a shell terminal and their installation is really trivial. All the details can be found in the github repository of the project.
Here are few usage examples:

Downloading, extracting a chain and extracting its amino-acid sequence

$ ./pdb_fetch.py 1brs | ./pdb_selchain.py -A | ./pdb_toseq.py > 1brs_A.fasta

Getting general information on a PDB file

$ ./pdb_fetch.py 1brs | ./pdb_wc.py
No. atoms:   4640    (4640.0 per model)
No. residues:    588 (588.0 per model)
No. chains:  6   ( 6.0 per model)
No. models:  1
Hetero Atoms:    Yes
Has seq. gaps:   Yes
Double Occ.: Yes
Insertions:  No
$ ./pdb_fetch.py -biounit 1brs | ./pdb_wc.py
No. atoms:   1559    (1559.0 per model)
No. residues:    195 (195.0 per model)
No. chains:  2   ( 2.0 per model)
No. models:  2
Hetero Atoms:    Yes
Has seq. gaps:   Yes
Double Occ.: Yes
Insertions:  No

Finding gaps in a PDB

$ ./pdb_fetch.py -biounit 1brs | ./pdb_gap.py
D:THR63 < 4.88A > D:GLY66

PyMol ‘alter’ command

If you prefer to go through a 3D viewer, PyMol is a nice alternative to edit a PDB structure. More specifically, the ‘alter’ command, allows you to sequentially modify chain IDs or renumber a whole PDB. It can also be used in a more complete pipeline to change the representation (like vdw radius) of a selection of atoms based on their distance to a specific residue for instance. Possibilities are quite huge and you will know better than us the different steps that will lead to your next journal quality picture!
Few examples (you can find other example and a more complete definition of the command on its PyMol wiki page):

Change chain label and residue index

alter (chain A), chain='B'
alter (all), resi = str(int(resi) + 100)
sort

Change the b values of all atoms to the distance of the atoms to a reference point

# reference point
x0,y0,z0 = [1,2,3]  
# calculate distance values between the reference point and all the atoms
alldist = []
iterate_state 1, yourstruc, alldist.append(((x-x0)**2.0+(y-y0)**2.0+(z-z0)**2.0)**0.5)
# assign distance values to b-factors 
di = iter(alldist)
alter yourstruc, b = di.next()
# visualize the distances
spectrum b, rainbow, yourstruc

 

Do not hesitate to give us feedback on these tips and tricks by dropping a comment on our forum or directly in the “Leave a reply” field below.