11#ifndef RD_FPBREADER_H_DEC2015
12#define RD_FPBREADER_H_DEC2015
28#include <boost/shared_ptr.hpp>
29#include <boost/shared_array.hpp>
67 FPBReader(
const char *fname,
bool lazyRead =
false) {
68 _initFromFilename(fname, lazyRead);
71 FPBReader(
const std::string &fname,
bool lazyRead =
false) {
72 _initFromFilename(fname.c_str(), lazyRead);
86 FPBReader(std::istream *inStream,
bool takeOwnership =
true,
87 bool lazyRead =
false)
90 df_owner(takeOwnership),
92 df_lazyRead(lazyRead) {}
126 boost::shared_ptr<ExplicitBitVect>
getFP(
unsigned int idx)
const;
128 boost::shared_array<std::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));
141 unsigned int minCount,
unsigned int maxCount);
150 double getTanimoto(
unsigned int idx,
const std::uint8_t *bv)
const;
153 boost::shared_array<std::uint8_t> bv)
const {
172 const std::uint8_t *bv,
double threshold = 0.7,
173 bool usePopcountScreen =
true)
const;
176 boost::shared_array<std::uint8_t> bv,
double threshold = 0.7,
177 bool usePopcountScreen =
true)
const {
183 bool usePopcountScreen =
true)
const;
195 double getTversky(
unsigned int idx,
const std::uint8_t *bv,
double ca,
198 double getTversky(
unsigned int idx, boost::shared_array<std::uint8_t> bv,
199 double ca,
double cb)
const {
221 const std::uint8_t *bv,
double ca,
double cb,
double threshold = 0.7,
222 bool usePopcountScreen =
true)
const;
225 boost::shared_array<std::uint8_t> bv,
double ca,
double cb,
226 double threshold = 0.7,
bool usePopcountScreen =
true)
const {
231 const ExplicitBitVect &ebv,
double ca,
double cb,
double threshold = 0.7,
232 bool usePopcountScreen =
true)
const;
239 const std::uint8_t *bv)
const;
242 boost::shared_array<std::uint8_t> bv)
const {
250 std::istream *dp_istrm{
nullptr};
251 detail::FPBReader_impl *dp_impl{
nullptr};
252 bool df_owner{
false};
254 bool df_lazyRead{
false};
260 FPBReader(
const FPBReader &);
261 FPBReader &operator=(
const FPBReader &);
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->bad())) {
267 std::ostringstream errout;
268 errout <<
"Bad input file " << fname;
270 throw BadFileException(errout.str());
272 dp_istrm = tmpStream;
276 df_lazyRead = lazyRead;
a class for bit vectors that are densely occupied
std::vector< unsigned int > getContainingNeighbors(boost::shared_array< std::uint8_t > bv) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::pair< unsigned int, unsigned int > getFPIdsInCountRange(unsigned int minCount, unsigned int maxCount)
std::vector< std::pair< double, unsigned int > > getTanimotoNeighbors(const std::uint8_t *bv, double threshold=0.7, bool usePopcountScreen=true) const
returns tanimoto neighbors that are within a similarity threshold
std::vector< std::pair< double, unsigned int > > getTanimotoNeighbors(const ExplicitBitVect &ebv, double threshold=0.7, bool usePopcountScreen=true) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< std::pair< double, unsigned int > > getTverskyNeighbors(const std::uint8_t *bv, double ca, double cb, double threshold=0.7, bool usePopcountScreen=true) const
returns Tversky neighbors that are within a similarity threshold
std::vector< unsigned int > getContainingNeighbors(const std::uint8_t *bv) const
returns indices of all fingerprints that completely contain this one
double getTversky(unsigned int idx, const std::uint8_t *bv, double ca, double cb) const
std::vector< std::pair< double, unsigned int > > getTverskyNeighbors(boost::shared_array< std::uint8_t > bv, double ca, double cb, double threshold=0.7, bool usePopcountScreen=true) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
unsigned int length() const
returns the number of fingerprints
boost::shared_array< std::uint8_t > getBytes(unsigned int idx) const
returns the requested fingerprint as an array of bytes
double getTanimoto(unsigned int idx, const std::uint8_t *bv) const
std::vector< std::pair< double, unsigned int > > getTverskyNeighbors(const ExplicitBitVect &ebv, double ca, double cb, double threshold=0.7, bool usePopcountScreen=true) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
boost::shared_ptr< ExplicitBitVect > getFP(unsigned int idx) const
returns the requested fingerprint as an ExplicitBitVect
double getTanimoto(unsigned int idx, boost::shared_array< std::uint8_t > bv) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double getTversky(unsigned int idx, boost::shared_array< std::uint8_t > bv, double ca, double cb) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::pair< boost::shared_ptr< ExplicitBitVect >, std::string > operator[](unsigned int idx) const
returns the fingerprint and id of the requested fingerprint
std::vector< std::pair< double, unsigned int > > getTanimotoNeighbors(boost::shared_array< std::uint8_t > bv, double threshold=0.7, bool usePopcountScreen=true) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double getTversky(unsigned int idx, const ExplicitBitVect &ebv, double ca, double cb) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
FPBReader(std::istream *inStream, bool takeOwnership=true, bool lazyRead=false)
ctor for reading from an open istream
FPBReader(const char *fname, bool lazyRead=false)
ctor for reading from a named file
FPBReader(const std::string &fname, bool lazyRead=false)
This is an overloaded member function, provided for convenience. It differs from the above function o...
unsigned int nBits() const
returns the number of bits in our fingerprints
std::vector< unsigned int > getContainingNeighbors(const ExplicitBitVect &ebv) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double getTanimoto(unsigned int idx, const ExplicitBitVect &ebv) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::string getId(unsigned int idx) const
returns the id of the requested fingerprint
void init()
Read the data from the file and initialize internal data structures.
#define RDKIT_DATASTRUCTS_EXPORT