This file is indexed.

/usr/include/rdkit/DataStructs/FPBReader.h is in librdkit-dev 201603.5-2.

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
//
// Copyright (c) 2016 Greg Landrum
//
//  @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
#ifndef RD_FPBREADER_H_DEC2015
#define RD_FPBREADER_H_DEC2015
/*! \file FPBReader.h

  \brief contains a simple class for reading and searching FPB files

  \b Note that this functionality is experimental and the API may change
     in future releases.
*/

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <RDGeneral/BadFileException.h>
#include <DataStructs/ExplicitBitVect.h>

#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>

namespace RDKit {
namespace detail {
struct FPBReader_impl;
}

//! class for reading and searching FPB files
/*!
  basic usage:
  \code
  FPBReader reader("foo.fpb");
  reader.init();
  boost::shared_ptr<ExplicitBitVect> ebv = reader.getFP(95);
  std::vector<std::pair<double, unsigned int> > nbrs =
      reader.getTanimotoNeighbors(*ebv.get(), 0.70);
  \endcode

  \b Note: this functionality is experimental and the API may change
     in future releases.

  <b>Note on thread safety</b>
  Operations that involve reading from the FPB file are not thread safe.
  This means that the \c init() method is not thread safe and none of the
  search operations are thread safe when an \c FPBReader is initialized in
  \c lazyRead mode.

*/
class FPBReader {
 public:
  FPBReader()
      : dp_istrm(NULL),
        dp_impl(NULL),
        df_owner(false),
        df_init(false),
        df_lazyRead(false){};
  //! ctor for reading from a named file
  /*!
  \param fname the name of the file to reads
  \param lazyRead if set to \c false all fingerprints from the file will be read
  into memory when \c init() is called.
  */
  FPBReader(const char *fname, bool lazyRead = false) {
    _initFromFilename(fname, lazyRead);
  };
  //! \overload
  FPBReader(const std::string &fname, bool lazyRead = false) {
    _initFromFilename(fname.c_str(), lazyRead);
  };
  //! ctor for reading from an open istream
  /*!
  \param inStream the stream to read from
  \param takeOwnership if set, we will take over ownership of the stream pointer
  \param lazyRead if set to \c false all fingerprints from the file will be read
  into memory when \c init() is called.

  Some additional notes:
    - if \c lazyRead is set, \c inStream must support the \c seekg() and \c
  tellg() operations.

  */
  FPBReader(std::istream *inStream, bool takeOwnership = true,
            bool lazyRead = false)
      : dp_istrm(inStream),
        df_owner(takeOwnership),
        df_init(false),
        df_lazyRead(lazyRead){};
  ~FPBReader() {
    destroy();
    if (df_owner) delete dp_istrm;
    dp_istrm = NULL;
    df_init = false;
  };

  //! Read the data from the file and initialize internal data structures
  /*!
  This must be called before most of the other methods of this clases.

  Some notes:
  \li if \c lazyRead is not set, all fingerprints will be read into memory. This
  can require substantial amounts of memory for large files.
  \li For large files, this can take a long time.
  \li If \c lazyRead and \c takeOwnership are both \c false it is safe to close
  and delete inStream after calling \c init()
  */
  void init();
  //! returns the requested fingerprint as an \c ExplicitBitVect
  boost::shared_ptr<ExplicitBitVect> getFP(unsigned int idx) const;
  //! returns the requested fingerprint as an array of bytes
  boost::shared_array<boost::uint8_t> getBytes(unsigned int idx) const;

  //! returns the id of the requested fingerprint
  std::string getId(unsigned int idx) const;
  //! returns the fingerprint and id of the requested fingerprint
  std::pair<boost::shared_ptr<ExplicitBitVect>, std::string> operator[](
      unsigned int idx) const {
    return std::make_pair(getFP(idx), getId(idx));
  };

  //! returns beginning and end indices of fingerprints having on-bit counts
  //! within the range (including end points)
  std::pair<unsigned int, unsigned int> getFPIdsInCountRange(
      unsigned int minCount, unsigned int maxCount);

  //! returns the number of fingerprints
  unsigned int length() const;
  //! returns the number of bits in our fingerprints
  unsigned int nBits() const;

