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

Measure.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2011 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: Measure.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.65 $       $Date: 2011/06/14 21:17:49 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   Code to measure atom distances, angles, dihedrals, etc.
00019  ***************************************************************************/
00020 
00021 #include "ResizeArray.h"
00022 #include "Molecule.h"
00023 
00024 class AtomSel;
00025 class Matrix4;
00026 class MoleculeList;
00027 
00028 #define MEASURE_NOERR                0
00029 #define MEASURE_ERR_NOSEL           -1
00030 #define MEASURE_ERR_NOATOMS         -2
00031 #define MEASURE_ERR_BADWEIGHTNUM    -3
00032 #define MEASURE_ERR_NOWEIGHT        -4
00033 #define MEASURE_ERR_NOCOM           -4
00034 #define MEASURE_ERR_NOMINMAXCOORDS  -4
00035 #define MEASURE_ERR_NORGYR          -4
00036 #define MEASURE_ERR_BADWEIGHTSUM    -5
00037 #define MEASURE_ERR_NOMOLECULE      -6
00038 #define MEASURE_ERR_BADWEIGHTPARM   -7
00039 #define MEASURE_ERR_NONNUMBERPARM   -8
00040 #define MEASURE_ERR_MISMATCHEDCNT   -9
00041 #define MEASURE_ERR_RGYRMISMATCH    -10
00042 #define MEASURE_ERR_NOFRAMEPOS      -11
00043 #define MEASURE_ERR_NONZEROJACOBI   -12
00044 #define MEASURE_ERR_GENERAL         -13
00045 #define MEASURE_ERR_NORADII         -14
00046 #define MEASURE_ERR_BADORDERINDEX   -15
00047 #define MEASURE_ERR_NOTSUP          -16
00048 #define MEASURE_ERR_BADFRAMERANGE   -17
00049 #define MEASURE_ERR_MISMATCHEDMOLS  -18
00050 #define MEASURE_ERR_REPEATEDATOM    -19
00051 #define MEASURE_ERR_NOFRAMES        -20
00052 #define MEASURE_ERR_BADATOMID       -21
00053 #define MEASURE_ERR_BADCUTOFF       -22
00054 #define MEASURE_ERR_ZEROGRIDSIZE    -23
00055 
00056 #define MEASURE_BOND  2
00057 #define MEASURE_ANGLE 3
00058 #define MEASURE_DIHED 4
00059 #define MEASURE_IMPRP 5
00060 #define MEASURE_VDW   6
00061 #define MEASURE_ELECT 7
00062 
00063 // symbolic flags for cluster analysis
00064 enum {MEASURE_DIST_RMSD=0,
00065       MEASURE_DIST_FITRMSD,
00066       MEASURE_DIST_RGYRD,
00067       MEASURE_DIST_CUSTOM,
00068       MEASURE_NUM_DIST};
00069 
00070 extern const char *measure_error(int errnum);
00071 
00072 // apply a matrix transformation to the coordinates of a selection
00073 extern int measure_move(const AtomSel *sel, float *framepos, 
00074                         const Matrix4 &mat);
00075 
00076 // Calculate average position of selected atoms over selected frames
00077 extern int measure_avpos(const AtomSel *sel, MoleculeList *mlist, 
00078                          int start, int end, int step, float *avpos);
00079 
00080 // find the center of the selected atoms in sel, using the coordinates in
00081 // framepos and the weights in weight.  weight has sel->selected elements.
00082 // Place the answer in com.  Return 0 on success, or negative on error.
00083 extern int measure_center(const AtomSel *sel, const float *framepos, 
00084                           const float *weight, float *com);
00085 
00086 // find the dipole of the selected atoms in sel, using the coordinates in
00087 // framepos, and the atom charges.
00088 // Place the answer in dipole.  Return 0 on success, or negative on error.
00089 // Default units are elementary charges/Angstrom.
00090 // Setting unitsdebye to 1 will scale the results by 4.77350732929 (default 0)
00091 // For charged systems the point of reference for computing the dipole is
00092 // selected with usecenter: 
00093 //   1 = geometrical center (default),
00094 //  -1 = center of mass,
00095 //   0 = origin
00096 extern int measure_dipole(const AtomSel *sel, MoleculeList *mlist,
00097                           float *dipole, int unitsdebye, int usecenter);
00098 
00099 // Find the transformation which aligns the atoms of sel1 and sel2 optimally,
00100 // meaning it minimizes the RMS distance between them, weighted by weight.
00101 // The returned matrix will have positive determinant, even if an optimal
00102 // alignment would produce a matrix with negative determinant; the last 
00103 // row in the matrix is flipped to change the sign of the determinant. 
00104 // sel1->selected == sel2->selected == len(weight).
00105 extern int measure_fit(const AtomSel *sel1, const AtomSel *sel2, 
00106                   const float *x, const float *y, const float *weight, 
00107                   const int *order, Matrix4 *mat);
00108 
00109 // compute the axis aligned aligned bounding box for the selected atoms
00110 // returns 0 if success
00111 // returns <0 if not
00112 // If the selection contains no atoms, return {0 0 0} for min and max.
00113 extern int measure_minmax(int num, const int *on, const float *framepos,
00114                           const float *radii, 
00115                           float *min_coord, float *max_coord);
00116 
00117 // Calculate the radius of gyration of the given selection, using the
00118 // given weight, placing the result in rgyr.
00119 extern int measure_rgyr(const AtomSel *sel, MoleculeList *mlist, 
00120                         const float *weight, float *rgyr);
00121 
00122 // Calculate the RMS distance between the atoms in the two selections, 
00123 // weighted by weight.  Same conditions on sel1, sel2, and weight as for
00124 // measure_fit.  
00125 extern int measure_rmsd(const AtomSel *sel1, const AtomSel *sel2,
00126                         int num, const float *f1, const float *f2,
00127                         float *weight, float *rmsd);
00128 
00129 // Calculate RMS fluctuation of selected atoms over selected frames
00130 extern int measure_rmsf(const AtomSel *sel, MoleculeList *mlist, 
00131                         int start, int end, int step, float *rmsf);
00132 
00133 extern int measure_sumweights(const AtomSel *sel, int numweights, 
00134                               const float *weights, float *weightsum);
00135 
00136 
00137 // find the solvent-accessible surface area of atoms in the given selection.
00138 // Use the assigned radii for each atom, and extend this radius by the
00139 // parameter srad to find the points on a sphere that are exposed to solvent.
00140 // Optional parameters (pass NULL to ignore) are:
00141 //   pts: fills the given array with the location of the points that make
00142 //        up the surface.
00143 //   restrictsel: Only solvent accessible points near the given selection will 
00144 //        be considered.
00145 //   nsamples: number of points to use around each atom.
00146 extern int measure_sasa(const AtomSel *sel, const float *framepos,
00147     const float *radius, float srad, float *sasa, ResizeArray<float> *pts,
00148     const AtomSel *restrictsel, const int *nsamples);
00149 
00150 // perform cluster analysis
00151 extern int measure_cluster(AtomSel *sel, MoleculeList *mlist, 
00152                            const int numcluster, const int algorithm,
00153                            const int likeness, const double cutoff,
00154                            int *clustersize, int **clusterlist,
00155                            int first, int last, int step, int selupdate,
00156                            float *weights);
00157 
00158 // perform cluster size analysis
00159 extern int measure_clustsize(const AtomSel *sel, MoleculeList *mlist,
00160                              const double cutoff, int *clustersize,
00161                              int *clusternum, int *clusteridx, 
00162                              int minsize, int numshared, int usepbc);
00163 
00164 // calculate g(r) for two selections
00165 extern int measure_gofr(AtomSel *sel1, AtomSel *sel2,
00166                         MoleculeList *mlist, 
00167                         const int count_h, double *gofr, double *numint, 
00168                         double *histog, const float delta, 
00169                         int first, int last, int step, int *framecntr,
00170                         int usepbc, int selupdate);
00171 
00172 // calculate g(r) for two selections
00173 extern int  measure_rdf(VMDApp *app, 
00174                         AtomSel *sel1, AtomSel *sel2,
00175                         MoleculeList *mlist, 
00176                         const int count_h, double *gofr, double *numint, 
00177                         double *histog, const float delta, 
00178                         int first, int last, int step, int *framecntr,
00179                         int usepbc, int selupdate);
00180 
00181 int measure_geom(MoleculeList *mlist, int *molid, int *atmid, ResizeArray<float> *gValues,
00182                  int frame, int first, int last, int defmolid, int geomtype);
00183 
00184 // calculate the value of this geometry, and return it
00185 int calculate_bond(MoleculeList *mlist, int *molid, int *atmid, float *value);
00186 
00187 // calculate the value of this geometry, and return it
00188 int calculate_angle(MoleculeList *mlist, int *molid, int *atmid, float *value);
00189 
00190 // calculate the value of this geometry, and return it
00191 int calculate_dihed(MoleculeList *mlist, int *molid, int *atmid, float *value);
00192 
00193 // check whether the given molecule & atom index is OK
00194 // if OK, return Molecule pointer; otherwise, return NULL
00195 int check_mol(Molecule *mol, int a);
00196 
00197 // for the given Molecule, find the UNTRANSFORMED coords for the given atom
00198 // return Molecule pointer if successful, NULL otherwise.
00199 int normal_atom_coord(Molecule *m, int a, float *pos);
00200 
00201 int measure_energy(MoleculeList *mlist, int *molid, int *atmid, int natoms, ResizeArray<float> *gValues,
00202                    int frame, int first, int last, int defmolid, double *params, int geomtype);
00203 int compute_bond_energy(MoleculeList *mlist, int *molid, int *atmid, float *energy,
00204                         float k, float x0);
00205 int compute_angle_energy(MoleculeList *mlist, int *molid, int *atmid, float *energy,
00206                          float k, float x0, float kub, float s0);
00207 int compute_dihed_energy(MoleculeList *mlist, int *molid, int *atmid, float *energy,
00208                          float k, int n, float delta);
00209 int compute_imprp_energy(MoleculeList *mlist, int *molid, int *atmid, float *energy,
00210                          float k, float x0);
00211 int compute_vdw_energy(MoleculeList *mlist, int *molid, int *atmid, float *energy,
00212                        float rmin1, float eps1, float rmin2, float eps2, float cutoff, float switchdist);
00213 int compute_elect_energy(MoleculeList *mlist, int *molid, int *atmid, float *energy,
00214                          float q1, float q2, bool flag1, bool flag2, float cutoff);
00215 
00216 // compute matrix that transforms coordinates from an arbitrary PBC cell 
00217 // into an orthonormal unitcell.
00218 int measure_pbc2onc(MoleculeList *mlist, int molid, int frame, const float *center, Matrix4 &transform);
00219 
00220 // does the low level work for the above
00221 void get_transform_to_orthonormal_cell(const float *cell, const float center[3], Matrix4 &transform);
00222 
00223 // get atoms in PBC neighbor cells
00224 int measure_pbc_neighbors(MoleculeList *mlist, AtomSel *sel, int molid,
00225                           int frame, const Matrix4 *alignment,
00226                           const float *center, const float *cutoff, const float *box,
00227                           ResizeArray<float> *extcoord_array,
00228                           ResizeArray<int> *indexmap_array);
00229 
00230 // compute the orthogonalized bounding box for the PBC cell.
00231 int compute_pbcminmax(MoleculeList *mlist, int molid, int frame, 
00232                const float *center, const Matrix4 *transform,
00233                float *min, float *max);
00234 
00235 
00236 // Return the list of atoms within the specified distance of the surface
00237 // where the surface depth is specified by sel_dist, the grid resolution is
00238 // approximately gridsz, and atoms are assume to have size  radius
00239 // If any of a, b, c, alpha, or gamma are zero, assume non-periodic,
00240 // otherwise assume periodic
00241 // returns 0 if success
00242 // returns <0 if not
00243 extern int measure_surface(AtomSel *sel, MoleculeList *mlist,
00244                            const float *framepos, 
00245                            const double gridsz,
00246                            const double radius,
00247                            const double sel_dist,
00248                            int **surface, int *n_surf);
00249 
00250 
00251 // Calculate center of mass, principle axes and moments of inertia for
00252 // selected atoms. The corresponding eigenvalues are also returned, 
00253 // and might tell you if two axes are equivalent.
00254 extern int measure_inertia(AtomSel *sel, MoleculeList *mlist, const float *coor, float rcom[3],
00255                            float priaxes[3][3], float itensor[4][4], float evalue[3]);
00256 

Generated on Fri May 24 01:48:46 2013 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002