Package rdkit :: Package DataStructs :: Module BitEnsemble
[hide private]
[frames] | no frames]

Source Code for Module rdkit.DataStructs.BitEnsemble

 1  # $Id: BitEnsemble.py 997 2009-02-25 06:12:43Z glandrum $ 
 2  # 
 3  # Copyright (C) 2003-2006 greg Landrum and Rational Discovery LLC 
 4  # 
 5  #   @@ All Rights Reserved  @@ 
 6  # 
 7  """ #DOC 
 8   
 9   
10  """ 
11   
12 -class BitEnsemble(object):
13 """ used to store a collection of bits and score 14 BitVects (or signatures) against them. 15 16 """
17 - def __init__(self,bits=None):
18 if bits is not None: 19 self._bits = list(bits) 20 else: 21 self._bits = []
22 - def SetBits(self,bits):
23 self._bits = list(bits)
24 - def AddBit(self,bit):
25 self._bits.append(bit)
26 - def GetBits(self):
27 return tuple(self._bits)
28 - def GetNumBits(self):
29 return len(self._bits)
30
31 - def ScoreWithOnBits(self,other):
32 """ other must support GetOnBits() """ 33 obl = other.GetOnBits() 34 cnt = 0 35 for bit in self.GetBits(): 36 if bit in obl: cnt += 1 37 return cnt
38 39
40 - def ScoreWithIndex(self,other):
41 """ other must support __getitem__() """ 42 cnt = 0 43 for bit in self.GetBits(): 44 if other[bit]: cnt += 1 45 return cnt
46 47 48 if __name__=='__main__': 49 50 pass 51