0

I have generated a list of smiles strings and defined them as 'result'

I'd like to convert each SMILES string in the list to separate mol files using RDKit. My current code is this:

m = Chem.MolFromSmiles('result')
print(Chem.MolToMolBlock(m))

This script does not work and returns:

ArgumentError: Python argument types in rdkit.Chem.rdmolfiles.MolToMolBlock(NoneType) did not match C++ signature: MolToMolBlock(RDKit::ROMol mol, bool includeStereo=True, int confId=-1, bool kekulize=True, bool forceV3000=False)

How would I go about correcting this?

Thanks!

Graham
  • 7,431
  • 18
  • 59
  • 84

1 Answers1

2

You converted the string 'result' to a RDKit mol object. And this could not not be transformed to a Molblock. Variable names are not strings, so don't use them with quotes.

First you have to convert the SMILES one by one to mol objects.

from rdkit import Chem
result = ['C', 'CC', 'CCC']
mo = [Chem.MolFromSmiles(r) for r in result]

Then you can print the Molblocks one by one.

for m in mo:
    print(Chem.MolToMolBlock(m))

That will give you this:

     RDKit          2D

  1  0  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
M  END


     RDKit          2D

  2  1  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2990    0.7500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
M  END


     RDKit          2D

  3  2  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2990    0.7500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.5981   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
  2  3  1  0
M  END
rapelpy
  • 1,684
  • 1
  • 11
  • 14