This is a source file to load Brookhaven PDB files.
The format is somewhat complicated. Though the code is stable enough for use, it cannot guarantee to load every PDB file out there. In particular attempts to load non-protein files may well fail.
The PDB structure is semi-opaque. It is intended that it only be accessed through functions in the file pdb.c, but in practise it is hard to support every type of operation anyone might want to do. Therefore the elements of the structure are exposed.
If you enhance or bug fix, please update me at email@example.com
pdb.h exposes a simple interface.
PDB *loadpdb(const char *path, int *err);
Same as load pdb, but pass in an already opened file. Useful if you are piping output.
PDB *floadpdb(FILE *fp, int *err);
void killpdb(PDB *pdb);
int pdb_getNmodels(PDB *pdb);
int pdb_getNchains(PDB *pdb);
int pdb_setmodel(PDB *pdb, int model);
Assert-fails if passed an out of range index.
Get the number of residues in a chain. Index zero-based.
int pdb_getchainlen(PDB *pdb, int chain);
Assert fails if passed a bad chain index.
int pdb_chainindex(PDB *pdb, char *id);
Returns -1 if the named chain is not present.
int pdb_getatom(PDB *pdb, int chain, int residue, char *atom, float *x, float *y, float *z);
Assert fails if passed a bad residue or chain index. If the atom is not present it will return 0. Often files have missing atom records.
Currently there isn't any support for retrieving badly-named atoms in the file.
int pdb_getsequence(PDB *pdb, int chain, char *out);
Assert fails if passed a bad chain index. Buffer must be large enough to hold chain plus terminating NUL.
int pdb_getsecondary(PDB *pdb, int chain, char *out);
Assert fails if passed a bad chain index. Buffer must be big enough to hold chain plus terminating NUL.