Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

VolMapCreate.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2009 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: VolMapCreate.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.89 $       $Date: 2009/05/29 16:20:18 $
00015  *
00016  **************************************************************************/
00017 
00018 #include "Matrix4.h"
00019 
00020 // enable multilevel summation by default
00021 #define VMDUSEMSMPOT 1
00022 
00023 class VMDApp;
00024 class VolumetricData;
00025 class AtomSel;
00026 class Molecule;
00027 
00033 
00034 class VolMapCreate {
00035 public:
00036   typedef enum {COMBINE_AVG, COMBINE_MIN, COMBINE_MAX, COMBINE_STDEV, COMBINE_PMF} CombineType;
00037   
00038 protected:
00039   VMDApp *app;
00040   AtomSel *sel;
00041   float delta;            // resolution (same along x, y and z)
00042   int computed_frames;    // frame counter
00043   int checkpoint_freq;    // write checkpoint file every xxx steps
00044   char *checkpoint_name;  // checkpoint file name
00045   bool user_minmax;       // true = user specified a minmax box, false = compute default minmax
00046   float min_coord[3], max_coord[3]; // used to pass user defaults, avoid using for computations!
00047 
00048 protected:
00049   virtual int compute_frame(int frame, float *voldata) = 0;
00050   int compute_init(float padding);
00051   
00053   virtual int compute_init() {return compute_init(0.);}
00054   
00056   int calculate_minmax (float *min_coord, float *max_coord);
00057   
00059   int calculate_max_radius (float &radius);
00060   
00062   void combo_begin(CombineType method, void **customptr, void *params);
00063   void combo_addframe(CombineType method, float *voldata, void *customptr, float *framedata);
00064   void combo_export(CombineType method, float *voldata, void *customptr);
00065   void combo_end(CombineType method, void *customptr);
00066 
00067 
00068 public:
00069   VolumetricData *volmap;
00070   
00071   VolMapCreate(VMDApp *app, AtomSel *sel, float resolution);
00072   virtual ~VolMapCreate();
00073   
00074   void set_minmax (float minx, float miny, float minz, float maxx, float maxy, float maxz);
00075 
00076   void set_checkpoint (int checkpointfreq, char *checkpointname);
00077   
00078   int compute_all(bool allframes, CombineType method, void *params);
00079 
00084   virtual void write_map(const char *filename);
00085 
00086   // We temporarily need our own file writer until we use molfile plugin
00087   int write_dx_file (const char *filename);
00088 
00089 };
00090 
00091 
00092 class VolMapCreateMask: public VolMapCreate {
00093 protected:
00094   int compute_init();
00095   int compute_frame(int frame, float *voldata);
00096 private:
00097   float atomradius;
00098 
00099 public:
00100   VolMapCreateMask(VMDApp *app, AtomSel *sel, float res, float the_atomradius) : VolMapCreate(app, sel, res) {
00101     atomradius = the_atomradius;
00102   }
00103 };
00104 
00105 
00106 class VolMapCreateDensity : public VolMapCreate {
00107 protected:
00108   float *weight;
00109   int compute_init();
00110   int compute_frame(int frame, float *voldata);
00111   float radius_scale; // mult. factor for atomic radii
00112   
00113 public:
00114   VolMapCreateDensity(VMDApp *app, AtomSel *sel, float res, float *the_weight, float the_radscale) : VolMapCreate(app, sel, res) {
00115     weight = the_weight;
00116     // number of random points to use for each atom's gaussian distr.
00117     radius_scale = the_radscale;
00118   }
00119 };
00120 
00121 
00122 class VolMapCreateInterp : public VolMapCreate {
00123 protected:
00124   float *weight;
00125   int compute_init();
00126   int compute_frame(int frame, float *voldata);
00127 
00128 public:
00129   VolMapCreateInterp(VMDApp *app, AtomSel *sel, float res, float *the_weight) : VolMapCreate(app, sel, res) {
00130     weight = the_weight;
00131   }
00132 };
00133 
00134 
00135 class VolMapCreateOccupancy : public VolMapCreate {
00136 private:
00137   bool use_points;
00138 protected:
00139   int compute_init();
00140   int compute_frame(int frame, float *voldata);  
00141 public:
00142   VolMapCreateOccupancy(VMDApp *app, AtomSel *sel, float res, bool use_point_particles) : VolMapCreate(app, sel, res) {
00143     use_points = use_point_particles;
00144   }
00145 };
00146 
00147 
00148 class VolMapCreateDistance : public VolMapCreate {
00149 protected:
00150   float max_dist;
00151   int compute_init();
00152   int compute_frame(int frame, float *voldata);  
00153 public:
00154   VolMapCreateDistance(VMDApp *app, AtomSel *sel, float res, float the_max_dist) : VolMapCreate(app, sel, res) {
00155     max_dist = the_max_dist;
00156   }
00157 };
00158 
00159 
00160 class VolMapCreateCoulombPotential : public VolMapCreate {
00161 protected:
00162   int compute_init();
00163   int compute_frame(int frame, float *voldata);
00164   
00165 public:
00166   VolMapCreateCoulombPotential(VMDApp *app, AtomSel *sel, float res) : VolMapCreate(app, sel, res) {
00167   }
00168 };
00169 
00170 
00171 #if defined(VMDUSEMSMPOT)
00172 class VolMapCreateCoulombPotentialMSM : public VolMapCreate {
00173 protected:
00174   int compute_init();
00175   int compute_frame(int frame, float *voldata);
00176   
00177 public:
00178   VolMapCreateCoulombPotentialMSM(VMDApp *app, AtomSel *sel, float res) : VolMapCreate(app, sel, res) {
00179   }
00180 };
00181 #endif
00182 
00183 
00187 class VolMapCreateILS {
00188 private:
00189   VMDApp *app;
00190   int molid;     // the molecule we are operating on
00191 
00192   int num_atoms; // # atoms in the system
00193 
00194   VolumetricData *volmap;  // our result: the free energy map
00195   VolumetricData *volmask; // mask defining valid gridpoints in volmap
00196 
00197   float delta;        // distance of samples for ILS computation
00198   int   nsubsamp;     // # samples in each dim. downsampled into
00199                       // each gridpoint of the final map.
00200 
00201   // Number of samples used during computation.
00202   int   nsampx, nsampy, nsampz;
00203 
00204   float minmax[6];     // minmax coords of bounding box
00205   float gridorigin[3]; // center of the first grid cell
00206 
00207   float cutoff;        // max interaction dist between any 2 atoms
00208   float extcutoff;     // cutoff corrected for the probe size
00209   float excl_dist;     // cutoff for the atom clash pre-scanning
00210 
00211   bool compute_elec;   // compute electrostatics? (currently unused)
00212 
00213   // Control of the angular spacing of probe orientation vectors:
00214   // 1 means using 1 orientation only
00215   // 2 corresponds to 6 orientations (vertices of octahedron)
00216   // 3 corresponds to 8 orientations (vertices of hexahedron)
00217   // 4 corresponds to 12 orientations (faces of dodecahedron)
00218   // 5 corresponds to 20 orientations (vertices of dodecahedron)
00219   // 6 corresponds to 32 orientations (faces+vert. of dodecah.)
00220   // 7 and above: geodesic subdivisions of icosahedral faces
00221   //              with frequency 1, 2, ...
00222   // Probes with tetrahedral symmetry: 
00223   // # number of rotamers for each of the 8 orientations
00224   // (vertices of tetrahedron and its dual tetrahedron).
00225   //
00226   // Note that the angular spacing of the rotations around
00227   // the orientation vectors is chosen to be about the same
00228   // as the angular spacing of the orientation vector
00229   // itself.
00230   int conformer_freq; 
00231   
00232   int num_conformers;   // # probe symmetry unique orientations and
00233                         // rotations sampled per grid point
00234   float *conformers;    // Stores the precomputed atom positions
00235                         // (relative to the center of mass)
00236                         // of the different probe orientations and
00237                         // rotations.
00238   int num_orientations; // # probe symmetry unique orientations
00239   int num_rotations;    // # symmetry unique rotations sampled
00240                         // per orientation
00241 
00242   // We store the VDW parameters once for each type:
00243   float *vdwparams;       // VDW well depths and radii for all types
00244   int   *atomtypes;       // index list for vdw parameter types
00245 
00246   int   num_unique_types; // # unique atom types
00247 
00248   float temperature;  // Temp. in Kelvin at which the MD sim. was performed
00249 
00250   int num_probe_atoms;  // # atoms in the probe (the ligand)
00251   float  probe_effsize; // effective probe radius
00252   float *probe_coords;  // probe coordinates
00253 
00254   // The two highest symmetry axes of the probe
00255   float probe_symmaxis1[3];
00256   float probe_symmaxis2[3];
00257   int probe_axisorder1, probe_axisorder2;
00258   int probe_tetrahedralsymm; // probe has tetrahedral symmetry flag
00259 
00260   // VDW parameters for the probe:
00261   // A tuple of eps and rmin is stored for each atom.
00262   // Actually we store beta*sqrt(eps) and rmin/2 
00263   // (see function set_probe()).
00264   float *probe_vdw; 
00265   float *probe_charge; // charge for each probe atom
00266 
00267   int first, last;        // trajectory frame range
00268   int computed_frames;    // # frames processed
00269 
00270   float max_energy;   // max energy considered in map, all higher energies
00271                       // will be clamped to this value.
00272   float min_occup;    // occupancies below this value will be treated
00273                       // as zero.
00274 
00275   bool pbc;           // If flag is set then periodic boundaries are taken
00276                       // into account.
00277   bool pbcbox;        // If flag is set then the grid dimensions will be chosen
00278                       // as the orthogonalized bounding box for the PBC cell.
00279   float pbccenter[3]; // User provided PBC cell center.
00280 
00281   AtomSel *alignsel;  // Selection to be used for alignment
00282   const float *alignrefpos; // Stores the alignment reference position
00283 
00284   Matrix4 transform;  // Transformation matrix that was used for the
00285                       // alignment of the first frame.
00286 
00287   int maskonly;       // If set, compute only a mask map telling for which
00288                       // gridpoints we expect valid energies, i.e. the points
00289                       // for which the maps overlap for all frames. 
00290 
00291 
00292   // Check if the box given by the minmax coordinates is located
00293   // entirely inside the PBC unit cell of the given frame and in
00294   // this case return 1, otherwise return 0. 
00295   int box_inside_pbccell(int frame, float *minmax);
00296 
00297   // Check if the entire volmap grid is located entirely inside
00298   // the PBC unit cell of the given frame (taking the alignment
00299   // into account) and in this case return 1, otherwise return 0.
00300   int grid_inside_pbccell(int frame,  float *voldata,
00301                           const Matrix4 &alignment);
00302 
00303   // Set grid dimensions to the minmax coordinates and
00304   // align grid with integer coordinates.
00305   int set_grid();
00306 
00307   // Initialize the ILS calculation
00308   int initialize();
00309 
00310   // ILS calculation for the given frame
00311   int compute_frame(int frame, float *voldata);
00312 
00313   // Align current frame to the reference
00314   void align_frame(Molecule *mol, int frame, float *coords,
00315                    Matrix4 &alignment);
00316 
00317   // Get array of coordinates of selected atoms and their
00318   // neighbors (within a cutoff) in the PBC images.
00319   int get_atom_coordinates(int frame, Matrix4 &alignment,
00320                            int *(&vdwtypes),
00321                            float *(&coords));
00322 
00323   // Check if probe is a linear molecule and returns
00324   // the Cinf axis.
00325   int is_probe_linear(float *axis);
00326 
00327   // Simple probe symmetry check
00328   void check_probe_symmetry();
00329 
00330   // Determine probe symmetry and generate probe orientations
00331   // and rotations.
00332   void initialize_probe();
00333   void get_eff_proberadius();
00334 
00335 
00336   // Generate conformers for tetrahedral symmetry
00337   int gen_conf_tetrahedral(float *(&conform), int freq,
00338                            int &numorient, int &numrot);
00339 
00340   // Generate conformers for all other symmetries
00341   int gen_conf(float *(&conform), int freq,
00342                int &numorient, int &numrot);
00343 
00344   float dimple_depth(float phi);
00345 
00346   // Create list of unique VDW parameters which can be accessed
00347   // through the atomtypes index list. 
00348   int create_unique_paramlist();
00349 
00350 
00351 public:   
00352   VolMapCreateILS(VMDApp *_app, int molid, int firstframe,
00353                   int lastframe, float T, float res, 
00354                   int subr, float cut, int maskonly);
00355   ~VolMapCreateILS();
00356 
00357   VolumetricData* get_volmap() { return volmap; };
00358 
00359   // Perform ILS calculation for all specified frames.
00360   int compute();
00361 
00363   int add_map_to_molecule();
00364 
00367   int write_map(const char *filename);
00368 
00369   // Set probe coordinates,charges and VDW parameters
00370   void set_probe(int num_probe_atoms, int num_conf,
00371                  const float *probe_coords,
00372                  const float *vdwrmin, const float *vdweps,
00373                  const float *charge);
00374 
00375   // Set the two highest symmetry axes for the probe and a flag
00376   // telling if we have a tetrahedral symmetry.
00377   // If the axes are not orthogonal the lower axis will be ignored.
00378   void set_probe_symmetry(int order1, const float *axis1,
00379                           int order2, const float *axis2,
00380                           int tetrahedral);
00381 
00382   // Set minmax coordinates of rectangular molecule bounding box
00383   void set_minmax (float minx, float miny, float minz, float maxx, float maxy, float maxz);
00384 
00385   // Request PBC aware computation.
00386   void set_pbc(float center[3], int bbox);
00387 
00388   // Set maximum energy considered in the calculation.
00389   void set_maxenergy(float maxenergy);
00390 
00391   // Set selection to be used for alignment.
00392   void set_alignsel(AtomSel *asel);
00393 
00394   // Set transformation matrix that was used for the
00395   // alignment of the first frame.
00396   void set_transform(const Matrix4 *mat);
00397 
00398   int get_conformers(float *&conform) const {
00399     conform = conformers;
00400     return num_conformers;
00401   }
00402 
00403   void get_statistics(int &numconf, int &numorient,
00404                       int &numrot) {
00405     numconf   = num_conformers;
00406     numorient = num_orientations;
00407     numrot    = num_rotations;
00408   }
00409 };
00410 
00411 
00412 // Write given map as a DX file.
00413 int volmap_write_dx_file (VolumetricData *volmap, const char *filename);

Generated on Mon Nov 23 01:33:02 2009 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002