Reputation: 19
Been programming a program to determine various functional groups from an inputted molecule. Was working great until 2 days ago. Started getting the error below. Below is a simplified exerpt of the code that generates the same error. Any suggestions on how to resovle?
from rdkit import Chem`
from rdkit.Chem import Draw, Descriptors, rdqueries
m= Chem.MolFromSmiles("CCCCCC")
print(m.GetSubstructMatches("[CX4]"))
I have checked the SMILES input and the SMARTs input for validity, created a new environment and freshly installed the rdkit library, and restarted my kernel. To no avail.
ArgumentError Traceback (most recent call last) Cell In[2], line 4 2 from rdkit.Chem import Draw, Descriptors, rdqueries 3 m= Chem.MolFromSmiles("CCCCCC") 4 print(m.GetSubstructMatches(m,"[CX4]"))
File ~\anaconda3\envs\ThermoSim\lib\site-packages\rdkit\Chem\Draw\IPythonConsole.py:212, in _GetSubstructMatches(mol, query, *args, **kwargs) 211 def _GetSubstructMatches(mol, query, *args, **kwargs): 212 res = mol.__GetSubstructMatches(query, *args, **kwargs) 213 mol.__sssAtoms = [] 214 if highlightSubstructs:
ArgumentError: Python argument types in Mol.GetSubstructMatches(Mol, Mol, str) did not match C++ signature: GetSubstructMatches(class RDKit::ROMol self, class RDKit::MolBundle query, struct RDKit::SubstructMatchParameters params) GetSubstructMatches(class RDKit::ROMol self, class RDKit::ROMol query, struct RDKit::SubstructMatchParameters params) GetSubstructMatches(class RDKit::ROMol self, class RDKit::MolBundle query, bool uniquify=True, bool useChirality=False, bool useQueryQueryMatches=False, unsigned int maxMatches=1000) GetSubstructMatches(class RDKit::ROMol self, class RDKit::ROMol query, bool uniquify=True, bool useChirality=False, bool useQueryQueryMatches=False, unsigned int maxMatches=1000)
Upvotes: 1
Views: 331
Reputation: 1948
As you can see here Mol.GetSubstructMatches()
is not able to transfer a string into a SMARTS-mol object. Hence you need to do this before via Chem.MolFromSmarts()
.
from rdkit import Chem
m = Chem.MolFromSmiles("CCCCCC")
print(m.GetSubstructMatches(Chem.MolFromSmarts("[CX4]")))
# output:
>>> ((0,), (1,), (2,), (3,), (4,), (5,))
Upvotes: 1