  //! returns the tanimoto similarity between the specified fingerprint and the
  //! provided fingerprint
  double getTanimoto(unsigned int idx, const boost::uint8_t *bv) const;
  //! \overload
  double getTanimoto(unsigned int idx,
                     boost::shared_array<boost::uint8_t> bv) const {
    return getTanimoto(idx, bv.get());
  };
  //! \overload
  double getTanimoto(unsigned int idx, const ExplicitBitVect &ebv) const;

  //! returns tanimoto neighbors that are within a similarity threshold
  /*!
  The result vector of (similarity,index) pairs is sorted in order
  of decreasing similarity

    \param bv the query fingerprint
    \param threshold the minimum similarity to return
    \param usePopcountScreen if this is true (the default) the popcount of the
           neighbors will be used to reduce the number of calculations that need
           to be done

  */
  std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
      const boost::uint8_t *bv, double threshold = 0.7,
      bool usePopcountScreen = true) const;
  //! \overload
  std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
      boost::shared_array<boost::uint8_t> bv, double threshold = 0.7,
      bool usePopcountScreen = true) const {
    return getTanimotoNeighbors(bv.get(), threshold, usePopcountScreen);
  };
  //! \overload
  std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
      const ExplicitBitVect &ebv, double threshold = 0.7,
      bool usePopcountScreen = true) const;

  //! returns the Tversky similarity between the specified fingerprint and the
  //! provided fingerprint
  /*!

    \param idx the fingerprint to compare to
    \param bv the query fingerprint
    \param ca the Tversky a coefficient
    \param cb the Tversky a coefficient

   */
  double getTversky(unsigned int idx, const boost::uint8_t *bv, double ca,
                    double cb) const;
  //! \overload
  double getTversky(unsigned int idx, boost::shared_array<boost::uint8_t> bv,
                    double ca, double cb) const {
    return getTversky(idx, bv.get(), ca, cb);
  };
  //! \overload
  double getTversky(unsigned int idx, const ExplicitBitVect &ebv, double ca,
                    double cb) const;

  //! returns Tversky neighbors that are within a similarity threshold
  /*!
  The result vector of (similarity,index) pairs is sorted in order
  of decreasing similarity

    \param bv the query fingerprint
    \param ca the Tversky a coefficient
    \param cb the Tversky a coefficient
    \param threshold the minimum similarity to return
    \param usePopcountScreen if this is true (the default) the popcount of the
           neighbors will be used to reduce the number of calculations that need
           to be done

  */
  std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
      const boost::uint8_t *bv, double ca, double cb, double threshold = 0.7,
      bool usePopcountScreen = true) const;
  //! \overload
  std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
      boost::shared_array<boost::uint8_t> bv, double ca, double cb,
      double threshold = 0.7, bool usePopcountScreen = true) const {
    return getTverskyNeighbors(bv.get(), ca, cb, threshold, usePopcountScreen);
  };
  //! \overload
  std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
      const ExplicitBitVect &ebv, double ca, double cb, double threshold = 0.7,
      bool usePopcountScreen = true) const;

  //! returns indices of all fingerprints that completely contain this one
  /*! (i.e. where all the bits set in the query are also set in the db
   molecule)
   */
  std::vector<unsigned int> getContainingNeighbors(
      const boost::uint8_t *bv) const;
  //! \overload
  std::vector<unsigned int> getContainingNeighbors(
      boost::shared_array<boost::uint8_t> bv) const {
    return getContainingNeighbors(bv.get());
  };
  //! \overload
  std::vector<unsigned int> getContainingNeighbors(
      const ExplicitBitVect &ebv) const;

 private:
  std::istream *dp_istrm;
  detail::FPBReader_impl *dp_impl;  // implementation details
  bool df_owner;
  bool df_init;
  bool df_lazyRead;

  // disable automatic copy constructors and assignment operators
  // for this class and its subclasses.  They will likely be
  // carrying around stream pointers and copying those is a recipe
  // for disaster.
  FPBReader(const FPBReader &);
  FPBReader &operator=(const FPBReader &);
  void destroy();
  void _initFromFilename(const char *fname, bool lazyRead) {
    std::istream *tmpStream = static_cast<std::istream *>(
        new std::ifstream(fname, std::ios_base::binary));
    if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) {
      std::ostringstream errout;
      errout << "Bad input file " << fname;
      throw BadFileException(errout.str());
    }
    dp_istrm = tmpStream;
    df_owner = true;
    df_init = false;
    df_lazyRead = lazyRead;
  }
};
}
#endif