File: rdMolDescriptors.cpp

package info (click to toggle)
rdkit 201203-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 37,840 kB
  • sloc: cpp: 93,902; python: 51,897; java: 5,192; ansic: 3,497; xml: 2,499; sql: 1,641; yacc: 1,518; lex: 1,076; makefile: 325; fortran: 183; sh: 153; cs: 51
file content (681 lines) | stat: -rw-r--r-- 31,577 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
// $Id: rdMolDescriptors.cpp 2003 2012-03-26 03:08:02Z glandrum $
//
//  Copyright (C) 2007-2011 Greg Landrum
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
#include <RDBoost/Wrap.h>
#include <GraphMol/Atom.h>
#include <GraphMol/GraphMol.h>
#include <numpy/arrayobject.h>
#include <boost/foreach.hpp>

#include <GraphMol/Descriptors/MolDescriptors.h>
#include <GraphMol/Fingerprints/AtomPairs.h>
#include <GraphMol/Fingerprints/MorganFingerprints.h>
#include <DataStructs/BitVects.h>

#include <vector>

namespace python = boost::python;

namespace {
  std::vector<unsigned int> atomPairTypes(RDKit::AtomPairs::atomNumberTypes,
					  RDKit::AtomPairs::atomNumberTypes+sizeof(RDKit::AtomPairs::atomNumberTypes)/sizeof(unsigned int));
  python::tuple computeASAContribs(const RDKit::ROMol &mol,bool includeHs=true,
				   bool force=false){
    std::vector<double> contribs(mol.getNumAtoms());
    double hContrib=0.0;
    RDKit::Descriptors::getLabuteAtomContribs(mol,contribs,hContrib,includeHs,force);
    python::tuple pycontribs(contribs);
    return python::make_tuple(contribs,hContrib);
  }
  python::tuple computeTPSAContribs(const RDKit::ROMol &mol,
				   bool force=false){
    std::vector<double> contribs(mol.getNumAtoms());
    RDKit::Descriptors::getTPSAAtomContribs(mol,contribs,force);
    python::tuple pycontribs(contribs);
    return pycontribs;
  }

  python::list computeCrippenContribs(const RDKit::ROMol &mol,
				       bool force=false){
    std::vector<double> logpContribs(mol.getNumAtoms());
    std::vector<double> mrContribs(mol.getNumAtoms());

    RDKit::Descriptors::getCrippenAtomContribs(mol,logpContribs,mrContribs,force);
    python::list pycontribs;
    for(unsigned int i=0;i<mol.getNumAtoms();++i){
      pycontribs.append(python::make_tuple(logpContribs[i],mrContribs[i]));
    }
    return pycontribs;
  }
  python::tuple calcCrippenDescriptors(const RDKit::ROMol &mol,bool includeHs=true,
				       bool force=false){
    double logp,mr;
    RDKit::Descriptors::calcCrippenDescriptors(mol,logp,mr,includeHs,force);
    return python::make_tuple(logp,mr);
  }

