This file is indexed.

/usr/include/openbabel-2.0/openbabel/grid.h is in libopenbabel-dev 2.3.2+dfsg-3build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/**********************************************************************
grid.h - Handle grids of values.

Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison
Some Portions Copyright (C) 2008 by Marcus D. Hanwell

This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
***********************************************************************/

#ifndef OB_GRID_H
#define OB_GRID_H

#include <openbabel/babelconfig.h>
#include <openbabel/math/vector3.h>
#include <openbabel/base.h>

// Necessary evil for 2.x series -- should use OBMol* below
#include <openbabel/mol.h>

#include <iosfwd>
#include <algorithm>
#include <vector>
#include <string>

namespace OpenBabel
{

  // Forward declaration
  class OBMol;

  //! \class OBGrid grid.h <openbabel/grid.h>
  //! \brief A base grid class
 class OBAPI OBGrid: public OBBase
  {
  protected:
    double _xmin,_xmax,_ymin,_ymax,_zmin,_zmax; //!< the min/max axes in XYZ axes (i.e., the box)

  public:
    OBGrid() {}

    //! \brief Initialize the grid based on a box around the molecule @p box
    //! Subclasses should overload this method -- this only tracks the
    //! dimension of the box itself
    virtual void Init(OBMol &box);

    //! \return the minimum x point of the grid
    double GetXmin() const    { return(_xmin);    }
    //! \return the minimum y point of the grid
    double GetYmin() const    { return(_ymin);    }
    //! \return the minimum z point of the grid
    double GetZmin() const    { return(_zmin);    }
    //! \return the maximum x point of the grid
    double GetXmax() const    { return(_xmax);    }
    //! \return the maximum y point of the grid
    double GetYmax() const    { return(_ymax);    }
    //! \return the maximum z point of the grid
    double GetZmax() const    { return(_zmax);    }

    //! \return whether the supplied XYZ coordinates fall within the box
    bool PointIsInBox(double x,double y,double z)
    {
      return (x>=_xmin) && (x<=_xmax) &&
        (y>=_ymin) && (y<=_ymax) &&
        (z>=_zmin) && (z<=_zmax);
    }
    //! \return true if the point falls within the box
    bool PointIsInBox(double *c)
    {
      return (c[0]>=_xmin) && (c[0]<=_xmax) &&
        (c[1]>=_ymin) && (c[1]<=_ymax) &&
        (c[2]>=_zmin) && (c[2]<=_zmax);
    }

    //! \return true if the point falls within the box
    bool PointIsInBox(vector3 v)
    {
      return (v.x() >= _xmin) && (v.x() <=_xmax) &&
      (v.y()>=_ymin) && (v.y()<=_ymax) &&
      (v.z()>=_zmin) && (v.z()<=_zmax);
    }
  };

  //! \class OBFloatGrid grid.h <openbabel/grid.h>
  //! \brief Handle double precision floating point 3D grids (e.g., charge density around an OBMol)
  //!
  //! Supports input/output and base functionality for simple 3D discrete grids
  //! of some function -- typically around a molecule. Typically you will want
  //! to use OBGridData which uses OBFloatGrid to store its data.
  //! \sa OBGridData
 class OBAPI OBFloatGrid: public OBGrid
  {
  protected:
    std::vector<double> _values;   //!< floating point values
    int   *_ival;             //!< for integer values (deprecated)
    double _midz,_midx,_midy; //!< center of grid in world coordinates
    int _ydim,_xdim,_zdim;    //!< grid dimensions
    double _spacing,_inv_spa; //!< spacing between grid points and its inverse
    double _halfSpace;        //!< half of the grid spacing
    //! Three axes (i.e., translation vectors like a unit cell)
    vector3 _xAxis, _yAxis, _zAxis;

  public:

    OBFloatGrid() : _ival(NULL), _halfSpace(0.0) {}
    ~OBFloatGrid()
    {
      if (_ival) delete [] _ival;
    }

    //! Initialize the grid using this molecule as a box (plus a padding)
    //! with the supplied spacing between points.
    void Init(OBMol &box,double spacing, double pad=0.0);

    //! \return the minimum point in the grid.
    vector3 GetMin() { return vector3(_xmin, _ymin, _zmin); }

