NAMD
Public Types | Public Member Functions | Static Public Attributes | Static Protected Member Functions | List of all members
PDBData Class Reference

#include <PDBData.h>

Inheritance diagram for PDBData:
PDBAtom PDBUnknown PDBAtomRecord PDBHetatm

Public Types

enum  PDBType {
  HEADER, OBSLTE, COMPND, SOURCE,
  EXPDTA, AUTHOR, REVDAT, SPRSDE,
  JRNL, REMARK, SEQRES, FTNOTE,
  HET, FORMUL, HELIX, SHEET,
  TURN, SSBOND, SITE, CRYST1,
  ORIGX, SCALE, MTRIX, TVECT,
  MODEL, ATOM, HETATM, SIGATM,
  ANISOU, SIGUIJ, TER, ENDMDL,
  CONECT, MASTER, END, UNKNOWN
}
 
enum  PDBFormatStyle { COLUMNS, FIELDS }
 

Public Member Functions

 PDBData (PDBType newtype)
 
virtual ~PDBData (void)
 
PDBType type (void)
 
virtual void sprint (char *s, PDBFormatStyle usestyle=COLUMNS)
 

Static Public Attributes

static const char * PDBNames [UNKNOWN+1]
 

Static Protected Member Functions

static void scan (const char *data, int len, int start, int size, int *ans, int defalt)
 
static void scan (const char *data, int len, int start, int size, BigReal *ans, BigReal defalt)
 
static void scan (const char *data, int len, int start, int size, char *ans)
 
static void field (const char *data, int fld, char *result)
 
static void sprintcol (char *s, int start, int len, const char *val)
 
static void sprintcol (char *s, int start, int len, int val)
 *** provide a simple way to print to a specific column More...
 
static void sprintcol (char *s, int start, int len, int prec, BigReal val)
 

Detailed Description

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 33 of file PDBData.h.

Member Enumeration Documentation

Enumerator
COLUMNS 
FIELDS 

Definition at line 48 of file PDBData.h.

48 { COLUMNS, FIELDS }; // used to specify if the
Enumerator
HEADER 
OBSLTE 
COMPND 
SOURCE 
EXPDTA 
AUTHOR 
REVDAT 
SPRSDE 
JRNL 
REMARK 
SEQRES 
FTNOTE 
HET 
FORMUL 
HELIX 
SHEET 
TURN 
SSBOND 
SITE 
CRYST1 
ORIGX 
SCALE 
MTRIX 
TVECT 
MODEL 
ATOM 
HETATM 
SIGATM 
ANISOU 
SIGUIJ 
TER 
ENDMDL 
CONECT 
MASTER 
END 
UNKNOWN 

Definition at line 42 of file PDBData.h.

Constructor & Destructor Documentation

PDBData::PDBData ( PDBType  newtype)
inline

Definition at line 90 of file PDBData.h.

90  {
91  mytype = newtype;
92  }
virtual PDBData::~PDBData ( void  )
inlinevirtual

Definition at line 93 of file PDBData.h.

93  {
94  }

Member Function Documentation

void PDBData::field ( const char *  data,
int  fld,
char *  result 
)
staticprotected

Definition at line 133 of file PDBData.C.

References FALSE, and TRUE.

Referenced by PDBAtom::parse().

134 {
135  int i;
136 
137  Bool onword = FALSE;
138  if (fld<=0) { // ask a stupid question, get a stupid answer
139  result[0]='#';
140  result[1]=0;
141  return;
142  }
143  for (i=0; data[i]; i++)
144  if (!onword && data[i] != ' ' && data[i] != '\t') { // if I found a field
145  onword = TRUE; // mark that I'm on it
146  if (--fld <= 0) // am I done?
147  break;
148  } else {
149  if (onword && (data[i] == ' ' || data[i] == '\t')) { // left a field
150  onword = FALSE; // mark that I left
151  }
152  }
153  if (fld>0) { // oh no, didn't find the field!
154  result[0] = '#';
155  result[1] = 0;
156  return;
157  }
158 
159  int cpy=0; // copy the field to the output
160  while (data[i] != ' ' && data[i] != '\t' && data[i])
161  result[cpy++] = data[i++];
162  result[cpy] = 0; // terminate and I'm done
163 }
#define FALSE
Definition: common.h:118
int Bool
Definition: common.h:133
#define TRUE
Definition: common.h:119
void PDBData::scan ( const char *  data,
int  len,
int  start,
int  size,
int *  ans,
int  defalt 
)
staticprotected

Definition at line 53 of file PDBData.C.