  RDKit::SparseIntVect<boost::int32_t> *GetAtomPairFingerprint(const RDKit::ROMol &mol,
                                                               unsigned int minLength,
                                                               unsigned int maxLength,
                                                               python::object fromAtoms,
                                                               python::object ignoreAtoms,
                                                               python::object atomInvariants){
    std::vector<boost::uint32_t> *fvect=pythonObjectToVect(fromAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *ivect=pythonObjectToVect(ignoreAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *invvect=pythonObjectToVect(atomInvariants,mol.getNumAtoms());
    RDKit::SparseIntVect<boost::int32_t> *res;
    res = RDKit::AtomPairs::getAtomPairFingerprint(mol,minLength,maxLength,
                                                   fvect,ivect,invvect);
    if(fvect) delete fvect;
    if(ivect) delete ivect;
    if(invvect) delete invvect;
    return res;
  }
  RDKit::SparseIntVect<boost::int32_t> *GetHashedAtomPairFingerprint(const RDKit::ROMol &mol,
                                                                     unsigned int nBits,
                                                                     unsigned int minLength,
                                                                     unsigned int maxLength,
                                                                     python::object fromAtoms,
                                                                     python::object ignoreAtoms,
                                                                     python::object atomInvariants){

    std::vector<boost::uint32_t> *fvect=pythonObjectToVect(fromAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *ivect=pythonObjectToVect(ignoreAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *invvect=pythonObjectToVect(atomInvariants,mol.getNumAtoms());
    RDKit::SparseIntVect<boost::int32_t> *res;
    res = RDKit::AtomPairs::getHashedAtomPairFingerprint(mol,nBits,minLength,maxLength,
                                                         fvect,ivect,invvect);
    if(fvect) delete fvect;
    if(ivect) delete ivect;
    if(invvect) delete invvect;
    return res;
  }

  RDKit::SparseIntVect<boost::int64_t> *GetTopologicalTorsionFingerprint(const RDKit::ROMol &mol,
                                                                         unsigned int targetSize,
                                                                         python::object fromAtoms,
                                                                         python::object ignoreAtoms,
                                                                         python::object atomInvariants){
    std::vector<boost::uint32_t> *fvect=pythonObjectToVect(fromAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *ivect=pythonObjectToVect(ignoreAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *invvect=pythonObjectToVect(atomInvariants,mol.getNumAtoms());
    if(targetSize*RDKit::AtomPairs::codeSize>64){
      std::ostringstream errout;
      errout << "Maximum supported topological torsion path length is " << 64/RDKit::AtomPairs::codeSize<<std::endl;
      throw_value_error(errout.str());
    }
    
    RDKit::SparseIntVect<boost::int64_t> *res;
    res = RDKit::AtomPairs::getTopologicalTorsionFingerprint(mol,targetSize,fvect,ivect,invvect);
    if(fvect) delete fvect;
    if(ivect) delete ivect;
    if(invvect) delete invvect;
    return res;
  }

  RDKit::SparseIntVect<boost::int64_t> *GetHashedTopologicalTorsionFingerprint(const RDKit::ROMol &mol,
                                                                               unsigned int nBits,
                                                                               unsigned int targetSize,
                                                                               python::object fromAtoms,
                                                                               python::object ignoreAtoms,
                                                                               python::object atomInvariants){
    std::vector<boost::uint32_t> *fvect=pythonObjectToVect(fromAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *ivect=pythonObjectToVect(ignoreAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *invvect=pythonObjectToVect(atomInvariants,mol.getNumAtoms());
    RDKit::SparseIntVect<boost::int64_t> *res;
    res = RDKit::AtomPairs::getHashedTopologicalTorsionFingerprint(mol,nBits,targetSize,fvect,ivect,
                                                                   invvect);
    if(fvect) delete fvect;
    if(ivect) delete ivect;
    if(invvect) delete invvect;
    return res;
  }

  ExplicitBitVect *GetHashedTopologicalTorsionFingerprintAsBitVect(const RDKit::ROMol &mol,
                                                                   unsigned int nBits,
                                                                   unsigned int targetSize,
                                                                   python::object fromAtoms,
                                                                   python::object ignoreAtoms,
                                                                   python::object atomInvariants,
                                                                   unsigned int nBitsPerEntry
                                                                   ){
    std::vector<boost::uint32_t> *fvect=pythonObjectToVect(fromAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *ivect=pythonObjectToVect(ignoreAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *invvect=pythonObjectToVect(atomInvariants,mol.getNumAtoms());
    ExplicitBitVect *res;
    res = RDKit::AtomPairs::getHashedTopologicalTorsionFingerprintAsBitVect(mol,nBits,targetSize,fvect,ivect,
                                                                            invvect,
                                                                            nBitsPerEntry);
    if(fvect) delete fvect;
    if(ivect) delete ivect;
    if(invvect) delete invvect;
    return res;
  }

  ExplicitBitVect *GetHashedAtomPairFingerprintAsBitVect(const RDKit::ROMol &mol,
                                                         unsigned int nBits,
                                                         unsigned int minLength,
                                                         unsigned int maxLength,
                                                         python::object fromAtoms,
                                                         python::object ignoreAtoms,
                                                         python::object atomInvariants,
                                                         unsigned int nBitsPerEntry
                                                         ){
    std::vector<boost::uint32_t> *fvect=pythonObjectToVect(fromAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *ivect=pythonObjectToVect(ignoreAtoms,mol.getNumAtoms());
    std::vector<boost::uint32_t> *invvect=pythonObjectToVect(atomInvariants,mol.getNumAtoms());
    ExplicitBitVect *res;
    res = RDKit::AtomPairs::getHashedAtomPairFingerprintAsBitVect(mol,nBits,
                                                                  minLength,maxLength,
                                                                  fvect,ivect,invvect,
                                                                  nBitsPerEntry);
    if(fvect) delete fvect;
    if(ivect) delete ivect;
    if(invvect) delete invvect;
    return res;
  }

  
  RDKit::SparseIntVect<boost::uint32_t> *GetMorganFingerprint(const RDKit::ROMol &mol,
                                                              int radius,
                                                              python::object invariants,
                                                              python::object fromAtoms,
                                                              bool useChirality,
                                                              bool useBondTypes,
                                                              bool useFeatures,
                                                              python::object bitInfo){
    std::vector<boost::uint32_t> *invars=0;
    if(invariants){
      unsigned int nInvar=python::extract<unsigned int>(invariants.attr("__len__")());
      if(nInvar){
        if(nInvar!=mol.getNumAtoms()){
          throw_value_error("length of invariant vector != number of atoms");
        }
        invars = new std::vector<boost::uint32_t>(mol.getNumAtoms());
        for(unsigned int i=0;i<mol.getNumAtoms();++i){
          (*invars)[i] = python::extract<boost::uint32_t>(invariants[i]);
        }
      }
    } else if(useFeatures){
      invars = new std::vector<boost::uint32_t>(mol.getNumAtoms());
      RDKit::MorganFingerprints::getFeatureInvariants(mol,*invars);
    }
    std::vector<boost::uint32_t> *froms=0;
    if(fromAtoms){
      unsigned int nFrom=python::extract<unsigned int>(fromAtoms.attr("__len__")());
      if(nFrom){
        froms = new std::vector<boost::uint32_t>();
        for(unsigned int i=0;i<nFrom;++i){
          froms->push_back(python::extract<boost::uint32_t>(fromAtoms[i]));
        }
      }
    }
    RDKit::MorganFingerprints::BitInfoMap *bitInfoMap=0;
    if(bitInfo!=python::object()){
      // make sure the optional argument actually was a dictionary
      python::dict typecheck=python::extract<python::dict>(bitInfo);
      bitInfoMap=new RDKit::MorganFingerprints::BitInfoMap();
    }
    RDKit::SparseIntVect<boost::uint32_t> *res;
    res = RDKit::MorganFingerprints::getFingerprint(mol,
                                                    static_cast<unsigned int>(radius),
                                                    invars,froms,useChirality,useBondTypes,
                                                    false,bitInfoMap);
    if(bitInfoMap){
      bitInfo.attr("clear")();
      for(RDKit::MorganFingerprints::BitInfoMap::const_iterator iter=bitInfoMap->begin();
          iter!=bitInfoMap->end();++iter){
        const std::vector<std::pair<boost::uint32_t,boost::uint32_t> > &v=iter->second;
        python::list localL;
        for(std::vector<std::pair<boost::uint32_t,boost::uint32_t> >::const_iterator vIt=v.begin();
            vIt!=v.end();++vIt){
          localL.append(python::make_tuple(vIt->first,vIt->second));
        }
        bitInfo[iter->first]=python::tuple(localL);
      }
      delete bitInfoMap;
    }
    if(invars) delete invars;
    if(froms) delete froms;
    return res;
  }

  ExplicitBitVect *GetMorganFingerprintBV(const RDKit::ROMol &mol,
                                          int radius,
                                          unsigned int nBits,
                                          python::object invariants,
                                          python::object fromAtoms,
                                          bool useChirality,
                                          bool useBondTypes,
                                          bool useFeatures,
                                          python::object bitInfo){
    std::vector<boost::uint32_t> *invars=0;
    if(invariants){
      unsigned int nInvar=python::extract<unsigned int>(invariants.attr("__len__")());
      if(nInvar){
        if(nInvar!=mol.getNumAtoms()){
          throw_value_error("length of invariant vector != number of atoms");
        }
        invars = new std::vector<boost::uint32_t>(mol.getNumAtoms());
        for(unsigned int i=0;i<mol.getNumAtoms();++i){
          (*invars)[i] = python::extract<boost::uint32_t>(invariants[i]);
        }
      }
    } else if(useFeatures){
      invars = new std::vector<boost::uint32_t>(mol.getNumAtoms());
      RDKit::MorganFingerprints::getFeatureInvariants(mol,*invars);
    }
    
    std::vector<boost::uint32_t> *froms=0;
    if(fromAtoms){
      unsigned int nFrom=python::extract<unsigned int>(fromAtoms.attr("__len__")());
      if(nFrom){
        froms = new std::vector<boost::uint32_t>();
        for(unsigned int i=0;i<nFrom;++i){
          froms->push_back(python::extract<boost::uint32_t>(fromAtoms[i]));
        }
      }
    }
    RDKit::MorganFingerprints::BitInfoMap *bitInfoMap=0;
    if(bitInfo!=python::object()){
      // make sure the optional argument actually was a dictionary
      python::dict typecheck=python::extract<python::dict>(bitInfo);
      bitInfoMap=new RDKit::MorganFingerprints::BitInfoMap();
    }
    ExplicitBitVect *res;
    res = RDKit::MorganFingerprints::getFingerprintAsBitVect(mol,
                                                             static_cast<unsigned int>(radius),
                                                             nBits,
                                                             invars,froms,useChirality,
                                                             useBondTypes,
                                                             false,bitInfoMap);
    if(bitInfoMap){
      bitInfo.attr("clear")();
      for(RDKit::MorganFingerprints::BitInfoMap::const_iterator iter=bitInfoMap->begin();
          iter!=bitInfoMap->end();++iter){
        const std::vector<std::pair<boost::uint32_t,boost::uint32_t> > &v=iter->second;
        python::list localL;
        for(std::vector<std::pair<boost::uint32_t,boost::uint32_t> >::const_iterator vIt=v.begin();
            vIt!=v.end();++vIt){
          localL.append(python::make_tuple(vIt->first,vIt->second));
        }
        bitInfo[iter->first]=python::tuple(localL);
      }
      delete bitInfoMap;
    }
    if(invars) delete invars;
    if(froms) delete froms;
    return res;
  }

  python::list GetConnectivityInvariants(const RDKit::ROMol &mol,bool includeRingMembership){
    std::vector<boost::uint32_t> invars(mol.getNumAtoms());
    RDKit::MorganFingerprints::getConnectivityInvariants(mol,invars,includeRingMembership);
    python::list res;
    for(std::vector<boost::uint32_t>::const_iterator iv=invars.begin();iv!=invars.end();++iv){
      res.append(python::long_(*iv));
    }
    return res;
  }
  python::list GetFeatureInvariants(const RDKit::ROMol &mol){
    std::vector<boost::uint32_t> invars(mol.getNumAtoms());
    RDKit::MorganFingerprints::getFeatureInvariants(mol,invars);
    python::list res;
    for(std::vector<boost::uint32_t>::const_iterator iv=invars.begin();iv!=invars.end();++iv){
      res.append(python::long_(*iv));
    }
    return res;
  }

  python::list CalcSlogPVSA(const RDKit::ROMol &mol,
                            python::object bins,
                            bool force){
    std::vector<double> *lbins=0;
    if(bins){
      unsigned int nBins=python::extract<unsigned int>(bins.attr("__len__")());
      if(nBins){
        lbins = new std::vector<double>(nBins,0.0);
        for(unsigned int i=0;i<nBins;++i){
          (*lbins)[i] = python::extract<double>(bins[i]);
        }
      }
    }
    std::vector<double> res;
    res=RDKit::Descriptors::calcSlogP_VSA(mol,lbins,force);

    python::list pyres;
    for(std::vector<double>::const_iterator iv=res.begin();iv!=res.end();++iv){
      pyres.append(*iv);
    }
    return pyres;
  }
  python::list CalcSMRVSA(const RDKit::ROMol &mol,
                            python::object bins,
                            bool force){
    std::vector<double> *lbins=0;
    if(bins){
      unsigned int nBins=python::extract<unsigned int>(bins.attr("__len__")());
      if(nBins){
        lbins = new std::vector<double>(nBins,0.0);
        for(unsigned int i=0;i<nBins;++i){
          (*lbins)[i] = python::extract<double>(bins[i]);
        }
      }
    }
    std::vector<double> res;
    res=RDKit::Descriptors::calcSMR_VSA(mol,lbins,force);

    python::list pyres;
    for(std::vector<double>::const_iterator iv=res.begin();iv!=res.end();++iv){
      pyres.append(*iv);
    }
    return pyres;
  }
  python::list CalcPEOEVSA(const RDKit::ROMol &mol,
                            python::object bins,
                            bool force){
    std::vector<double> *lbins=0;
    if(bins){
      unsigned int nBins=python::extract<unsigned int>(bins.attr("__len__")());
      if(nBins){
        lbins = new std::vector<double>(nBins,0.0);
        for(unsigned int i=0;i<nBins;++i){
          (*lbins)[i] = python::extract<double>(bins[i]);
        }
      }
    }
    std::vector<double> res;
    res=RDKit::Descriptors::calcPEOE_VSA(mol,lbins,force);

    python::list pyres;
    for(std::vector<double>::const_iterator iv=res.begin();iv!=res.end();++iv){
      pyres.append(*iv);
    }
    return pyres;
  }
}

BOOST_PYTHON_MODULE(rdMolDescriptors) {
  python::scope().attr("__doc__") =
    "Module containing functions to compute molecular descriptors"
    ;

  python::register_exception_translator<IndexErrorException>(&translate_index_error);
  python::register_exception_translator<ValueErrorException>(&translate_value_error);

  std::string docString = "";

  python::class_<python::object>("AtomPairsParameters")
    .setattr("version",
		  RDKit::AtomPairs::atomPairsVersion)
    .setattr("numTypeBits",
		  RDKit::AtomPairs::numTypeBits)
    .setattr("numPiBits",
		  RDKit::AtomPairs::numPiBits)
    .setattr("numBranchBits",
		  RDKit::AtomPairs::numBranchBits)
    .setattr("codeSize",
		  RDKit::AtomPairs::codeSize)
    .setattr("atomTypes",
		  atomPairTypes)
    .setattr("numPathBits",
		  RDKit::AtomPairs::numPathBits)
    .setattr("numAtomPairFingerprintBits",
		  RDKit::AtomPairs::numAtomPairFingerprintBits)
    ;
  docString="Returns the atom code (hash) for an atom";
  python::def("GetAtomPairAtomCode", RDKit::AtomPairs::getAtomCode,
              (python::arg("atom"), python::arg("branchSubtract")=0),
              docString.c_str());
  docString="Returns the atom-pair fingerprint for a molecule as an IntSparseIntVect";
  python::def("GetAtomPairFingerprint", GetAtomPairFingerprint,
              (python::arg("mol"),
               python::arg("minLength")=1,
               python::arg("maxLength")=RDKit::AtomPairs::maxPathLen-1,
               python::arg("fromAtoms")=0,
               python::arg("ignoreAtoms")=0,
               python::arg("atomInvariants")=0),
              docString.c_str(),
              python::return_value_policy<python::manage_new_object>());

  docString="Returns the hashed atom-pair fingerprint for a molecule as an IntSparseIntVect";
  python::def("GetHashedAtomPairFingerprint",
	      GetHashedAtomPairFingerprint,
	      (python::arg("mol"),
               python::arg("nBits")=2048,
               python::arg("minLength")=1,
               python::arg("maxLength")=RDKit::AtomPairs::maxPathLen-1,
               python::arg("fromAtoms")=0,
               python::arg("ignoreAtoms")=0,
               python::arg("atomInvariants")=0),
              docString.c_str(),
	      python::return_value_policy<python::manage_new_object>());

  docString="Returns the atom-pair fingerprint for a molecule as an ExplicitBitVect";
  python::def("GetHashedAtomPairFingerprintAsBitVect",
	      GetHashedAtomPairFingerprintAsBitVect,
	      (python::arg("mol"),
               python::arg("nBits")=2048,
               python::arg("minLength")=1,
               python::arg("maxLength")=RDKit::AtomPairs::maxPathLen-1,
               python::arg("fromAtoms")=0,
               python::arg("ignoreAtoms")=0,
               python::arg("atomInvariants")=0,
               python::arg("nBitsPerEntry")=4),
              docString.c_str(),
	      python::return_value_policy<python::manage_new_object>());

  docString="Returns the topological-torsion fingerprint for a molecule as a LongIntSparseIntVect";
  python::def("GetTopologicalTorsionFingerprint",
	      GetTopologicalTorsionFingerprint,
	      (python::arg("mol"),python::arg("targetSize")=4,
               python::arg("fromAtoms")=0,
               python::arg("ignoreAtoms")=0,
               python::arg("atomInvariants")=0),
              docString.c_str(),
	      python::return_value_policy<python::manage_new_object>());
  docString="Returns the hashed topological-torsion fingerprint for a molecule as a LongIntSparseIntVect";
  python::def("GetHashedTopologicalTorsionFingerprint",
	      GetHashedTopologicalTorsionFingerprint,
	      (python::arg("mol"),
               python::arg("nBits")=2048,
               python::arg("targetSize")=4,
               python::arg("fromAtoms")=0,
               python::arg("ignoreAtoms")=0,
               python::arg("atomInvariants")=0),
              docString.c_str(),
	      python::return_value_policy<python::manage_new_object>());
  docString="Returns the topological-torsion fingerprint for a molecule as an ExplicitBitVect";
  python::def("GetHashedTopologicalTorsionFingerprintAsBitVect",
	      GetHashedTopologicalTorsionFingerprintAsBitVect,
	      (python::arg("mol"),
               python::arg("nBits")=2048,
               python::arg("targetSize")=4,
               python::arg("fromAtoms")=0,
               python::arg("ignoreAtoms")=0,
               python::arg("atomInvariants")=0,
               python::arg("nBitsPerEntry")=4),
              docString.c_str(),
	      python::return_value_policy<python::manage_new_object>());

  docString="Returns a Morgan fingerprint for a molecule";
  python::def("GetMorganFingerprint", GetMorganFingerprint,
              (python::arg("mol"),python::arg("radius"),
               python::arg("invariants")=python::list(),
               python::arg("fromAtoms")=python::list(),
               python::arg("useChirality")=false,
               python::arg("useBondTypes")=true,
               python::arg("useFeatures")=false,
               python::arg("bitInfo")=python::object()),
              docString.c_str(),
              python::return_value_policy<python::manage_new_object>());
  docString="Returns a Morgan fingerprint for a molecule as a bit vector";
  python::def("GetMorganFingerprintAsBitVect", GetMorganFingerprintBV,
              (python::arg("mol"),python::arg("radius"),python::arg("nBits")=2048,
               python::arg("invariants")=python::list(),
               python::arg("fromAtoms")=python::list(),
               python::arg("useChirality")=false,
               python::arg("useBondTypes")=true,
               python::arg("useFeatures")=false,
               python::arg("bitInfo")=python::object()),
              docString.c_str(),
              python::return_value_policy<python::manage_new_object>());
  python::scope().attr("_MorganFingerprint_version")=
    RDKit::MorganFingerprints::morganFingerprintVersion;
  docString="Returns connectivity invariants (ECFP-like) for a molecule.";
  python::def("GetConnectivityInvariants", GetConnectivityInvariants,
              (python::arg("mol"),python::arg("includeRingMembership")=true),
              docString.c_str());
  python::scope().attr("_ConnectivityInvariants_version")=
    RDKit::MorganFingerprints::morganConnectivityInvariantVersion;

  docString="Returns feature invariants (FCFP-like) for a molecule.";
  python::def("GetFeatureInvariants", GetFeatureInvariants,
              (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_FeatureInvariants_version")=
    RDKit::MorganFingerprints::morganFeatureInvariantVersion;

  docString="returns (as a list of 2-tuples) the contributions of each atom to\n"
    "the Wildman-Cripppen logp and mr value";
  python::def("_CalcCrippenContribs",
	      computeCrippenContribs,
	      (python::arg("mol"),
	       python::arg("force")=false),
              docString.c_str());
  docString="returns a 2-tuple with the Wildman-Crippen logp,mr values";
  python::def("CalcCrippenDescriptors",
	      calcCrippenDescriptors,
	      (python::arg("mol"),python::arg("includeHs")=true,
	       python::arg("force")=false),
              docString.c_str());
  python::scope().attr("_CalcCrippenDescriptors_version")=
    RDKit::Descriptors::crippenVersion;
  
  docString="returns the Labute ASA value for a molecule";
  python::def("CalcLabuteASA",
	      RDKit::Descriptors::calcLabuteASA,
	      (python::arg("mol"),python::arg("includeHs")=true,
	       python::arg("force")=false),
              docString.c_str());
  python::scope().attr("_CalcLabuteASA_version")=RDKit::Descriptors::labuteASAVersion;

  docString="returns a list of atomic contributions to the Labute ASA";
  python::def("_CalcLabuteASAContribs",
	      computeASAContribs,
	      (python::arg("mol"),python::arg("includeHs")=true,
	       python::arg("force")=false),
              docString.c_str());

  docString="returns the TPSA value for a molecule";
  python::def("CalcTPSA",
	      RDKit::Descriptors::calcTPSA,
	      (python::arg("mol"),
	       python::arg("force")=false),
              docString.c_str());
  python::scope().attr("_CalcTPSA_version")=RDKit::Descriptors::tpsaVersion;

  docString="returns a list of atomic contributions to the TPSA";
  python::def("_CalcTPSAContribs",
	      computeTPSAContribs,
	      (python::arg("mol"),
	       python::arg("force")=false),
              docString.c_str());

  docString="returns the molecule's molecular weight";
  python::def("_CalcMolWt",
	      RDKit::Descriptors::calcAMW,
	      (python::arg("mol"),python::arg("onlyHeavy")=false),
              docString.c_str());
  python::scope().attr("_CalcMolWt_version")="1.0.0";

  docString="returns the molecule's exact molecular weight";
  python::def("CalcExactMolWt",
	      RDKit::Descriptors::calcExactMW,
	      (python::arg("mol"),python::arg("onlyHeavy")=false),
              docString.c_str());
  python::scope().attr("_CalcExactMolWt_version")="1.0.0";

  docString="returns the molecule's formula";
  python::def("CalcMolFormula",
	      RDKit::Descriptors::calcMolFormula,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcMolFormula_version")="1.0.0";

  docString="returns the number of Lipinski H-bond donors for a molecule";
  python::def("CalcNumLipinskiHBD",
	      RDKit::Descriptors::calcLipinskiHBD,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumLipinskiHBD_version")=RDKit::Descriptors::lipinskiHBDVersion;
  docString="returns the number of Lipinski H-bond acceptors for a molecule";
  python::def("CalcNumLipinskiHBA",
	      RDKit::Descriptors::calcLipinskiHBA,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumLipinskiHBA_version")=RDKit::Descriptors::lipinskiHBAVersion;
  docString="returns the number of H-bond donors for a molecule";
  python::def("CalcNumHBD",
	      RDKit::Descriptors::calcNumHBD,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumHBD_version")=RDKit::Descriptors::NumHBDVersion;
  docString="returns the number of H-bond acceptors for a molecule";
  python::def("CalcNumHBA",
	      RDKit::Descriptors::calcNumHBA,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumHBA_version")=RDKit::Descriptors::NumHBAVersion;
  docString="returns the number of rotatable bonds for a molecule";
  python::def("CalcNumRotatableBonds",
	      RDKit::Descriptors::calcNumRotatableBonds,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumRotatableBonds_version")=RDKit::Descriptors::NumRotatableBondsVersion;
  docString="returns the number of rings for a molecule";
  python::def("CalcNumRings",
	      RDKit::Descriptors::calcNumRings,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumRings_version")=RDKit::Descriptors::NumRingsVersion;
  docString="returns the number of heteroatoms for a molecule";
  python::def("CalcNumHeteroatoms",
	      RDKit::Descriptors::calcNumHeteroatoms,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumHeteroatoms_version")=RDKit::Descriptors::NumHeteroatomsVersion;
  docString="returns the number of amide bonds in a molecule";
  python::def("CalcNumAmideBonds",
	      RDKit::Descriptors::calcNumAmideBonds,
	      (python::arg("mol")),
              docString.c_str());
  python::scope().attr("_CalcNumAmideBonds_version")=RDKit::Descriptors::NumAmideBondsVersion;

  docString="returns the SlogP VSA contributions for a molecule";
  python::def("SlogP_VSA_",
              CalcSlogPVSA,
              (python::arg("mol"),
               python::arg("bins")=python::list(),
               python::arg("force")=false));
  docString="returns the SMR VSA contributions for a molecule";
  python::def("SMR_VSA_",
              CalcSMRVSA,
              (python::arg("mol"),
               python::arg("bins")=python::list(),
               python::arg("force")=false));
  docString="returns the PEOE VSA contributions for a molecule";
  python::def("PEOE_VSA_",
              CalcPEOEVSA,
              (python::arg("mol"),
               python::arg("bins")=python::list(),
               python::arg("force")=false));
  
}