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)
94 df_owner(takeOwnership),
96 df_lazyRead(lazyRead){};
99 if (df_owner)
delete dp_istrm;
121 if (!df_init)
return;
126 boost::shared_ptr<ExplicitBitVect> getFP(
unsigned int idx)
const;
128 boost::shared_array<boost::uint8_t> getBytes(
unsigned int idx)
const;
131 std::string getId(
unsigned int idx)
const;
133 std::pair<boost::shared_ptr<ExplicitBitVect>, std::string>
operator[](
134 unsigned int idx)
const {
135 return std::make_pair(getFP(idx), getId(idx));
140 std::pair<unsigned int, unsigned int> getFPIdsInCountRange(
141 unsigned int minCount,
unsigned int maxCount);
144 unsigned int length()
const;
146 unsigned int nBits()
const;
150 double getTanimoto(
unsigned int idx,
const boost::uint8_t *bv)
const;
153 boost::shared_array<boost::uint8_t> bv)
const {
154 return getTanimoto(idx, bv.get());
157 double getTanimoto(
unsigned int idx,
const ExplicitBitVect &ebv)
const;
171 std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
172 const boost::uint8_t *bv,
double threshold = 0.7,
173 bool usePopcountScreen =
true)
const;
176 boost::shared_array<boost::uint8_t> bv,
double threshold = 0.7,
177 bool usePopcountScreen =
true)
const {
178 return getTanimotoNeighbors(bv.get(), threshold, usePopcountScreen);
181 std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
183 bool usePopcountScreen =
true)
const;
195 double getTversky(
unsigned int idx,
const boost::uint8_t *bv,
double ca,
198 double getTversky(
unsigned int idx, boost::shared_array<boost::uint8_t> bv,
199 double ca,
double cb)
const {
200 return getTversky(idx, bv.get(), ca, cb);
203 double getTversky(
unsigned int idx,
const ExplicitBitVect &ebv,
double ca,
220 std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
221 const boost::uint8_t *bv,
double ca,
double cb,
double threshold = 0.7,
222 bool usePopcountScreen =
true)
const;
225 boost::shared_array<boost::uint8_t> bv,
double ca,
double cb,
226 double threshold = 0.7,
bool usePopcountScreen =
true)
const {
227 return getTverskyNeighbors(bv.get(), ca, cb, threshold, usePopcountScreen);
230 std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
231 const ExplicitBitVect &ebv,
double ca,
double cb,
double threshold = 0.7,
232 bool usePopcountScreen =
true)
const;
238 std::vector<unsigned int> getContainingNeighbors(
239 const boost::uint8_t *bv)
const;
242 boost::shared_array<boost::uint8_t> bv)
const {
243 return getContainingNeighbors(bv.get());
246 std::vector<unsigned int> getContainingNeighbors(
250 std::istream *dp_istrm;
251 detail::FPBReader_impl *dp_impl;
263 void _initFromFilename(
const char *fname,
bool lazyRead) {
264 std::istream *tmpStream =
static_cast<std::istream *
>(
265 new std::ifstream(fname, std::ios_base::binary));
266 if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) {
267 std::ostringstream errout;
268 errout <<
"Bad input file " << fname;
271 dp_istrm = tmpStream;
275 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
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