I'm working with RDKit and have the following issue. I'm trying to create a function that encode a molecule from a SMILES string into a fingerprint. But an ArgumentError occurs and I can't figure it out.
This is my code:
def get_fp(dfx, method="maccs", n_bits=2048):
ligands = [Chem.MolFromSmiles(mol) for mol in dfx.canonical_smiles]
if method == "morgan2":
data1 = []
for mol in ligands:
ecfp4 = [int(x) for x in AllChem.GetMorganFingerprintAsBitVect(mol, 2, n_Bits=n_bits)]
data1.append(ecfp4)
ecfp4_df = pd.DataFrame(data1, index=dfx.index)
return ecfp4_df
if method == "morgan3":
data2 = []
for mol in ligands:
ecfp6 = [int(x) for x in AllChem.GetMorganFingerprintAsBitVect(mol, 3, n_Bits=n_bits)]
data2.append(ecfp6)
ecfp6_df = pd.DataFrame(data2, index=dfx.index)
return ecfp6_df
if method == "maccs":
data3 = []
for mol in ligands:
maccs = [int(x) for x in MACCSkeys.GenMACCSKeys(mol)]
data3.append(maccs)
maccs_df = pd.DataFrame(data3, index=dfx.index)
return maccs_df
For "maccs" method it worked but for morgan didn't. I think it is a function problem but I cannot debug it... This is the error:
ArgumentError: Python argument types in rdkit.Chem.rdMolDescriptors.GetMorganFingerprintAsBitVect(Mol, int) did not match C++ signature: GetMorganFingerprintAsBitVect(class RDKit::ROMol mol, unsigned int radius, unsigned int nBits=2048, class boost::python::api::object invariants=[], class boost::python::api::object fromAtoms=[], bool useChirality=False, bool useBondTypes=True, bool useFeatures=False, class boost::python::api::object bitInfo=None, bool includeRedundantEnvironments=False)
Thanks