1

I have a list of 298 SMILES and I want to turn those 298 into mol objects however rdkit is giving me the above error.

TypeError: No registered converter was able to produce a C++  

 rvalue of type std::basic_string<wchar_t, 
  std::char_traits<wchar_t>, std::allocator<wchar_t> > from this 
  Python object of type float

This is my code:

for mol in str_smiles:
  Chem.MolFromSmiles(mol)
  mol_object_list.append(mol)

Can someone tell what's wrong?

Vandan Revanur
  • 459
  • 6
  • 17
Cris Silva
  • 11
  • 2

1 Answers1

1

First of all, the code you presented won't work because you need to assign the object to something first. Something like this:

mol_object_list = []
for smi in str_smiles:
    mol = Chem.MolFromSmiles(smi)
    mol_object_list.append(mol)

Coming back to your error, the error occurs when the SMILES string input is invalid. It's possible some of the SMILES in str_smiles list are wrong. Try the following piece of code to figure out which ones:

mol_object_list = []
for smi in str_smiles:
    try:  # Try converting the SMILES to mol object
        mol = Chem.MolFromSmiles(smi)
        mol_object_list.append(mol)
    except:  # Print the SMILES if there was an error in converting
        print(smi)

The SMILES that are printed are invalid and you have to fix them.

P.S. I'm assuming that str_smiles is a python list.

betelgeuse
  • 1,136
  • 3
  • 13
  • 25