    //! Get the minimum point in the grid.
    //! \deprecated Will be removed.
    //! Use \sa GetMin()
    void GetMin(double *a)
    {
      a[0]=_xmin;
      a[1]=_ymin;
      a[2]=_zmin;
    }

    //! \return the minimum point in the grid.
    vector3 GetMax() { return vector3(_xmax, _ymax, _zmax); }

    //! Get the maximum point in the grid.
    //! \deprecated Will be removed.
    //! \sa GetMax()
    void GetMax(double *a)
    {
      a[0]=_xmax;
      a[1]=_ymax;
      a[2]=_zmax;
    }

    //! \return The grid spacing.
    double GetSpacing() const { return(_spacing); }
    //! Get the grid spacing.
    //! \deprecated Will be removed.
    //! \sa GetSpacing()
    void GetSpacing(double &s)
    {
      s=_spacing;
    }
    //! \return Inverse of the grid spacing.
    double GetScale() const   { return(_inv_spa); }
    //! \return Half of the spacing between grid points.
    double GetHalfSpace() const {return(_halfSpace);}
    //! \return Size of the grid in the x dimension.
    int GetXdim() const       { return(_xdim);    }
    //! \return Size of the grid in the y dimension.
    int GetYdim() const       { return(_ydim);    }
    //! \return Size of the grid in the z dimension.
    int GetZdim() const       { return(_zdim);    }
    //! Get the x, y and z dimensions (must pass an double[3] at least).
    //! \deprecated May be removed in future.
    //! \sa GetXdim() \sa GetYdim() \sa GetZdim()
    void GetDim(int *a)
    {
      a[0]=_xdim;
      a[1]=_ydim;
      a[2]=_zdim;
    }

    //! \return Position of the center of the grid.
    vector3 GetMidpointVector()
    {
      vector3 v;
      v.Set(_midx,_midy,_midz);
      return(v);
    }

    //! \return X axis direction.
    vector3 GetXAxis() const
    {
      return _xAxis;
    }

    //! \return Y axis direction.
    vector3 GetYAxis() const
    {
      return _yAxis;
    }

    //! \return Z axis direction.
    vector3 GetZAxis() const
    {
      return _zAxis;
    }

    //! Sets the number of points in the x, y and z directions.
    void SetNumberOfPoints(int nx, int ny, int nz);

    //! Set the direction of the x axis.
    void SetXAxis(vector3);
    //! Set the direction of the y axis.
    void SetYAxis(vector3);
    //! Set the direction of the z axis.
    void SetZAxis(vector3);

    //! Set the limits (i.e., the origin point and the axes)
    //! NOTE: You must set the number of points first,
    //!       with SetNumberOfPoints
    //!       so the grid spacing can be calculated
    void SetLimits(const vector3& origin, const vector3& x, const vector3& y,
                   const vector3& z);
    //! \deprecated Will be removed.
    //! \sa SetLimits(const vector3& origin, const vector3& x, const vector3& y, const vector3& z)
    void SetLimits(const double origin[3], const double x[3], const double y[3],
                   const double z[3]);

    //! Get a copy of the vector that stores the points in the grid.
    std::vector<double> GetDataVector();
    //! Set the values in the grid to those in the vector passed. Note that the
    //! vector must be of the same dimensions as the grid based on the values
    //! given in SetNumberOfPoints(int nx, int ny, int nz).
    void SetVals(const std::vector<double> & vals);

    //! \return Pointer to the first element of the grid point data stored as a
    //! one dimensional array.
    //! \deprecated Will be removed.
    //! \sa GetDataVector()
    double *GetVals()    {        return(&_values[0]);    }

    //! \return Value at the point in the grid specified by i, j and k.
    double GetValue(int i, int j, int k)
    {
      if (i*_ydim*_zdim + j*_zdim + k > _xdim*_ydim*_zdim)
        return 0.0;
      else
        return _values[i*_ydim*_zdim + j*_zdim + k];
    }

    //! \deprecated Will be removed.
    //! \sa SetVals(const std::vector<double> & vals)
    void SetVals(double *ptr)
    {
     for (int i = 0; i < _xdim*_ydim*_zdim; ++i)
       _values[i] = ptr[i];
    }

