10 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 |
|
GNU General Public License for more details. |
12 |
|
***********************************************************************/ |
13 |
< |
#include "fingerprintformat.hpp" |
13 |
> |
#include "mol.hpp" |
14 |
> |
#include "obconversion.hpp" |
15 |
> |
#include "obmolecformat.hpp" |
16 |
> |
#include "fingerprint.hpp" |
17 |
> |
#include <vector> |
18 |
> |
#include <string> |
19 |
> |
#include <iomanip> |
20 |
|
|
21 |
|
using namespace std; |
22 |
< |
namespace OpenBabel { |
22 |
> |
namespace OpenBabel |
23 |
> |
{ |
24 |
|
|
25 |
+ |
/// \brief Constructs and displays fingerprints. For details see OBFingerprint class |
26 |
+ |
class FingerprintFormat : public OBMoleculeFormat |
27 |
+ |
{ |
28 |
+ |
public: |
29 |
+ |
//Register this format type ID |
30 |
+ |
FingerprintFormat() {OBConversion::RegisterFormat("fpt",this);} |
31 |
+ |
|
32 |
+ |
virtual const char* Description() //required |
33 |
+ |
{ return |
34 |
+ |
"Fingerprint format\n \ |
35 |
+ |
Constructs and displays fingerprints and (for multiple input objects)\n \ |
36 |
+ |
the Tanimoto coefficient and whether a superstructure of the first object\n \ |
37 |
+ |
Options e.g. -xfFP3 -xn128\n \ |
38 |
+ |
f<id> fingerprint type\n \ |
39 |
+ |
N# fold to specified number of bits, 32, 64, 128, etc.\n \ |
40 |
+ |
h hex output when multiple molecules\n \ |
41 |
+ |
F displays the available fingerprint types\n \ |
42 |
+ |
"; |
43 |
+ |
}; |
44 |
+ |
|
45 |
+ |
virtual unsigned int Flags(){return NOTREADABLE;}; |
46 |
+ |
virtual bool WriteMolecule(OBBase* pOb, OBConversion* pConv); |
47 |
+ |
|
48 |
+ |
private: |
49 |
+ |
vector<unsigned int> firstfp; |
50 |
+ |
string firstname; |
51 |
+ |
bool IsPossibleSubstructure(vector<unsigned int>Mol, vector<unsigned int>Frag); |
52 |
+ |
}; |
53 |
+ |
|
54 |
+ |
//////////////////////////////////////////////////// |
55 |
+ |
//Make an instance of the format class |
56 |
+ |
FingerprintFormat theFingerprintFormat; |
57 |
+ |
|
58 |
+ |
//******************************************************************* |
59 |
|
bool FingerprintFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv) |
60 |
|
{ |
61 |
|
ostream &ofs = *pConv->GetOutStream(); |
110 |
|
|
111 |
|
if(hexoutput) |
112 |
|
{ |
113 |
< |
int i, bitsset=0; |
113 |
> |
unsigned int i, bitsset=0; |
114 |
|
for (i=0;i<fptvec.size();++i) |
115 |
|
{ |
116 |
|
int wd = fptvec[i]; |
155 |
|
bool FingerprintFormat::IsPossibleSubstructure(vector<unsigned int>Mol, vector<unsigned int>Frag) |
156 |
|
{ |
157 |
|
//Returns false if Frag is definitely NOT a substructure of Mol |
158 |
< |
int i; |
158 |
> |
unsigned int i; |
159 |
|
for (i=0;i<Mol.size();++i) |
160 |
|
if((Mol[i] & Frag[i]) ^ Frag[i]) return false; |
161 |
|
return true; |