35        "HEADER", 
"OBSLTE", 
"COMPND",
    36        "SOURCE", 
"EXPDTA", 
"AUTHOR", 
"REVDAT", 
"SPRSDE", 
"JRNL",
    37        "REMARK", 
"SEQRES", 
"FTNOTE", 
"HET", 
"FORMUL", 
"HELIX",
    38        "SHEET", 
"TURN", 
"SSBOND", 
"SITE", 
"CRYST1", 
"ORIGX",
    39        "SCALE", 
"MTRIX", 
"TVECT", 
"MODEL", 
"ATOM", 
"HETATM",
    40        "SIGATM", 
"ANISOU", 
"SIGUIJ", 
"TER", 
"ENDMDL", 
"CONECT",
    41        "MASTER", 
"END", 
"UNKNOWN"};
    63   strncpy(tempbuffer, data + start-1, size);  
    66   for (
int i=strlen(tempbuffer)-1; i>=0; i--) { 
    67     if (tempbuffer[i]>
' ') {
    75   *ans = atoi(tempbuffer);
    81 void PDBData::scan( 
const char *data, 
int length, 
int start, 
int size, 
char *ans)
    87   strncpy(ans, data + start - 1, size);
    91   for (i=0,j=0; ans[i]; i++)  
    92     if (ans[i]!=
' ' && ans[i]!=
'\t')   
   100   char tempbuffer[200];
   101   if (length < start) {               
   107   strncpy(tempbuffer, data + start - 1, size);
   110   for (
int i=strlen(tempbuffer)-1; i>=0; i--) { 
   111     if (tempbuffer[i]>
' ') {
   119     *ans = atof(tempbuffer);  
   143   for (i=0; data[i]; i++)
   144     if (!onword && data[i] != 
' ' && data[i] != 
'\t')  {  
   149       if (onword && (data[i] == 
' ' || data[i] == 
'\t')) { 
   160   while (data[i] != 
' ' && data[i] != 
'\t' && data[i])
   161      result[cpy++] = data[i++];
   172  sprintf(temps, 
"%*d", len, val);  
   179  sprintf(temps, 
"%*.*f", len, prec, val);
   186  while (len-- >0 && *val)  
   196  field(data, 1, tempstr);  
   197  if (tempstr[0] == 
'#')  {
   198    parse_field_data(data);
   200    parse_column_data(data);
   235 void PDBAtom::parse_column_data( 
const char *data)
   237  int len = strlen(data);  
   269     if (s[0] < 
'0' || s[0] > 
'9') {
   270        static int elvis_count = 0;
   271        int num = (s[0] - 
'A') * 1000 + 10000;
   273        if (s[0] < 
'A' || s[0] > 
'Z') {
   274           if (elvis_count == 0) {
   275      iout << 
iWARN << 
"Man, tiny Elvis, that number is huge!\n"   276      << 
iWARN << 
"We don't know how X-Plor represents over Z999 residues\n"   277      << 
iWARN << 
"And you just tried " << s << 
" - so we'll fake it as " << num << 
"\n"   278      << 
iWARN << 
"This is reversible, but only inside this program.\n" << 
endi;
   325 void PDBAtom::parse_field_data( 
const char *data)
   330   field(data, 3, tempstr);
   333   field(data, 4, tempstr);
   334   name( tempstr[0] != 
'#' ? tempstr : 
"" );
   336   field(data, 5, tempstr);
   339   field(data, 6, tempstr);
   342   field(data, 7, tempstr);
   343   chain( tempstr[0] != 
'#' ? tempstr : 
"" );
   345   field(data, 8, tempstr);
   348   field(data, 9, tempstr);
   351   field(data, 10, tempstr);
   352   xcoor( tempstr[0] != 
'#' ?
   354   field(data, 11, tempstr);
   355   ycoor( tempstr[0] != 
'#' ?
   357   field(data, 12, tempstr);
   358   zcoor( tempstr[0] != 
'#' ?
   361   field(data, 13, tempstr);
   365   field(data, 14, tempstr);
   369   field(data, 15, tempstr);
   372   field(data, 16, tempstr);
   375   field(data, 17, tempstr);
   376   element( tempstr[0] != 
'#' ? tempstr : 
"");
   381 { 
return myserialnumber; }
   383 { myserialnumber = newserialnumber; }
   389 { strncpy(myname, newname, 
LNAME); myname[
LNAME]=0; }
   393 { 
return myalternatelocation; }
   395 { strncpy(myalternatelocation, newalternatelocation, 
LALT);
   396   myalternatelocation[
LALT]=0;}
   400 { 
return myresiduename; }
   402 { strncpy(myresiduename, newresiduename, 
LRESNAME); myresiduename[
LRESNAME]=0;}
   408 { strncpy(mychain, newchain, 
LCHAIN); mychain[
LCHAIN]=0;}
   412 { 
return myresidueseq; }
   414 { myresidueseq = newresidueseq; }
   418 { 
return myinsertioncode; }
   420 { strncpy(myinsertioncode, newinsertioncode, 
LINSERT); 
   426 { 
return mycoor[0]; }
   428 { mycoor[0] = newxcoor; }
   430 { 
return mycoor[1]; }
   432 { mycoor[1] = newycoor; }
   434 { 
return mycoor[2]; }
   436 { mycoor[2] = newzcoor; }
   441 { 
for (
int i=0; i<3; i++) mycoor[i] = newcoordinates[i]; }
   445 { 
return myoccupancy ;}
   447 { myoccupancy = newoccupancy; }
   451 { 
return mytemperaturefactor; }
   453 { mytemperaturefactor = newtemperaturefactor; }
   457 { 
return myfootnote; }
   459 { myfootnote = newfootnote; }
   465 { 
return mysegmentname; }
   467 { strncpy(mysegmentname, newsegmentname, 
LSEGNAME); mysegmentname[
LSEGNAME]=0;}
   471 { 
return myelement; }
   478 void PDBAtom::sprint_columns( 
char *outstr)
   491      if (strlen(
name()) == 4) {
   509         sprintf(s, 
"%c%03d", 
'A' + val, modulo);
   527   int lelement = strlen(
element());
   533 void PDBAtom::sprint_fields( 
char *outstr)
   538       sprintf(tmpstr, 
" #");
   541   strcat(outstr, tmpstr);
   543       sprintf(tmpstr, 
" #");
   545       sprintf(tmpstr, 
" %s", 
name());
   546   strcat(outstr, tmpstr);
   548       sprintf(tmpstr, 
" #");
   551   strcat(outstr, tmpstr);
   553       sprintf(tmpstr, 
" #");
   556   strcat(outstr, tmpstr);
   558       sprintf(tmpstr, 
" #");
   560       sprintf(tmpstr, 
" %s", 
chain());
   561   strcat(outstr, tmpstr);
   563       sprintf(tmpstr, 
" #");
   566   strcat(outstr, tmpstr);
   568       sprintf(tmpstr, 
" #");
   571   strcat(outstr, tmpstr);
   573       sprintf(tmpstr, 
" #");
   576   strcat(outstr, tmpstr);
   578       sprintf(tmpstr, 
" #");
   581   strcat(outstr, tmpstr);
   583       sprintf(tmpstr, 
" #");
   586   strcat(outstr, tmpstr);
   591   strcat(outstr, tmpstr);
   596   strcat(outstr, tmpstr);
   598     sprintf(tmpstr, 
" #");
   600     sprintf(tmpstr, 
" %d",  
footnote() );         
   601   strcat(outstr, tmpstr);
   603       sprintf(tmpstr, 
" #");
   606   strcat(outstr, tmpstr);
   608       sprintf(tmpstr, 
" #");
   610       sprintf(tmpstr, 
" %s", 
element());
   611   strcat(outstr, tmpstr);
   618    sprint_columns( outstr);
   620    sprint_fields( outstr);
   629   sscanf(data, 
"%s %s ", temps1, temps2);
   630   if (temps1[0] == 
'#')
   656 #ifdef TEST_PDBREADER   660   PDBAtomRecord atom(
"ATOM   6312  CB TALA 3 235I     24.681  54.463 137.827  1.00 51.30      VP3");
   662   std::cout << tempstr << 
'\n';
   664   std::cout << tempstr << 
'\n';
   665   std::cout << 
"Serial number : "  << atom.serialnumber()         <<  
"\n";
   666   std::cout << 
"name          : '" << atom.name()                 <<  
"'\n";
   667   std::cout << 
"alt. location : '" << atom.alternatelocation()    <<  
"'\n";
   668   std::cout << 
"residue name  : '" << atom.residuename()          <<  
"'\n";
   669   std::cout << 
"chain         : '" << atom.chain()                <<  
"'\n";
   670   std::cout << 
"residue seq   : "  << atom.residueseq()           <<  
"\n";
   671   std::cout << 
"insertion code: '" << atom.insertioncode()        << 
"'\n";
   672   std::cout << 
"X coordinate  : "  << atom.xcoor()                <<  
"\n";
   673   std::cout << 
"Y coordinate  : "  << atom.ycoor()                << 
"\n";
   674   std::cout << 
"Z coordinate  : "  << atom.zcoor()                << 
"\n";
   675   std::cout << 
"occupancy     : "  << atom.occupancy()            << 
"\n";
   676   std::cout << 
"temperature factor: " << atom.temperaturefactor() << 
"\n";
   677   std::cout << 
"footnote      : " << atom.footnote()              << 
"\n";
   678   std::cout << 
"segment name  : '" << atom.segmentname()          << 
"'\n";
   679   std::cout << 
"element       : '" << atom.element()              << 
"'\n";
   682   PDBAtomRecord atom2(
"# ATOM 6312 CB T ALA 3 235 I 24.681 54.463 137.827 1.00 51.30 # VP3");
   684   std::cout << tempstr << 
'\n';
   686   std::cout << tempstr << 
'\n';
   687   std::cout << 
"Serial number : "  << atom2.serialnumber()         <<  
"\n";
   688   std::cout << 
"name          : '" << atom2.name()                 <<  
"'\n";
   689   std::cout << 
"alt. location : '" << atom2.alternatelocation()    <<  
"'\n";
   690   std::cout << 
"residue name  : '" << atom2.residuename()          <<  
"'\n";
   691   std::cout << 
"chain         : '" << atom2.chain()                <<  
"'\n";
   692   std::cout << 
"residue seq   : "  << atom2.residueseq()           <<  
"\n";
   693   std::cout << 
"insertion code: '" << atom2.insertioncode()        << 
"'\n";
   694   std::cout << 
"X coordinate  : "  << atom2.xcoor()                <<  
"\n";
   695   std::cout << 
"Y coordinate  : "  << atom2.ycoor()                << 
"\n";
   696   std::cout << 
"Z coordinate  : "  << atom2.zcoor()                << 
"\n";
   697   std::cout << 
"occupancy     : "  << atom2.occupancy()            << 
"\n";
   698   std::cout << 
"temperature factor: " << atom2.temperaturefactor() << 
"\n";
   699   std::cout << 
"footnote      : " << atom2.footnote()              << 
"\n";
   700   std::cout << 
"segment name  : '" << atom2.segmentname()          << 
"'\n";
   701   std::cout << 
"element       : '" << atom2.element()              << 
"'\n";
   705   PDBAtomRecord atom3(
"# ATOM # # Q WER # # # # 123.456 # # # 9 LAST anything?");
   707   std::cout << tempstr << 
'\n';
   709   std::cout << tempstr << 
'\n';
   710   std::cout << 
"Serial number : "  << atom3.serialnumber()         <<  
"\n";
   711   std::cout << 
"name          : '" << atom3.name()                 <<  
"'\n";
   712   std::cout << 
"alt. location : '" << atom3.alternatelocation()    <<  
"'\n";
   713   std::cout << 
"residue name  : '" << atom3.residuename()          <<  
"'\n";
   714   std::cout << 
"chain         : '" << atom3.chain()                <<  
"'\n";
   715   std::cout << 
"residue seq   : "  << atom3.residueseq()           <<  
"\n";
   716   std::cout << 
"insertion code: '" << atom3.insertioncode()        << 
"'\n";
   717   std::cout << 
"X coordinate  : "  << atom3.xcoor()                <<  
"\n";
   718   std::cout << 
"Y coordinate  : "  << atom3.ycoor()                << 
"\n";
   719   std::cout << 
"Z coordinate  : "  << atom3.zcoor()                << 
"\n";
   720   std::cout << 
"occupancy     : "  << atom3.occupancy()            << 
"\n";
   721   std::cout << 
"temperature factor: " << atom3.temperaturefactor() << 
"\n";
   722   std::cout << 
"footnote      : " << atom3.footnote()              << 
"\n";
   723   std::cout << 
"segment name  : '" << atom3.segmentname()          << 
"'\n";
   724   std::cout << 
"element       : '" << atom3.element()              << 
"'\n";
 
static const BigReal default_coor
 
static const int no_footnote
 
static const BigReal default_temperaturefactor
 
static void field(const char *data, int fld, char *result)
 
BigReal temperaturefactor(void)
 
const char * insertioncode(void)
 
static const char * PDBNames[UNKNOWN+1]
 
std::ostream & endi(std::ostream &s)
 
std::ostream & iWARN(std::ostream &s)
 
const char * residuename(void)
 
static void sprintcol(char *s, int start, int len, const char *val)
 
const BigReal * coordinates(void)
 
const char * alternatelocation(void)
 
static const int default_residueseq
 
void parse(const char *s)
 
int main(int argc, char *argv[])
 
static void scan(const char *data, int len, int start, int size, int *ans, int defalt)
 
PDBData * new_PDBData(const char *data)
 
const char * element(void)
 
void sprint(char *s, PDBFormatStyle usestyle=COLUMNS)
 
static const int default_serial
 
static const BigReal default_occupancy
 
const char * segmentname(void)