11 #ifndef RD_FPBREADER_H_DEC2015 12 #define RD_FPBREADER_H_DEC2015 28 #include <boost/cstdint.hpp> 29 #include <boost/shared_ptr.hpp> 30 #include <boost/shared_array.hpp> 34 struct FPBReader_impl;
72 FPBReader(
const char *fname,
bool lazyRead =
false) {
73 _initFromFilename(fname, lazyRead);
76 FPBReader(
const std::string &fname,
bool lazyRead =
false) {
77 _initFromFilename(fname.c_str(), lazyRead);
91 FPBReader(std::istream *inStream,
bool takeOwnership =
true,
92 bool lazyRead =
false)
95 df_owner(takeOwnership),
97 df_lazyRead(lazyRead){};
100 if (df_owner)
delete dp_istrm;
122 if (!df_init)
return;
127 boost::shared_ptr<ExplicitBitVect>
getFP(
unsigned int idx)
const;
129 boost::shared_array<boost::uint8_t> getBytes(
unsigned int idx)
const;
132 std::string getId(
unsigned int idx)
const;
134 std::pair<boost::shared_ptr<ExplicitBitVect>, std::string>
operator[](
135 unsigned int idx)
const {
136 return std::make_pair(
getFP(idx), getId(idx));
141 std::pair<unsigned int, unsigned int> getFPIdsInCountRange(
142 unsigned int minCount,
unsigned int maxCount);
145 unsigned int length()
const;
147 unsigned int nBits()
const;
151 double getTanimoto(
unsigned int idx,
const boost::uint8_t *bv)
const;
154 boost::shared_array<boost::uint8_t> bv)
const {
155 return getTanimoto(idx, bv.get());
158 double getTanimoto(
unsigned int idx,
const ExplicitBitVect &ebv)
const;
172 std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
173 const boost::uint8_t *bv,
double threshold = 0.7,
174 bool usePopcountScreen =
true)
const;
177 boost::shared_array<boost::uint8_t> bv,
double threshold = 0.7,
178 bool usePopcountScreen =
true)
const {
179 return getTanimotoNeighbors(bv.get(), threshold, usePopcountScreen);
182 std::vector<std::pair<double, unsigned int> > getTanimotoNeighbors(
184 bool usePopcountScreen =
true)
const;
196 double getTversky(
unsigned int idx,
const boost::uint8_t *bv,
double ca,
199 double getTversky(
unsigned int idx, boost::shared_array<boost::uint8_t> bv,
200 double ca,
double cb)
const {
201 return getTversky(idx, bv.get(), ca, cb);
204 double getTversky(
unsigned int idx,
const ExplicitBitVect &ebv,
double ca,
221 std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
222 const boost::uint8_t *bv,
double ca,
double cb,
double threshold = 0.7,
223 bool usePopcountScreen =
true)
const;
226 boost::shared_array<boost::uint8_t> bv,
double ca,
double cb,
227 double threshold = 0.7,
bool usePopcountScreen =
true)
const {
228 return getTverskyNeighbors(bv.get(), ca, cb, threshold, usePopcountScreen);
231 std::vector<std::pair<double, unsigned int> > getTverskyNeighbors(
232 const ExplicitBitVect &ebv,
double ca,
double cb,
double threshold = 0.7,
233 bool usePopcountScreen =
true)
const;
239 std::vector<unsigned int> getContainingNeighbors(
240 const boost::uint8_t *bv)
const;
243 boost::shared_array<boost::uint8_t> bv)
const {
244 return getContainingNeighbors(bv.get());
247 std::vector<unsigned int> getContainingNeighbors(
251 std::istream *dp_istrm;
252 detail::FPBReader_impl *dp_impl;
264 void _initFromFilename(
const char *fname,
bool lazyRead) {
265 std::istream *tmpStream =
static_cast<std::istream *
>(
266 new std::ifstream(fname, std::ios_base::binary));
267 if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) {
268 std::ostringstream errout;
269 errout <<
"Bad input file " << fname;
272 dp_istrm = tmpStream;
276 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
RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect * getFP(const ROMol &mol, FPType fPType)
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)
#define RDKIT_DATASTRUCTS_EXPORT
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