我是 Rdkit 的新手。我需要以整数/计数形式生成指纹。我尝试了很多替代方法,但总是收到以下信息:
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)
我的代码如下:
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)
我还想知道 Rdkit 中是否有一种方法可以将指纹直接打印到文本文件中,类似于Chem.SDwrite
但要保存指纹?但是,如果我可以将计数指纹转换为数组,那么我可以使用 Python 代码保存到文本文件。