rdkit.DataStructs.cDataStructs module¶
Module containing an assortment of functionality for basic data structures.
- At the moment the data structures defined are:
- Bit Vector classes (for storing signatures, fingerprints and the like:
- ExplicitBitVect: class for relatively small (10s of thousands of bits) or
dense bit vectors.
SparseBitVect: class for large, sparse bit vectors
DiscreteValueVect: class for storing vectors of integers SparseIntVect: class for storing sparse vectors of integers
- class rdkit.DataStructs.cDataStructs.DiscreteValueType(*values)¶
Bases:
Enum- EIGHTBITVALUE = 3¶
- FOURBITVALUE = 2¶
- ONEBITVALUE = 0¶
- SIXTEENBITVALUE = 4¶
- TWOBITVALUE = 1¶
- class rdkit.DataStructs.cDataStructs.DiscreteValueVect(self)¶
- class rdkit.DataStructs.cDataStructs.DiscreteValueVect(self, valType: rdkit.DataStructs.cDataStructs.DiscreteValueType, length: int)
- class rdkit.DataStructs.cDataStructs.DiscreteValueVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.DiscreteValueVect(self, pkl: str)
Bases:
objectA container class for storing unsigned integer values within a particular range.
The length of the vector and type of its elements (determines the maximum value that can be stored) are both set at construction time.
As you would expect, _DiscreteValueVects_ support a set of binary operations so you can do things like:
dvv3 = dvv1 & dvv2 the result contains the smallest value in each entry dvv3 = dvv1 | dvv2 the result contains the largest value in each entry dvv1 += dvv2 values are truncated when necessary dvv3 = dvv1 + dvv2 values are truncated when necessary dvv1 -= dvv3 would-be negative values are set to zero dvv3 = dvv1 - dvv2 would-be negative values are set to zero
Elements can be set and read using indexing (i.e. bv[i] = 4 or val=bv[i])
- GetTotalVal(self) int¶
Get the sum of the values in the vector, basically L1 norm
- GetValueType(self) rdkit.DataStructs.cDataStructs.DiscreteValueType¶
Get the type of value stored in the vector
- class rdkit.DataStructs.cDataStructs.ExplicitBitVect(self)¶
- class rdkit.DataStructs.cDataStructs.ExplicitBitVect(self, size: int)
- class rdkit.DataStructs.cDataStructs.ExplicitBitVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.ExplicitBitVect(self, pkl: str)
- class rdkit.DataStructs.cDataStructs.ExplicitBitVect(self, size: int, bitsSet: bool)
Bases:
objectA class to store explicit bit vectors.
This class is most useful for situations where the size of the vector is relatively small (tens of thousands or smaller).
For larger vectors, use the _SparseBitVect_ class instead.
As you would expect, _ExplicitBitVects_ support a set of binary operations so you can do things like:
bv3 = bv1 & bv2 (bitwise and) bv3 = bv1 | bv2 (bitwise or) bv3 = bv1 ^ bv2 (bitwise xor) bv3 = ~bv1 (bitwise negation)
Bits can be set and read using either the Set/UnsetBit() and GetBit() methods or by indexing (i.e. bv[i] = 1 or if bv[i]).
- GetBit(self, which: int) bool¶
Returns the value of a bit.
- GetNumBits(self) int¶
Returns the number of bits in the vector (the vector’s size).
- GetNumOffBits(self) int¶
Returns the number of off bits.
- GetNumOnBits(self) int¶
Returns the number of on bits.
- GetOnBits(self) list[int]¶
Returns a tuple containing IDs of the on bits.
- SetBit(self, which: int) bool¶
Turns on a particular bit. Returns the original state of the bit.
- SetBitsFromList(self, onBitList: collections.abc.Iterable) None¶
Turns on a set of bits. The argument should be a tuple or list of bit ids.
- ToBase64(self) str¶
Converts the vector to a base64 string (the base64 encoded version of the results of ToString()).
- ToBinary(self) bytes¶
Returns an internal binary representation of the vector.
- ToBitString()¶
- ToList(self) list¶
Return the Bitvector as a python list (faster than list(vect))
- UnSetBit(self, which: int) bool¶
Turns off a particular bit. Returns the original state of the bit.
- class rdkit.DataStructs.cDataStructs.FPBReader(self, filename: str, lazy: bool = False)¶
Bases:
objectA class for reading and searching FPB files from Andrew Dalke’s chemfp. Note that this functionality is still experimental and the API may change in future releases.
docstring
- GetBytes(self, which: int) bytes¶
returns a particular fingerprint as bytes
- GetContainingNeighbors(self, bv: bytes) tuple¶
returns indices of neighbors that contain this fingerprint (where all bits from this fingerprint are also set)
- GetFP(self, idx: int) rdkit.DataStructs.cDataStructs.ExplicitBitVect¶
returns a particular fingerprint as an ExplicitBitVect
- GetId(self, idx: int) str¶
returns the id of a particular fingerprint
- GetNumBits(self) int¶
returns the number of bits in a fingerprint
- GetTanimoto(self, which: int, bytes: bytes) float¶
return the tanimoto similarity of a particular fingerprint to the bytes provided
- GetTanimotoNeighbors(self, bv: bytes, threshold: float = 0.7) tuple¶
returns tanimoto similarities to and indices of all neighbors above the specified threshold
- GetTversky(self, which: int, bytes: bytes, ca: float, cb: float) float¶
return the Tverksy similarity of a particular fingerprint to the bytes provided
- GetTverskyNeighbors(self, bv: bytes, ca: float, cb: float, threshold: float = 0.7) tuple¶
returns Tversky similarities to and indices of all neighbors above the specified threshold
- class rdkit.DataStructs.cDataStructs.IntSparseIntVect(self)¶
- class rdkit.DataStructs.cDataStructs.IntSparseIntVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.IntSparseIntVect(self, pkl: str)
- class rdkit.DataStructs.cDataStructs.IntSparseIntVect(self, arg: int, /)
Bases:
objectA container class for storing integer values within a particular range.
The length of the vector is set at construction time.
As you would expect, _SparseIntVects_ support a set of binary operations so you can do things like:
Arithmetic: siv1 += siv2 siv3 = siv1 + siv2 siv1 -= siv3 siv3 = siv1 - siv2 “Fuzzy” binary operations: siv3 = siv1 & siv2 the result contains the smallest value in each entry siv3 = siv1 | siv2 the result contains the largest value in each entry
Elements can be set and read using indexing (i.e. siv[i] = 4 or val=siv[i])
Overloaded function.
__init__(self) -> None
Constructor
__init__(self, pkl: bytes) -> None__init__(self, pkl: str) -> None__init__(self, arg: int, /) -> None
Constructor
- GetLength(self) int¶
Returns the length of the vector
- GetNonzeroElements(self) dict¶
returns a dictionary of the nonzero elements
- GetTotalVal(self, useAbs: bool = False) int¶
Get the sum of the values in the vector, basically L1 norm
- ToBinary(self) bytes¶
returns a binary (pickle) representation of the vector
- ToList(self) list¶
Return the SparseIntVect as a python list
- class rdkit.DataStructs.cDataStructs.LongSparseIntVect(self)¶
- class rdkit.DataStructs.cDataStructs.LongSparseIntVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.LongSparseIntVect(self, pkl: str)
- class rdkit.DataStructs.cDataStructs.LongSparseIntVect(self, arg: int, /)
Bases:
objectA container class for storing integer values within a particular range.
The length of the vector is set at construction time.
As you would expect, _SparseIntVects_ support a set of binary operations so you can do things like:
Arithmetic: siv1 += siv2 siv3 = siv1 + siv2 siv1 -= siv3 siv3 = siv1 - siv2 “Fuzzy” binary operations: siv3 = siv1 & siv2 the result contains the smallest value in each entry siv3 = siv1 | siv2 the result contains the largest value in each entry
Elements can be set and read using indexing (i.e. siv[i] = 4 or val=siv[i])
Overloaded function.
__init__(self) -> None
Constructor
__init__(self, pkl: bytes) -> None__init__(self, pkl: str) -> None__init__(self, arg: int, /) -> None
Constructor
- GetLength(self) int¶
Returns the length of the vector
- GetNonzeroElements(self) dict¶
returns a dictionary of the nonzero elements
- GetTotalVal(self, useAbs: bool = False) int¶
Get the sum of the values in the vector, basically L1 norm
- ToBinary(self) bytes¶
returns a binary (pickle) representation of the vector
- ToList(self) list¶
Return the SparseIntVect as a python list
- class rdkit.DataStructs.cDataStructs.MultiFPBReader(self, initOnSearch: bool = False)¶
Bases:
objectA class for reading and searching multiple FPB files from Andrew Dalke’s chemfp. Note that this functionality is still experimental and the API may change in future releases.
docstring
- AddReader(self, rdr: rdkit.DataStructs.cDataStructs.FPBReader) int¶
adds an FPBReader to our set of readers
- GetContainingNeighbors(self, bv: bytes, numThreads: int = 1) tuple¶
returns indices of neighbors that contain this fingerprint (where all bits from this fingerprint are also set)
- GetNumBits(self) int¶
returns the number of bits in a fingerprint
- GetReader(self, which: int) rdkit.DataStructs.cDataStructs.FPBReader¶
returns one of our readers
- GetTanimotoNeighbors(self, bv: bytes, threshold: float = 0.7, numThreads: int = 1) tuple¶
returns tanimoto similarities to and indices of all neighbors above the specified threshold
- GetTverskyNeighbors(self, bv: bytes, ca: float, cb: float, threshold: float = 0.7, numThreads: int = 1) tuple¶
returns Tversky similarities to and indices of all neighbors above the specified threshold
- class rdkit.DataStructs.cDataStructs.RealValueVect(self)¶
- class rdkit.DataStructs.cDataStructs.RealValueVect(self, length: int)
- class rdkit.DataStructs.cDataStructs.RealValueVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.RealValueVect(self, pkl: str)
Bases:
objectA container class for storing real values.
The length of the vector is set at construction time.
As you would expect, _RealValueVects_ support a set of binary operations so you can do things like:
rvv3 = rvv1 & rvv2 the result contains the smallest value in each entry rvv3 = rvv1 | rvv2 the result contains the largest value in each entry rvv1 += rvv2 rvv3 = rvv1 + rvv2 rvv1 -= rvv3 rvv3 = rvv1 - rvv2
Elements can be set and read using indexing (i.e. bv[i] = 4 or val=bv[i])
- GetTotalVal(self) float¶
Get the sum of the values in the vector, basically L1 norm
- class rdkit.DataStructs.cDataStructs.SparseBitVect(self)¶
- class rdkit.DataStructs.cDataStructs.SparseBitVect(self, size: int)
- class rdkit.DataStructs.cDataStructs.SparseBitVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.SparseBitVect(self, pkl: str)
Bases:
objectA class to store sparse bit vectors.
This class is most useful for situations where the size of the vector is large and relatively few bits are set
For smaller or denser vectors, the _ExplicitBitVect_ class is much faster.
As you would expect, _SparseBitVects_ support a set of binary operations so you can do things like:
bv3 = bv1 & bv2 (bitwise and) bv3 = bv1 | bv2 (bitwise or) bv3 = bv1 ^ bv2 (bitwise xor) bv3 = ~bv1 (bitwise negation) NOTE: this operation is likely
to be VERY slow and inefficient.
Bits can be set and read using either the Set/UnsetBit() and GetBit() methods or by indexing (i.e. bv[i] = 1 or if bv[i]).
- GetBit(self, which: int) bool¶
Returns the value of a bit.
- GetNumBits(self) int¶
Returns the number of bits in the vector (the vector’s size).
- GetNumOffBits(self) int¶
Returns the number of off bits.
- GetNumOnBits(self) int¶
Returns the number of on bits.
- GetOnBits(self) list[int]¶
Returns a tuple containing IDs of the on bits.
- SetBit(self, which: int) bool¶
Turns on a particular bit. Returns the original state of the bit.
- SetBitsFromList(self, onBitList: collections.abc.Iterable) None¶
Turns on a set of bits. The argument should be a tuple or list of bit ids.
- ToBase64(self) str¶
Converts the vector to a base64 string (the base64 encoded version of the results of ToString()).
- ToBinary(self) bytes¶
Returns an internal binary representation of the vector.
- ToBitString()¶
- ToList(self) list¶
Return the BitVector as a python list.
- UnSetBit(self, which: int) bool¶
Turns off a particular bit. Returns the original state of the bit.
- class rdkit.DataStructs.cDataStructs.UIntSparseIntVect(self)¶
- class rdkit.DataStructs.cDataStructs.UIntSparseIntVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.UIntSparseIntVect(self, pkl: str)
- class rdkit.DataStructs.cDataStructs.UIntSparseIntVect(self, arg: int, /)
Bases:
objectA container class for storing integer values within a particular range.
The length of the vector is set at construction time.
As you would expect, _SparseIntVects_ support a set of binary operations so you can do things like:
Arithmetic: siv1 += siv2 siv3 = siv1 + siv2 siv1 -= siv3 siv3 = siv1 - siv2 “Fuzzy” binary operations: siv3 = siv1 & siv2 the result contains the smallest value in each entry siv3 = siv1 | siv2 the result contains the largest value in each entry
Elements can be set and read using indexing (i.e. siv[i] = 4 or val=siv[i])
Overloaded function.
__init__(self) -> None
Constructor
__init__(self, pkl: bytes) -> None__init__(self, pkl: str) -> None__init__(self, arg: int, /) -> None
Constructor
- GetLength(self) int¶
Returns the length of the vector
- GetNonzeroElements(self) dict¶
returns a dictionary of the nonzero elements
- GetTotalVal(self, useAbs: bool = False) int¶
Get the sum of the values in the vector, basically L1 norm
- ToBinary(self) bytes¶
returns a binary (pickle) representation of the vector
- ToList(self) list¶
Return the SparseIntVect as a python list
- class rdkit.DataStructs.cDataStructs.ULongSparseIntVect(self)¶
- class rdkit.DataStructs.cDataStructs.ULongSparseIntVect(self, pkl: bytes)
- class rdkit.DataStructs.cDataStructs.ULongSparseIntVect(self, pkl: str)
- class rdkit.DataStructs.cDataStructs.ULongSparseIntVect(self, arg: int, /)
Bases:
objectA container class for storing integer values within a particular range.
The length of the vector is set at construction time.
As you would expect, _SparseIntVects_ support a set of binary operations so you can do things like:
Arithmetic: siv1 += siv2 siv3 = siv1 + siv2 siv1 -= siv3 siv3 = siv1 - siv2 “Fuzzy” binary operations: siv3 = siv1 & siv2 the result contains the smallest value in each entry siv3 = siv1 | siv2 the result contains the largest value in each entry
Elements can be set and read using indexing (i.e. siv[i] = 4 or val=siv[i])
Overloaded function.
__init__(self) -> None
Constructor
__init__(self, pkl: bytes) -> None__init__(self, pkl: str) -> None__init__(self, arg: int, /) -> None
Constructor
- GetLength(self) int¶
Returns the length of the vector
- GetNonzeroElements(self) dict¶
returns a dictionary of the nonzero elements
- GetTotalVal(self, useAbs: bool = False) int¶
Get the sum of the values in the vector, basically L1 norm
- ToBinary(self) bytes¶
returns a binary (pickle) representation of the vector
- ToList(self) list¶
Return the SparseIntVect as a python list