PDBData.C File Reference

#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include "InfoStream.h"
#include "PDBData.h"

Go to the source code of this file.

Functions

PDBDatanew_PDBData (const char *data)


Function Documentation

PDBData* new_PDBData ( const char *  data  ) 

Definition at line 624 of file PDBData.C.

References PDBData::ATOM, PDBData::HETATM, and PDBData::PDBNames.

Referenced by PDB::PDB().

00625 {
00626   char temps1[160];
00627   char temps2[160];
00628   char *temps;
00629   sscanf(data, "%s %s ", temps1, temps2);
00630   if (temps1[0] == '#')
00631      temps = temps2;
00632     else
00633      temps = temps1;
00634 
00635      // go through the list of possible PDB data types
00636      //this _should_ be the same as: for(PDBTypes i=HEADER; i<UNKNOWN; i++)
00637   for (int i=0; i< (int)(sizeof(PDBData::PDBNames) /
00638                   sizeof(PDBData::PDBNames[0])); i++)
00639     if (!strcmp(temps, PDBData::PDBNames[i]))
00640        switch(i) {
00641          case PDBData::ATOM: return new PDBAtomRecord(data);
00642          case PDBData::HETATM: return new PDBHetatm(data);
00643          default: return new PDBUnknown(data);
00644        }
00645   // Now, if HETATM is right next to an aton number (like HETATM12345) then the above
00646   // test will fail, so I have to special case it:
00647   if (!strncmp(temps, PDBData::PDBNames[PDBData::HETATM], sizeof(PDBData::PDBNames[PDBData::HETATM]))) {
00648     return new PDBHetatm(data);
00649   }
00650    //  Hmm, looks like it isn't any data type, so I'll fake it
00651    return new PDBUnknown(data);
00652 }


Generated on Sat Sep 23 01:17:17 2017 for NAMD by  doxygen 1.4.7