NAMD
Functions
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().

625 {
626  char temps1[160];
627  char temps2[160];
628  char *temps;
629  sscanf(data, "%s %s ", temps1, temps2);
630  if (temps1[0] == '#')
631  temps = temps2;
632  else
633  temps = temps1;
634 
635  // go through the list of possible PDB data types
636  //this _should_ be the same as: for(PDBTypes i=HEADER; i<UNKNOWN; i++)
637  for (int i=0; i< (int)(sizeof(PDBData::PDBNames) /
638  sizeof(PDBData::PDBNames[0])); i++)
639  if (!strcmp(temps, PDBData::PDBNames[i]))
640  switch(i) {
641  case PDBData::ATOM: return new PDBAtomRecord(data);
642  case PDBData::HETATM: return new PDBHetatm(data);
643  default: return new PDBUnknown(data);
644  }
645  // Now, if HETATM is right next to an aton number (like HETATM12345) then the above
646  // test will fail, so I have to special case it:
647  if (!strncmp(temps, PDBData::PDBNames[PDBData::HETATM], sizeof(PDBData::PDBNames[PDBData::HETATM]))) {
648  return new PDBHetatm(data);
649  }
650  // Hmm, looks like it isn't any data type, so I'll fake it
651  return new PDBUnknown(data);
652 }
static const char * PDBNames[UNKNOWN+1]
Definition: PDBData.h:52