SDWriter in rdkit

I have a fever since yesterday… ;-(
But not Flu.
I hope I’ll get well soon……

By the way, I have a problem about molecular chirality handling in rdkit.
I often use SDWriter for write molecules as SDF format. The function write molecule as V2000 format.
I wander can rdkit write molecule as v3000?
The answer is Yes.
Here is sample code.
SetForceV3000 method can change the file format.

from rdkit import Chem
mol = Chem.MolFromSmiles("N[C@@H](C)C(O)=O")
w2000 = Chem.SDWriter("2000.sdf")
w3000 = Chem.SDWriter("3000.sdf")
w3000.SetForceV3000(1)
w3000.write(mol)
w3000.close()
w2000.write(mol)
w2000.close()

Check results.

In [14]: %cat 2000.sdf

     RDKit          

  6  5  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
  2  3  1  0
  2  4  1  0
  4  5  1  0
  4  6  2  0
M  END
$$$$

In [15]: %cat 3000.sdf

     RDKit          

  0  0  0  0  0  0  0  0  0  0999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 6 5 0 0 0
M  V30 BEGIN ATOM
M  V30 1 N 0 0 0 0
M  V30 2 C 0 0 0 0
M  V30 3 C 0 0 0 0
M  V30 4 C 0 0 0 0
M  V30 5 O 0 0 0 0
M  V30 6 O 0 0 0 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 2 1 2 3
M  V30 3 1 2 4
M  V30 4 1 4 5
M  V30 5 2 4 6
M  V30 END BOND
M  V30 END CTAB
M  END
$$$$

Works fine. I’ll go straight to bed.

Published by iwatobipen

I'm medicinal chemist in mid size of pharmaceutical company. I love chemoinfo, cording, organic synthesis, my family.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: