Bioplib
Protein Structure C Library
|
Read coordinates from a PDB file. More...
#include "port.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include "SysDefs.h"
#include "MathType.h"
#include "pdb.h"
#include "macros.h"
#include "fsscanf.h"
#include "general.h"
Go to the source code of this file.
Macros | |
#define | READPDB_MAIN |
#define | MAXPARTIAL 8 |
#define | SMALL 0.000001 |
#define | XML_BUFFER 1024 |
#define | XML_SAMPLE 256 |
#define | MAXBUFF 160 |
#define | LOCATION_HEADER 0 |
#define | LOCATION_COORDINATES 1 |
#define | LOCATION_TRAILER 2 |
Functions | |
FILE * | popen (char *, char *) |
int | pclose (FILE *) |
PDB * | blReadPDB (FILE *fp, int *natom) |
PDB * | blReadPDBAll (FILE *fp, int *natom) |
PDB * | blReadPDBAtoms (FILE *fp, int *natom) |
PDB * | blReadPDBOccRank (FILE *fp, int *natom, int OccRank) |
PDB * | blReadPDBAtomsOccRank (FILE *fp, int *natom, int OccRank) |
WHOLEPDB * | blDoReadPDB (FILE *fpin, BOOL AllAtoms, int OccRank, int ModelNum, BOOL DoWhole) |
char * | blFixAtomName (char *name, REAL occup) |
PDB * | blRemoveAlternates (PDB *pdb) |
WHOLEPDB * | blDoReadPDBML (FILE *fpin, BOOL AllAtoms, int OccRank, int ModelNum, BOOL DoWhole) |
BOOL | blCheckFileFormatPDBML (FILE *fp) |
void | blFreeWholePDB (WHOLEPDB *wpdb) |
WHOLEPDB * | blReadWholePDB (FILE *fpin) |
WHOLEPDB * | blReadWholePDBAtoms (FILE *fpin) |
Read coordinates from a PDB file.
This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.
The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.
The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.
This subroutine will read a .PDB file of any size and form a linked list of the protein structure. This list is contained in a linked set of structures of type pdb_entry. The structure is set up by including the file "pdb.h". For details of the structure, see this file.
To free the space created by this routine, call FREELIST(pdb,PDB).
The parameters passed to the subroutine are:
As of V2.3, the routine makes provision for partial occupancies. If the occupancies are 1.0 or 0.0, the atoms are read verbatim. If not, only the highest occupancy atoms are read and the atom names are corrected to remove alternative labels. This behaviour can be overridden by calling one of the ...OccRank() routines to read lower occupancy atoms. If any partial occupancy atoms are read the global flag gPDBPartialOcc is set to TRUE.
The various PDB reading routines set the following global flags: gPDBPartialOcc - the PDB file contained multiple occupancies gPDBMultiNMR - the PDB file contained multiple models gPDBXML - the file was in PDBML (XML) format gPDBModelNotFound - the requested model was not found
NOTE: Although some of the fields are represented by a single character, they are still stored in character arrays.
BUGS: The subroutine cannot read files with VAX Fortran carriage control! It just sits there and page faults like crazy.
BUGS: The multiple occupancy code assumes that all positions for a given atom in consecutive records of the file
BUGS: 25.01.05 Note the multiple occupancy code won't work properly for 3pga where atoms have occupancies of zero and one
[in] | *fp | A pointer to type FILE in which the .PDB file is stored. |
[out] | *natom | Number of atoms read. |
Definition in file ReadPDB.c.
BOOL blCheckFileFormatPDBML | ( | FILE * | fp | ) |
[in] | *fp | A pointer to type FILE. |
Simple test to detect PDBML-formatted pdb file.
Todo: Consider replacement with general function to detect file format for uncompressed file returning file type (eg pdb/pdbml/unknown).
[in] | *fpin | A pointer to type FILE in which the .PDB file is stored. |
[in] | AllAtoms | TRUE: ATOM & HETATM records FALSE: ATOM records only |
[in] | OccRank | Occupancy ranking |
[in] | ModelNum | NMR Model number (0 = all) |
[in] | DoWhole | Read the whole PDB file rather than just the ATOM/HETATM records. |
Reads a PDB file into a PDB linked list. The OccRank value indicates occupancy ranking to read for partial occupancy atoms. If any partial occupancy atoms are read the global flag gPDBPartialOcc is set to TRUE.
21.07.15 Changed atomType to atomInfo By: ACRM
We need to deal with freeing wpdb if we are returning null. Also need to deal with some sort of error code
[in] | *fpin | A pointer to type FILE in which the .PDB file is stored. |
[in] | AllAtoms | TRUE: ATOM & HETATM records FALSE: ATOM records only |
[in] | OccRank | Occupancy ranking |
[in] | ModelNum | NMR Model number (0 = all) |
[in] | DoWhole | Read the whole PDB file rather than just the ATOM/HETATM records. |
Reads a PDBML-formatted PDB file into a PDB linked list.
The OccRank value indicates occupancy ranking to read for partial occupancy atoms. If any partial occupancy atoms are read the global flag gPDBPartialOcc is set to TRUE.
The global multiple-models flag is set to true if more than one model is found.
Returns NULL if memory allocation fails or returns wpdb with wpdb->pdb set to NULL and wpdb->natoms set to -1.
char* blFixAtomName | ( | char * | name, |
REAL | occup | ||
) |
[in] | *name | Atom name read from file |
[in] | occup | Occupancy to allow fixing of partial occupancy atom names |
Fixes an atom name by removing leading spaces, or moving a leading digit to the end of the string. Used by doReadPDB()
void blFreeWholePDB | ( | WHOLEPDB * | wpdb | ) |
[in] | *wpdb | WHOLEPDB structure to be freed |
Frees the header, trailer and atom content from a WHOLEPDB structure
PDB* blReadPDB | ( | FILE * | fp, |
int * | natom | ||
) |
[in] | *fp | A pointer to type FILE in which the .PDB file is stored. |
[out] | *natom | Number of atoms read. -1 if error. |
Reads a PDB file into a PDB linked list
PDB* blReadPDBAll | ( | FILE * | fp, |
int * | natom | ||
) |
[in] | *fp | A pointer to type FILE in which the .PDB file is stored. |
[out] | *natom | Number of atoms read. -1 if error. |
Reads a PDB file into a PDB linked list. Reads all partial occupancy atoms. Reads both ATOM and HETATM records.
PDB* blReadPDBAtoms | ( | FILE * | fp, |
int * | natom | ||
) |
[in] | *fp | A pointer to type FILE in which the .PDB file is stored. |
[out] | *natom | Number of atoms read. -1 if error. |
Reads a PDB file into a PDB linked list. Atoms only (no HETATM cards).
PDB* blReadPDBAtomsOccRank | ( | FILE * | fp, |
int * | natom, | ||
int | OccRank | ||
) |
[in] | *fp | A pointer to type FILE in which the .PDB file is stored. |
[in] | OccRank | Occupancy ranking (>=1) |
[out] | *natom | Number of atoms read. -1 if error. |
Reads a PDB file into a PDB linked list ignoring HETATM records and selecting the OccRank'th highest occupancy atoms
PDB* blReadPDBOccRank | ( | FILE * | fp, |
int * | natom, | ||
int | OccRank | ||
) |
[in] | *fp | A pointer to type FILE in which the .PDB file is stored. |
[in] | OccRank | Occupancy ranking (>=1) |
[out] | *natom | Number of atoms read. -1 if error. |
Reads a PDB file into a PDB linked list selecting the OccRank'th highest occupancy atoms
WHOLEPDB* blReadWholePDB | ( | FILE * | fpin | ) |
[in] | *fpin | File pointer |
Reads a PDB file, storing the header and trailer information as well as the coordinate data. Can read gzipped files as well as uncompressed files.
Coordinate data is accessed as linked list of type PDB as follows:
WHOLEPDB *wpdb; PDB *p; wpdb = ReadWholePDB(fp); for(p=wpdb->pdb; p!=NULL; p=p->next) { ... Do something with p ... }
WHOLEPDB* blReadWholePDBAtoms | ( | FILE * | fpin | ) |
[in] | *fpin | File pointer |
Reads a PDB file, storing the header and trailer information as well as the coordinate data. Can read gzipped files as well as uncompressed files.
Coordinate data is accessed as linked list of type PDB as follows:
WHOLEPDB *wpdb; PDB *p; wpdb = ReadWholePDB(fp); for(p=wpdb->pdb; p!=NULL; p=p->next) { ... Do something with p ... }
[in,out] | *pdb | PDB |
Remove alternate atoms - we keep only the highest occupancy or the first if there are more than one the same.
int pclose | ( | FILE * | ) |
FILE* popen | ( | char * | , |
char * | |||
) |