Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Examples

A simple C++ PDB reader


This is a simple C++ PDB reader along with a couple of programs which use it to manipulate pdb files (applying a rigid transform or splitting/merging). The are aimed at people interested in proteins from a geometric viewpoint as they allow easy access to the geometry and bond structure in addition of the biological information. The reader has two modes for reading/writing a pdb file. The simplest one, through the Protein class just reads and writes a single protein from/to a pdb file (which must have only one chain, but can have multiple models). The second, through the PDB class can handle pdb files with multiple models and herogens (although these are just passed through and not currently interpreted).

Once a PDB is read, atom coordinates can be extracted, proteins can be aligned, and cRMS and dRMS can be computed, among other things.

It is designed to be clean and easily modifiable as everyone is likely to have changes they want to make.

The easiest changes to make are to


Once a PDB file is read a dsrpdb::PDB object is created. It contains a number of dsrpdb::Model objects corresponding to each of the models in the PDB file. Each of these contains several dsrpdb::Protein objects once for each chain in the dsrpdb::Model.

Utility Programs

The library includes several utilities

The programs use boost::program_options in order to handle more complicated command line arguments and the pdb_write_distmat program uses Image Magick++ to write images. These dependencies are checked by the configure script. The boost library can be found at (and there are packages for most linux distributions).


Examples for how to use the dsrpdb::Protein and dsrpdb::PDB classes for reading and writing PDB files are detailed with the respective classes. In addition, a program for splitting one pdb containing several models into seperate pdb files is included in the examples section.

Changing the point class

To change the point class just modify dsrpdb::Point in Point.h to be something else by changing Point.h.

Adding a new Atom/Bond

There are several different bits of information which need to be added all except for the first are in The first is in Residue.h.



You can download the code from



Thanks to Nikola for an earlier PDB reader from which I took the bond and atom data. The work was funded by a NSF graduate fellowship.