Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

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     PDBCoreData *atomArray;
00041 #else
00042     PDBAtom **atomArray;
00043 #endif
00044       // this doesn't create a copy 
00045     void add_atom_element(PDBAtom *newAtom); 
00046     int atomCount;
00047     
00048     ScaledPosition smin, smax;  // extreme edges of the molecular system
00049 
00050     void find_extremes_helper(
00051         SortableResizeArray<BigReal> &coor,
00052         BigReal &min, BigReal &max, Vector rec, BigReal frac
00053         );
00054 
00055   public:
00056     PDB(const char *pdbfilename);   // read in PDB from a file
00057 
00058 #ifdef MEM_OPT_VERSION
00059     //read in PDB from a file and eliminate the temporary memory usage of pdb atom list    
00060     PDB(const char *pdbfilename, int expectedNumAtoms); 
00061 #endif
00062 
00063     //Constructor for plugin IO based way of loading atoms' structure
00064     PDB(molfile_plugin_t *pIOHdl, void *pIOFileHdl, int numAtoms, const float *occupancy, const float *bfactor);
00065 
00066     PDB(const char *, Ambertoppar *);  // read AMBER coordinate file
00067 
00068     /* This constructor initializes the PDB data using a Gromacs
00069        coordinate file, generating an error message if the file
00070        can't be parsed or if its contents don't jive with what is in
00071        the topo file <topology>. */
00072     PDB(const char *filename, const GromacsTopFile *topology);
00073 
00074     ~PDB(void);               // clear everything
00075     void write(const char *outfilename, const char *commentline=NULL); // write the coordinates to a file
00076        // the following deals only with ATOMs and HETATMs
00077     int num_atoms( void);
00078 
00079 #ifdef MEM_OPT_VERSION
00080     PDBCoreData *atom(int place);           
00081     
00082     void delPDBCoreData() { delete [] atomArray; atomArray=NULL; } 
00083 #else
00084     PDBAtom *atom(int place); // get the nth atom in the PDB file
00085 #endif    
00086          // return linked list containing all atoms
00087     PDBAtomList *atoms(void ) { return atomListHead; }  
00088 
00089 #if 0
00090         // Find the extreme edges of the molecule
00091     void find_extremes(BigReal *min, BigReal *max, Vector rec,
00092                                                   BigReal frac=1.0) const;
00093 #else
00094     // Find the extreme edges of molecule in scaled coordinates,
00095     // where "frac" sets bounds based on a fraction of the atoms.
00096     void find_extremes(const Lattice &, BigReal frac=1.0);
00097 
00098     // Obtain results after find_extremes().
00099     void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const {
00100       xmin = smin;  xmax = smax;
00101     }
00102 #endif
00103 
00104     void set_all_positions(Vector *);   //  Reset all the positions in PDB
00105 
00106     void get_all_positions(Vector *);   //  Get all positions in PDB
00107 
00108     void get_position_for_atom(Vector *, int); //Get the position for an atom
00109 };
00110 
00111 #endif // PDB_H
00112 

Generated on Fri May 25 04:07:16 2012 for NAMD by  doxygen 1.3.9.1