I'm new to Rdkit. I need to generate fingerprint in integer/count form. I have tried many alternatives but always I get the message:
DataStructs.ConvertToNumpyArray(fps2[i], arr[i])
ArgumentError: Python argument types in
rdkit.DataStructs.cDataStructs.ConvertToNumpyArray(UIntSparseIntVect, numpy.ndarray)
did not match C++ signature:
ConvertToNumpyArray(RDKit::DiscreteValueVect bv, boost::python::api::object destArray)
ConvertToNumpyArray(ExplicitBitVect bv, boost::python::api::object destArray)
My Code as below:
import numpy as np
from rdkit.Chem import AllChem as Chem
from rdkit import DataStructs
from rdkit.Chem.AtomPairs import Pairs
suppl = Chem.SDMolSupplier('5ht3ligs.sdf')
fps1 = [Chem.RDKFingerprint(x, fpSize=1024, minPath=1, maxPath=4) for x in suppl]
fps2 = [Chem.GetHashedMorganFingerprint(x, radius=2, nBits=1024) for x in suppl]
fps3 = [Chem.GetMorganFingerprint(x, radius=2, useCounts= True) for x in suppl]
fps4 = [Pairs.GetAtomPairFingerprintAsIntVect(x) for x in suppl]
arr = np.zeros((4,1024), dtype = np.int8)
for i in range(0,len(suppl)):
DataStructs.ConvertToNumpyArray(fps2[i], arr[i])
print(arr)
I am also wondering if there is a way in Rdkit to print the fingerprint directly to the text file similar to Chem.SDwrite
but to save fingerprint? However, If I can convert the count fingerprint to an array then I can use Python code to save to text file.