55 {
56  char tempbuffer[200]; // temp. string buffer
57  if (length < start) { // check if the string is long enough
58  *ans = defalt; // return the default
59  return;
60  }
61  if (size>199) // make sure I won't overflow my array
62  size=199;
63  strncpy(tempbuffer, data + start-1, size); // convert the string to an int
64  tempbuffer[size]= 0;
65  int flg=0;
66  for (int i=strlen(tempbuffer)-1; i>=0; i--) { // see if this is a blank string
67  if (tempbuffer[i]>' ') {
68  flg = 1;
69  break;
70  }
71  }
72  if (flg != 1) { // then it was a blank string
73  *ans = defalt;
74  } else {
75  *ans = atoi(tempbuffer);
76  }
77 }
void PDBData::scan ( const char *  data,
int  len,
int  start,
int  size,
BigReal ans,
BigReal  defalt 
)
staticprotected

Definition at line 97 of file PDBData.C.

99 {
100  char tempbuffer[200];
101  if (length < start) { // check if the string is long enough
102  *ans = defalt; // return the default
103  return;
104  }
105  if (size>199) // make sure I won't overflow my array
106  size=199;
107  strncpy(tempbuffer, data + start - 1, size);// convert the string to a BigReal
108  tempbuffer[size]= 0;
109  int flg=0;
110  for (int i=strlen(tempbuffer)-1; i>=0; i--) { // see if this is a blank string
111  if (tempbuffer[i]>' ') {
112  flg = 1;
113  break;
114  }
115  }
116  if (flg != 1) { // then it was a blank string
117  *ans = defalt;
118  } else {
119  *ans = atof(tempbuffer); // WARNING : ASSUMES BigReal <= double!!!
120  }
121 }
void PDBData::scan ( const char *  data,
int  len,
int  start,
int  size,
char *  ans 
)
staticprotected

Definition at line 81 of file PDBData.C.

82 {
83  if (length < start) { // check if the string is long enough
84  ans[0] = 0;
85  return;
86  }
87  strncpy(ans, data + start - 1, size);
88  ans[size]=0;
89  // fix up leading and trailing spaces
90  int i,j;
91  for (i=0,j=0; ans[i]; i++) // all this does is strip out _all_ the
92  if (ans[i]!=' ' && ans[i]!='\t') // spaces -- this is important because I
93  ans[j++]=ans[i]; // check that a string is empty by looking to see if
94  ans[j]=0; // [0] == 0 instead of checking to see if all the elements are spaces
95 }
virtual void PDBData::sprint ( char *  s,
PDBFormatStyle  usestyle = COLUMNS 
)
inlinevirtual

Reimplemented in PDBAtom, and PDBUnknown.

Definition at line 99 of file PDBData.h.

References COLUMNS.

99  {
100  if (usestyle == COLUMNS) // get rid of warning
101  strcpy(s, "REMARK (undefined remark - this is a bug)");
102  else
103  strcpy(s, "REMARK (undefined remark - this is a bug)");
104  }
void PDBData::sprintcol ( char *  s,
int  start,
int  len,
const char *  val 
)
staticprotected

Definition at line 183 of file PDBData.C.

Referenced by sprintcol().

184 {
185  s+=start-1;
186  while (len-- >0 && *val) // copy string up to end of string or len
187  *s++ = *val++;
188 }
void PDBData::sprintcol ( char *  s,
int  start,
int  len,
int  val 
)
staticprotected

*** provide a simple way to print to a specific column

Definition at line 169 of file PDBData.C.

References sprintcol().

170 {
171  char temps[100];
172  sprintf(temps, "%*d", len, val); // convert the int to a string
173  sprintcol( s, start, len, temps); // copy to the output string
174 }
static void sprintcol(char *s, int start, int len, const char *val)
Definition: PDBData.C:183
void PDBData::sprintcol ( char *  s,
int  start,
int  len,
int  prec,
BigReal  val 
)
staticprotected

Definition at line 176 of file PDBData.C.

References sprintcol().

177 {
178  char temps[100];
179  sprintf(temps, "%*.*f", len, prec, val);
180  sprintcol( s, start, len, temps); // copy to the output string
181 }
static void sprintcol(char *s, int start, int len, const char *val)
Definition: PDBData.C:183
PDBType PDBData::type ( void  )
inline

Definition at line 95 of file PDBData.h.

95  {
96  return mytype;
97  }

Member Data Documentation

const char * PDBData::PDBNames
static
Initial value:
= {
"HEADER", "OBSLTE", "COMPND",
"SOURCE", "EXPDTA", "AUTHOR", "REVDAT", "SPRSDE", "JRNL",
"REMARK", "SEQRES", "FTNOTE", "HET", "FORMUL", "HELIX",
"SHEET", "TURN", "SSBOND", "SITE", "CRYST1", "ORIGX",
"SCALE", "MTRIX", "TVECT", "MODEL", "ATOM", "HETATM",
"SIGATM", "ANISOU", "SIGUIJ", "TER", "ENDMDL", "CONECT",
"MASTER", "END", "UNKNOWN"}

Definition at line 52 of file PDBData.h.

Referenced by new_PDBData().


The documentation for this class was generated from the following files: