NAMD
PDB.h
Go to the documentation of this file.
1 
7 /*
8  PDB Class
9  Given a PDB file name, read in all the data.
10 */
11 
12 #ifndef PDB_H
13 #define PDB_H
14 
15 // These are added to the global namespace:
16 // whatever is in PDBData.h
17 // the typedef PDBAtomList (a singly linked list of PDBAtom *
18 // the class PDB
19 
20 #include "parm.h"
21 #include "ResizeArray.h"
22 #include "GromacsTopFile.h"
23 
24 #include "PDBData.h"
25 #include "Vector.h"
26 #include "Lattice.h"
27 #include "molfile_plugin.h"
28 
29 typedef PDBAtom *PDBAtomPtr ;
30 typedef struct PAL {
32  struct PAL *next;
33 } PDBAtomList;
34 
35 class PDB {
36  private:
37  PDBAtomList *atomListHead, *atomListTail;
38 
39 #ifdef MEM_OPT_VERSION
40  char *altlocArray;
41  PDBCoreData *atomArray;
42 #else
43  PDBAtom **atomArray;
44  PDBAtom *atomAlloc;
45 #endif
46  // this doesn't create a copy
47  void add_atom_element(PDBAtom *newAtom);
48  int atomCount;
49 
50  ScaledPosition smin, smax; // extreme edges of the molecular system
51 
52  void find_extremes_helper(
54  BigReal &min, BigReal &max, Vector rec, BigReal frac
55  );
56 
57  public:
58  PDB(const char *pdbfilename); // read in PDB from a file
59 
60 #ifdef MEM_OPT_VERSION
61  //read in PDB from a file and eliminate the temporary memory usage of pdb atom list
62  PDB(const char *pdbfilename, int expectedNumAtoms);
63 #endif
64 
65  //Constructor for plugin IO based way of loading atoms' structure
66  PDB(molfile_plugin_t *pIOHdl, void *pIOFileHdl, int numAtoms, const float *occupancy, const float *bfactor);
67 
68  PDB(const char *, Ambertoppar *); // read AMBER coordinate file
69 
70  /* This constructor initializes the PDB data using a Gromacs
71  coordinate file, generating an error message if the file
72  can't be parsed or if its contents don't jive with what is in
73  the topo file <topology>. */
74  PDB(const char *filename, const GromacsTopFile *topology);
75 
76  ~PDB(void); // clear everything
77  void write(const char *outfilename, const char *commentline=NULL); // write the coordinates to a file
78  // the following deals only with ATOMs and HETATMs
79  int num_atoms( void);
80 
81 #ifdef MEM_OPT_VERSION
82  PDBCoreData *atom(int place);
83  char alternatelocation(int place) { return altlocArray[place]; }
84 
85  void delPDBCoreData() { delete [] atomArray; atomArray=NULL; }
86 #else
87  PDBAtom *atom(int place); // get the nth atom in the PDB file
88 #endif
89  // return linked list containing all atoms
90  PDBAtomList *atoms(void ) { return atomListHead; }
91 
92 #if 0
93  // Find the extreme edges of the molecule
94  void find_extremes(BigReal *min, BigReal *max, Vector rec,
95  BigReal frac=1.0) const;
96 #else
97  // Find the extreme edges of molecule in scaled coordinates,
98  // where "frac" sets bounds based on a fraction of the atoms.
99  void find_extremes(const Lattice &, BigReal frac=1.0);
100 
101  // Obtain results after find_extremes().
102  void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const {
103  xmin = smin; xmax = smax;
104  }
105 #endif
106 
107  void set_all_positions(Vector *); // Reset all the positions in PDB
108 
109  void get_all_positions(Vector *); // Get all positions in PDB
110 
111  void get_position_for_atom(Vector *, int); //Get the position for an atom
112 };
113 
114 #endif // PDB_H
115 
Definition: PDB.h:35
void get_position_for_atom(Vector *, int)
Definition: PDB.C:352
Definition: PDB.h:30
Definition: Vector.h:64
void write(const char *outfilename, const char *commentline=NULL)
Definition: PDB.C:261
PDBAtom * PDBAtomPtr
Definition: PDB.h:29
void set_all_positions(Vector *)
Definition: PDB.C:331
int num_atoms(void)
Definition: PDB.C:323
PDBAtomList * atoms(void)
Definition: PDB.h:90
PDBAtom * data
Definition: PDB.h:31
struct PAL * next
Definition: PDB.h:32
PDBAtom * atom(int place)
Definition: PDB.C:394
Definition: parm.h:15
PDB(const char *pdbfilename)
Definition: PDB.C:141
void find_extremes(const Lattice &, BigReal frac=1.0)
Definition: PDB.C:438
~PDB(void)
Definition: PDB.C:242
struct PAL PDBAtomList
void get_all_positions(Vector *)
Definition: PDB.C:366
void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const
Definition: PDB.h:102
double BigReal
Definition: common.h:114