19 #ifndef OB_FINGERPRINT_H 20 #define OB_FINGERPRINT_H 47 return "fingerprints";
56 void SetBit(std::vector<unsigned int>& vec,
const unsigned int n);
59 bool GetBit(
const std::vector<unsigned int>& vec,
const unsigned int n);
62 void Fold(std::vector<unsigned int>& vec,
unsigned int nbits);
65 virtual bool GetFingerprint(
OBBase* pOb, std::vector<unsigned int>& fp,
int nbits=0)=0;
68 enum FptFlag{FPT_UNIQUEBITS=1, FPT_NOINFO=2};
69 virtual unsigned int Flags() {
return 0;};
83 static double Tanimoto(
const std::vector<unsigned int>& vec1,
const std::vector<unsigned int>& vec2);
86 static double Tanimoto(
const std::vector<unsigned int>& vec1,
const unsigned int* p2)
89 int andbits=0, orbits=0;
91 for (i=0;i<vec1.size();++i)
93 int andfp = vec1[i] & p2[i];
94 int orfp = vec1[i] | p2[i];
100 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 101 andbits += __builtin_popcount(andfp);
102 orbits += __builtin_popcount(orfp);
104 for(;andfp;andfp=andfp<<1)
105 if(andfp<0) ++andbits;
106 for(;orfp;orfp=orfp<<1)
110 return((
double)andbits/(
double)orbits);
119 unsigned int operator()(
const unsigned int a,
const unsigned int b)
132 static const unsigned int bitsperint;
145 char datafilename[256];
155 bool Read(std::istream* pIndexstream);
156 bool ReadIndex(std::istream* pIndexstream);
157 bool ReadHeader(std::istream* pIndexstream);
170 std::string ReadIndexFile(std::string IndexFilename);
171 std::string ReadIndex(std::istream* pIndexstream);
176 bool Find(
OBBase* pOb, std::vector<unsigned long>& SeekPositions,
unsigned int MaxCandidates);
180 bool FindMatch(
OBBase* pOb, std::vector<unsigned long>& SeekPositions,
181 unsigned int MaxCandidates);
185 bool FindSimilar(
OBBase* pOb, std::multimap<double, unsigned long>& SeekposMap,
186 double MinTani,
double MaxTani = 1.1 );
190 bool FindSimilar(
OBBase* pOb, std::multimap<double, unsigned long>& SeekposMap,
211 FastSearchIndexer(std::string& datafilename, std::ostream* os, std::string& fpid,
212 int FptBits=0,
int nmols=0);
220 bool Add(
OBBase* pOb, std::streampos seekpos);
223 std::ostream* _indexstream;
virtual ~OBFingerprint()
Definition: fingerprint.h:53
virtual std::string DescribeBits(const std::vector< unsigned int >, bool=true)
Definition: fingerprint.h:75
Base class for all types of dynamic classes discovered at runtime.
Definition: plugin.h:52
OBFingerprint * GetFingerprint() const
Definition: fingerprint.h:194
std::vector< unsigned long > seekdata
Definition: fingerprint.h:154
Class to search fingerprint index files.
Definition: fingerprint.h:165
static double Tanimoto(const std::vector< unsigned int > &vec1, const unsigned int *p2)
Inline version of Tanimoto() taking a pointer for the second vector.
Definition: fingerprint.h:86
virtual unsigned int Flags()
Definition: fingerprint.h:69
Class to prepare fingerprint index files See FastSearch class for details.
Definition: fingerprint.h:206
FptIndexHeader header
Definition: fingerprint.h:152
static unsigned int Getbitsperint()
Definition: fingerprint.h:113
#define MAKE_PLUGIN(BaseClass)
Definition: plugin.h:195
Simplify 'plugin' classes to be discovered and/or loaded at runtime.
double Tanimoto(const OBBitVec &bv1, const OBBitVec &bv2)
The Tanimoto coefficient, which may be regarded as the proportion of the "on-bits" which are shared...
Definition: bitvec.cpp:660
virtual ~FastSearch()
Definition: fingerprint.h:173
const FptIndexHeader & GetIndexHeader() const
Definition: fingerprint.h:197
virtual void SetFlags(unsigned int)
Definition: fingerprint.h:71
Structure of fastsearch index files.
Definition: fingerprint.h:150
static OBFingerprint * FindFingerprint(const char *ID)
For backward compatibility; a synonym of OBFingerprint::FindType.
Definition: fingerprint.h:129
The base class for fingerprints.
Definition: fingerprint.h:39
Base Class.
Definition: base.h:239
std::vector< unsigned int > fptdata
Definition: fingerprint.h:153
FptFlag
Optional flags.
Definition: fingerprint.h:68
Global namespace for all Open Babel code.
Definition: alias.h:22