    //! Set the value at the grid point specified by i, j and k to val.
    bool SetValue(int i, int j, int k, double val)
    {
      if (i*_ydim*_zdim + j*_zdim + k > _xdim*_ydim*_zdim)
        return false;

      _values[i*_ydim*_zdim + j*_zdim + k] = val;
      return true;
    }

    //! \return Position of the center of the grid.
    vector3 Center()
    {
      return vector3(_midx,_midy,_midz);
    }

    friend std::ostream& operator<< ( std::ostream&, const OBFloatGrid& ) ;
    friend std::istream& operator>> ( std::istream&,OBFloatGrid& ) ;

    //! \return the value at the given point (rounding as needed)
    double Inject(double x,double y,double z);
    void IndexToCoords(int idx, double &x, double &y, double &z);
    void CoordsToIndex(int*,double*);
    int CoordsToIndex(double x, double y, double z);
    //! \return the interpolated value for the given point
    double Interpolate(double,double,double);
    //! \return the interpolated value for the given point and set the dx, dy, dz derivatives
    double InterpolateDerivatives(double,double,double,double *derivatives);
  };

#ifndef OBPolarGrid
#define OBPolarGrid 0x01 /* polar interactions? */
#endif //OBPolarGrid

#ifndef OBLipoGrid
#define OBLipoGrid 0x02 /* lipophilicity? */
#endif //OBLipoGrid

  //! \class OBProxGrid grid.h <openbabel/grid.h>
  //! \brief A grid for determining the proximity of a given point to atoms in an OBMol
  //! \deprecated May be removed in the future, since docking is not a key feature
 class OBAPI OBProxGrid: public OBGrid
  {
  protected:
    int _gridtype;
    int _nxinc,_nyinc,_nzinc,_maxinc;
    double _inc;
    std::vector<std::vector<int> > cell;

  public:

    OBProxGrid(int gridtype=0)
      {
        _gridtype=gridtype;
      }
    ~OBProxGrid()
      {}
    void Setup(OBMol &mol,OBMol &box, double cutoff,double resolution = 0.5);
    void Setup(OBMol &mol,OBMol &box, double cutoff,
               std::vector<bool> &use,double resolution = 0.5);
    std::vector<int> *GetProxVector(double,double,double);
    std::vector<int> *GetProxVector(double*);

    bool LipoGrid()
    {
      return((_gridtype&OBLipoGrid) ? true : false);
    }
    bool PolarGrid()
    {
      return(_gridtype&OBPolarGrid);
    }
    void SetGridType(int gridtype)
    {
      _gridtype = gridtype;
    }
  };

  // scoring function used: PLP = Piecewise Linear Potential or ChemScore algorithm
  typedef enum { Undefined = -1, PLP, ChemScore } score_t;

  //! \class OBScoreGrid grid.h <openbabel/grid.h>
  //! \brief A base class for scoring docking interactions between multiple molecules
  //! \deprecated Will disappear in future versions. Use your own code.
  class OBAPI OBScoreGrid
  {
  protected:
    score_t gridtype;
    bool verbose;

  public:

    double score;

    OBScoreGrid(void)                 {  verbose = false;      }
    virtual ~OBScoreGrid(void) {}

    void    SetVerbose(bool v)        {      verbose = v;      }
    void    SetType(score_t type)     {      gridtype = type;  }
    score_t GetType(void)             {    return gridtype;    }

    virtual void   Clear(void)        { }
    virtual double  Eval(double *)    {       return -1;       }
    virtual double  Eval(OBMol &mol){return Eval(mol.GetCoordinates());}
    virtual void   Init(OBMol &, OBMol &, std::string &, double){}
    virtual void   Setup(OBMol &) {}
    virtual void   Setup(OBMol &, std::vector<int> &){}
    virtual void   Setup(std::vector<int> &) {}
    virtual void   Config(std::string) {}
    virtual bool   Read(std::string)   {      return false;    }
    virtual bool   Write(std::string)  {      return false;    }
    virtual vector3 Center()           {      return VZero;    }
    virtual vector3 CenterMol(OBMol &) {      return VZero;    }
  };

} // end namespace OpenBabel

#endif // OB_GRID_H

//! \file grid.h
//! \brief Handle grids of values.