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));
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 {
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 {
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 {
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 {
221 const ExplicitBitVect &ebv,
double ca,
double cb,
double threshold = 0.7,
222 bool usePopcountScreen =
true)
const;
229 const boost::uint8_t *bv)
const;
232 boost::shared_array<boost::uint8_t> bv)
const {
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 getTversky(unsigned int idx, const boost::uint8_t *bv, double ca, double cb) const
used by various file parsing classes to indicate a bad file
double getTanimoto(unsigned int idx, const boost::uint8_t *bv) const
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
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
returns Tversky neighbors that are within a similarity threshold
FPBReader(const std::string &fname, bool lazyRead=false)
std::vector< std::pair< double, unsigned int > > getTanimotoNeighbors(boost::shared_array< boost::uint8_t > bv, double threshold=0.7, bool usePopcountScreen=true) const
std::vector< unsigned int > getContainingNeighbors(const boost::uint8_t *bv) const
returns indices of all fingerprints that completely contain this one
unsigned int length() const
returns the number of fingerprints
std::pair< boost::shared_ptr< ExplicitBitVect >, std::string > operator[](unsigned int idx) const
returns the fingerprint and id of the requested fingerprint
Includes a bunch of functionality for handling Atom and Bond queries.
boost::shared_ptr< ExplicitBitVect > getFP(unsigned int idx) const
returns the requested fingerprint as an ExplicitBitVect
double getTversky(unsigned int idx, boost::shared_array< boost::uint8_t > bv, double ca, double cb) const
boost::shared_array< boost::uint8_t > getBytes(unsigned int idx) const
returns the requested fingerprint as an array of bytes
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.
std::vector< std::pair< double, unsigned int > > getTanimotoNeighbors(const boost::uint8_t *bv, double threshold=0.7, bool usePopcountScreen=true) const
returns tanimoto neighbors that are within a similarity threshold
unsigned int nBits() const
returns the number of bits in our fingerprints
FPBReader(const char *fname, bool lazyRead=false)
ctor for reading from a named file
std::pair< unsigned int, unsigned int > getFPIdsInCountRange(unsigned int minCount, unsigned int maxCount)
std::vector< unsigned int > getContainingNeighbors(boost::shared_array< boost::uint8_t > bv) const
a class for bit vectors that are densely occupied
double getTanimoto(unsigned int idx, boost::shared_array< boost::uint8_t > bv) const