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