Package rdkit :: Package ML :: Package Descriptors :: Module Descriptors
[hide private]
[frames] | no frames]

Source Code for Module rdkit.ML.Descriptors.Descriptors

 1  # 
 2  #  Copyright (C) 2001,2002  greg Landrum and Rational Discovery LLC 
 3  # 
 4  """ Various bits and pieces for calculating descriptors 
 5   
 6  """ 
 7  from __future__ import print_function 
 8  from rdkit.six.moves import cPickle 
 9   
10   
11 -class DescriptorCalculator:
12 """ abstract base class for descriptor calculators 13 14 """ 15
16 - def __init__(self, *args, **kwargs):
17 """ Constructor 18 19 """ 20 self.simpleList = None 21 self.descriptorNames = None 22 self.compoundList = None
23 24 # ------------ 25 # methods used to calculate descriptors 26 # ------------ 27
28 - def ShowDescriptors(self):
29 """ prints out a list of the descriptors 30 31 """ 32 if self.simpleList is None: 33 raise NotImplementedError('Need to have a simpleList defined') 34 print('#---------') 35 print('Simple:') 36 for desc in self.simpleList: 37 print(desc) 38 if self.compoundList: 39 print('#---------') 40 print('Compound:') 41 for desc in self.compoundList: 42 print(desc)
43
44 - def GetDescriptorNames(self):
45 """ returns a list of the names of the descriptors this calculator generates 46 47 """ 48 raise NotImplementedError('abstract base class')
49
50 - def SaveState(self, fileName):
51 """ Writes this calculator off to a file so that it can be easily loaded later 52 53 **Arguments** 54 55 - fileName: the name of the file to be written 56 57 """ 58 try: 59 f = open(fileName, 'wb+') 60 except Exception: 61 print('cannot open output file %s for writing' % (fileName)) 62 return 63 cPickle.dump(self, f) 64 f.close()
65
66 - def CalcDescriptors(self, what, *args, **kwargs):
67 raise NotImplementedError('abstract base class')
68