10 #ifndef RD_FPBREADER_H_DEC2015 11 #define RD_FPBREADER_H_DEC2015 27 #include <boost/cstdint.hpp> 28 #include <boost/shared_ptr.hpp> 29 #include <boost/shared_array.hpp> 33 struct FPBReader_impl;
71 FPBReader(
const char *fname,
bool lazyRead =
false) {
72 _initFromFilename(fname, lazyRead);
75 FPBReader(
const std::string &fname,
bool lazyRead =
false) {
76 _initFromFilename(fname.c_str(), lazyRead);
90 FPBReader(std::istream *inStream,
bool takeOwnership =
true,
91 bool lazyRead =
false)
93 df_owner(takeOwnership),
95 df_lazyRead(lazyRead){};
98 if (df_owner)
delete dp_istrm;
116 boost::shared_ptr<ExplicitBitVect> getFP(
unsigned int idx)
const;
118 boost::shared_array<boost::uint8_t> getBytes(
unsigned int idx)
const;
121 std::string getId(
unsigned int idx)
const;
123 std::pair<boost::shared_ptr<ExplicitBitVect>, std::string>
operator[](
124 unsigned int idx)
const {
125 return std::make_pair(getFP(idx), getId(idx));
130 std::pair<unsigned int, unsigned int> getFPIdsInCountRange(
131 unsigned int minCount,
unsigned int maxCount);
134 unsigned int length()
const;
136 unsigned int nBits()
const;
140 double getTanimoto(
unsigned int idx,
const boost::uint8_t *bv)
const;
143 boost::shared_array<boost::uint8_t> bv)
const {
144 return getTanimoto(idx, bv.get());
147 double getTanimoto(
unsigned int idx,
const ExplicitBitVect &ebv)
const;
161 std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
162 const boost::uint8_t *bv,
double threshold = 0.7,
163 bool usePopcountScreen =
true)
const;
166 boost::shared_array<boost::uint8_t> bv,
double threshold = 0.7,
167 bool usePopcountScreen =
true)
const {
168 return getTanimotoNeighbors(bv.get(), threshold, usePopcountScreen);
171 std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
173 bool usePopcountScreen =
true)
const;
185 double getTversky(
unsigned int idx,
const boost::uint8_t *bv,
double ca,
188 double getTversky(
unsigned int idx, boost::shared_array<boost::uint8_t> bv,
189 double ca,
double cb)
const {
190 return getTversky(idx, bv.get(), ca, cb);
193 double getTversky(
unsigned int idx,
const ExplicitBitVect &ebv,
double ca,
210 std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
211 const boost::uint8_t *bv,
double ca,
double cb,
double threshold = 0.7,
212 bool usePopcountScreen =
true)
const;
215 boost::shared_array<boost::uint8_t> bv,
double ca,
double cb,
216 double threshold = 0.7,
bool usePopcountScreen =
true)
const {
217 return getTverskyNeighbors(bv.get(), ca, cb, threshold, usePopcountScreen);
220 std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
221 const ExplicitBitVect &ebv,
double ca,
double cb,
double threshold = 0.7,
222 bool usePopcountScreen =
true)
const;
228 std::vector<unsigned int> getContainingNeighbors(
229 const boost::uint8_t *bv)
const;
232 boost::shared_array<boost::uint8_t> bv)
const {
233 return getContainingNeighbors(bv.get());
236 std::vector<unsigned int> getContainingNeighbors(
240 std::istream *dp_istrm;
241 detail::FPBReader_impl *dp_impl;
253 void _initFromFilename(
const char *fname,
bool lazyRead) {
254 std::istream *tmpStream =
static_cast<std::istream *
>(
255 new std::ifstream(fname, std::ios_base::binary));
256 if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) {
257 std::ostringstream errout;
258 errout <<
"Bad input file " << fname;
261 dp_istrm = tmpStream;
264 df_lazyRead = lazyRead;
class for reading and searching FPB files
double getTanimoto(unsigned int idx, boost::shared_array< boost::uint8_t > bv) const
used by various file parsing classes to indicate a bad file
FPBReader(std::istream *inStream, bool takeOwnership=true, bool lazyRead=false)
ctor for reading from an open istream
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
FPBReader(const std::string &fname, bool lazyRead=false)
std::pair< boost::shared_ptr< ExplicitBitVect >, std::string > operator[](unsigned int idx) const
returns the fingerprint and id of the requested fingerprint
std::vector< unsigned int > getContainingNeighbors(boost::shared_array< boost::uint8_t > bv) const
Includes a bunch of functionality for handling Atom and Bond queries.
double getTversky(unsigned int idx, boost::shared_array< boost::uint8_t > bv, double ca, double cb) const
std::vector< std::pair< double, unsigned int > > getTanimotoNeighbors(boost::shared_array< boost::uint8_t > bv, double threshold=0.7, bool usePopcountScreen=true) const
FPBReader(const char *fname, bool lazyRead=false)
ctor for reading from a named file
a class for bit vectors that are densely occupied