PDB.h

Go to the documentation of this file.
00001 
00007 /*
00008    PDB Class
00009      Given a PDB file name, read in all the data.
00010 */
00011 
00012 #ifndef PDB_H
00013 #define PDB_H
00014 
00015 // These are added to the global namespace:
00016 //   whatever is in PDBData.h
00017 //   the typedef PDBAtomList (a singly linked list of PDBAtom *
00018 //   the class PDB
00019 
00020 #include "parm.h"
00021 #include "ResizeArray.h"
00022 #include "GromacsTopFile.h"
00023 
00024 #include "PDBData.h"
00025 #include "Vector.h"
00026 #include "Lattice.h"
00027 #include "molfile_plugin.h"
00028 
00029 typedef PDBAtom *PDBAtomPtr ;
00030 typedef struct PAL {
00031   PDBAtom *data;
00032   struct PAL *next;
00033 } PDBAtomList;
00034   
00035 class PDB {
00036   private:
00037     PDBAtomList *atomListHead, *atomListTail;
00038 
00039 #ifdef MEM_OPT_VERSION
00040     char *altlocArray;
00041     PDBCoreData *atomArray;
00042 #else
00043     PDBAtom **atomArray;
00044 #endif
00045       // this doesn't create a copy 
00046     void add_atom_element(PDBAtom *newAtom); 
00047     int atomCount;
00048     
00049     ScaledPosition smin, smax;  // extreme edges of the molecular system
00050 
00051     void find_extremes_helper(
00052         SortableResizeArray<BigReal> &coor,
00053         BigReal &min, BigReal &max, Vector rec, BigReal frac
00054         );
00055 
00056   public:
00057     PDB(const char *pdbfilename);   // read in PDB from a file
00058 
00059 #ifdef MEM_OPT_VERSION
00060     //read in PDB from a file and eliminate the temporary memory usage of pdb atom list    
00061     PDB(const char *pdbfilename, int expectedNumAtoms); 
00062 #endif
00063 
00064     //Constructor for plugin IO based way of loading atoms' structure
00065     PDB(molfile_plugin_t *pIOHdl, void *pIOFileHdl, int numAtoms, const float *occupancy, const float *bfactor);
00066 
00067     PDB(const char *, Ambertoppar *);  // read AMBER coordinate file
00068 
00069     /* This constructor initializes the PDB data using a Gromacs
00070        coordinate file, generating an error message if the file
00071        can't be parsed or if its contents don't jive with what is in
00072        the topo file <topology>. */
00073     PDB(const char *filename, const GromacsTopFile *topology);
00074 
00075     ~PDB(void);               // clear everything
00076     void write(const char *outfilename, const char *commentline=NULL); // write the coordinates to a file
00077        // the following deals only with ATOMs and HETATMs
00078     int num_atoms( void);
00079 
00080 #ifdef MEM_OPT_VERSION
00081     PDBCoreData *atom(int place);           
00082     char alternatelocation(int place) { return altlocArray[place]; }
00083     
00084     void delPDBCoreData() { delete [] atomArray; atomArray=NULL; } 
00085 #else
00086     PDBAtom *atom(int place); // get the nth atom in the PDB file
00087 #endif    
00088          // return linked list containing all atoms
00089     PDBAtomList *atoms(void ) { return atomListHead; }  
00090 
00091 #if 0
00092         // Find the extreme edges of the molecule
00093     void find_extremes(BigReal *min, BigReal *max, Vector rec,
00094                                                   BigReal frac=1.0) const;
00095 #else
00096     // Find the extreme edges of molecule in scaled coordinates,
00097     // where "frac" sets bounds based on a fraction of the atoms.
00098     void find_extremes(const Lattice &, BigReal frac=1.0);
00099 
00100     // Obtain results after find_extremes().
00101     void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const {
00102       xmin = smin;  xmax = smax;
00103     }
00104 #endif
00105 
00106     void set_all_positions(Vector *);   //  Reset all the positions in PDB
00107 
00108     void get_all_positions(Vector *);   //  Get all positions in PDB
00109 
00110     void get_position_for_atom(Vector *, int); //Get the position for an atom
00111 };
00112 
00113 #endif // PDB_H
00114 

Generated on Sun Nov 19 01:17:14 2017 for NAMD by  doxygen 1.4.7