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

Class VectCollection

source code

object --+
         |
        VectCollection



>>> vc = VectCollection()
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((1,3,5))
>>> vc.AddVect(1,bv1)
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((6,8))
>>> vc.AddVect(2,bv1)
>>> len(vc)
10
>>> vc.GetNumBits()
10
>>> vc[0]
0
>>> vc[1]
1
>>> vc[9]
0
>>> vc[6]
1
>>> vc.GetBit(6)
1
>>> list(vc.GetOnBits())
[1, 3, 5, 6, 8]

keys must be unique, so adding a duplicate replaces the
previous values:
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((7,9))
>>> vc.AddVect(1,bv1)
>>> len(vc)
10
>>> vc[1]
0
>>> vc[9]
1
>>> vc[6]
1

we can also query the children:
>>> vc.NumChildren()
2
>>> cs = vc.GetChildren()
>>> id,fp = cs[0]
>>> id
1
>>> list(fp.GetOnBits())
[7, 9]
>>> id,fp = cs[1]
>>> id
2
>>> list(fp.GetOnBits())
[6, 8]

attach/detach operations:
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((5,6))
>>> vc.AddVect(3,bv1)
>>> vc.NumChildren()
3
>>> list(vc.GetOnBits())
[5, 6, 7, 8, 9]
>>> vc.DetachVectsNotMatchingBit(6)
>>> vc.NumChildren()
2
>>> list(vc.GetOnBits())
[5, 6, 8]


>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((7,9))
>>> vc.AddVect(1,bv1)
>>> vc.NumChildren()
3
>>> list(vc.GetOnBits())
[5, 6, 7, 8, 9]
>>> vc.DetachVectsMatchingBit(6)
>>> vc.NumChildren()
1
>>> list(vc.GetOnBits())
[7, 9]


to copy VectCollections, use the copy module:
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((5,6))
>>> vc.AddVect(3,bv1)
>>> list(vc.GetOnBits())
[5, 6, 7, 9]
>>> vc2 = copy.copy(vc)
>>> vc.DetachVectsNotMatchingBit(6)
>>> list(vc.GetOnBits())
[5, 6]
>>> list(vc2.GetOnBits())
[5, 6, 7, 9]

The Uniquify() method can be used to remove duplicate vectors:
>>> vc = VectCollection()
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((7,9))
>>> vc.AddVect(1,bv1)
>>> vc.AddVect(2,bv1)
>>> bv1 = DataStructs.ExplicitBitVect(10)
>>> bv1.SetBitsFromList((2,3,5))
>>> vc.AddVect(3,bv1)
>>> vc.NumChildren()
3
>>> vc.Uniquify()
>>> vc.NumChildren()
2

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
GetOrVect(self) source code
 
AddVect(self, id, vect) source code
 
Reset(self) source code
 
NumChildren(self) source code
 
GetChildren(self) source code
 
GetBit(self, id) source code
 
GetNumBits(self) source code
 
GetOnBits(self) source code
 
DetachVectsNotMatchingBit(self, bit) source code
 
DetachVectsMatchingBit(self, bit) source code
 
Uniquify(self, verbose=False) source code
 
__len__(self) source code
 
__getitem__(self, id) source code
 
__getstate__(self) source code
 
__setstate__(self, pkl) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  orVect

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Property Details [hide private]

orVect

Get Method:
GetOrVect(self)