rdkit.DataStructs.VectCollection module — The RDKit 2016.09.1 documentation

# rdkit.DataStructs.VectCollection module

class `rdkit.DataStructs.VectCollection.` `VectCollection`

  Bases: `object`

      >>> 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

  `AddVect`(idx, vect)
  `DetachVectsMatchingBit`(bit)
  `DetachVectsNotMatchingBit`(bit)
  `GetBit`(idx)
  `GetChildren`()
  `GetNumBits`()
  `GetOnBits`()
  `GetOrVect`()
  `NumChildren`()
  `Reset`()
  `Uniquify`(verbose=False)
  `orVect`