4
$\begingroup$

In SMILES I would think that $\ce{XeF6}$ would be F[Xe](F)(F)(F)(F)F or F[Xe](F)(F)(F)(F)(F). A quick Wikipedia search showed that the first result is the correct SMILES string. However, rdkit isn't able to convert either SMILES strings into a structure.

Here is my code:

from IPython.display import SVG
from rdkit import Chem
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D
# Create mol object from smiles string
# mol = Chem.MolFromSmiles('[B](C7OC7)(CCC3CCCC31N2CN([P]5CCCC8C5)C2(CO8)CC1)(C6CCC6)')
# The above molecule was me learning SMILES, below is the Xenon Hexafluoride string
mol = Chem.MolFromSmiles('F[Xe](F)(F)(F)(F)')
molSize=(900,300)
mc = Chem.Mol(mol.ToBinary())
if not mc.GetNumConformers():
    #Compute 2D coordinates
    rdDepictor.Compute2DCoords(mc)
# init the drawer with the size
drawer = rdMolDraw2D.MolDraw2DSVG(molSize[0],molSize[1])
#draw the molcule
drawer.DrawMolecule(mc)
drawer.FinishDrawing()
# get the SVG string
svg = drawer.GetDrawingText()
# fix the svg string and display it
display(SVG(svg.replace('svg:','')))
$\endgroup$
6
  • 3
    $\begingroup$ You may want to post this question in Matter Modeling SE instead which is well suited to answer such questions. If you do decide to migrate the question please delete the current one. Good luck! $\endgroup$
    – Buck Thorn
    Commented Feb 5, 2021 at 9:29
  • 3
    $\begingroup$ Missing the sixth F? $\endgroup$
    – Andrew
    Commented Feb 5, 2021 at 11:44
  • $\begingroup$ Oh yeah Andrew you're right (doesn't fix issue though) and will do Buck Thorn. $\endgroup$ Commented Feb 5, 2021 at 20:28
  • 1
    $\begingroup$ With the last version of RDKit (2020.09) it works for me. $\endgroup$
    – rapelpy
    Commented Feb 6, 2021 at 6:24
  • 1
    $\begingroup$ @SohilKollipara If you are still interested in this or found an answer since then, you can copy the question to Matter Modeling and remove the version here. $\endgroup$
    – Tyberius
    Commented Jan 11, 2022 at 18:04

1 Answer 1

2
$\begingroup$

If you start with RDKit, I suggest to work through the examples of RDKit's cookbook. With minor adjustments, paste the following into a cell of a Jupyter notebook as a minimal, self sufficient working example (MWE)

from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
IPythonConsole.ipython_useSVG=True

mol = Chem.MolFromSmiles("F[Xe](F)(F)(F)(F)F")
mol

to obtain the following illustration:

enter image description here

The setup used: Jupyter 6.4.5, Python 3.9.9, RDKit 2021.09.2 as currently repackaged e.g., by Linux Debian 12/bookworm, branch testing (package tracker). Stay tuned to the project's GitHub page to know if there is a new release (currently 2021.09.4, just two days old) more frequently packaged for conda.


There is something odd with the code provided by you. Copy-pasted into the same Jupyter notebook, the molecule plot contains a dot about an unpaired electron:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.