4
$\begingroup$

I'm newish to RDKit and couldn't find an answer to this online. The following is a minimal representation of how I drew a molecule

from rdkit import Chem
from rdkit.Chem import Draw as Draw
from rdkit.Chem.rdMolDescriptors import CalcMolFormula

# .. read mol_a from file... then
print(repr(mol_a))
<rdkit.Chem.rdchem.Mol object at 0x7fd5c5494dc0>

print(CalcMolFormula(mol_a))
C4H11N

Draw.MolToImageFile(mol_a, 'pic.png')

Here is what I get:

Chemical drawing

What are those red boxes?

I'm running Ubuntu 16.04, Python 3.7.3

I had three semesters of college chemistry about a decade ago.

Thanks!

$\endgroup$
5
$\begingroup$

In your 3d data some atoms have the same coordinates.

If all coordinates are singular like here

from rdkit.Chem import AllChem as Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw

mb1 ='''
     RDKit          3D

 16 15  0  0  0  0  0  0  0  0999 V2000
   -1.4420   -0.8874   -0.7989 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.3758    0.0725   -0.4996 N   0  0  0  0  0  0  0  0  0  0  0  0
   -0.9154    1.1745    0.2995 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7376   -0.6096    0.1788 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.9820    0.2624    0.3084 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0693   -1.6891   -1.4463 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.8570   -1.3405    0.1088 H   0  0  0  0  0  0  0  0  0  0  0  0
   -2.2571   -0.4005   -1.3461 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.1723    1.9659    0.4378 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.2580    0.8409    1.2857 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.7617    1.6439   -0.2155 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.4357   -0.9719    1.1698 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.0275   -1.4907   -0.4080 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.8280    1.0937    1.0028 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.2816    0.6703   -0.6627 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.8161   -0.3344    0.6923 H   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
  1  6  1  0
  1  7  1  0
  1  8  1  0
  3  9  1  0
  3 10  1  0
  3 11  1  0
  4 12  1  0
  4 13  1  0
  5 14  1  0
  5 15  1  0
  5 16  1  0
M  END'''

You get a pic without the red box.

mol1 = Chem.MolFromMolBlock(mb1, removeHs=False)
Draw.MolToImage(mol1)

enter image description here

If I give the H on position 15 the coordinates from the C from position 5

mb2 ='''
     RDKit          3D

 16 15  0  0  0  0  0  0  0  0999 V2000
   -1.4420   -0.8874   -0.7989 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.3758    0.0725   -0.4996 N   0  0  0  0  0  0  0  0  0  0  0  0
   -0.9154    1.1745    0.2995 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7376   -0.6096    0.1788 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.9820    0.2624    0.3084 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0693   -1.6891   -1.4463 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.8570   -1.3405    0.1088 H   0  0  0  0  0  0  0  0  0  0  0  0
   -2.2571   -0.4005   -1.3461 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.1723    1.9659    0.4378 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.2580    0.8409    1.2857 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.7617    1.6439   -0.2155 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.4357   -0.9719    1.1698 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.0275   -1.4907   -0.4080 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.8280    1.0937    1.0028 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.9820    0.2624    0.3084 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.8161   -0.3344    0.6923 H   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
  1  6  1  0
  1  7  1  0
  1  8  1  0
  3  9  1  0
  3 10  1  0
  3 11  1  0
  4 12  1  0
  4 13  1  0
  5 14  1  0
  5 15  1  0
  5 16  1  0
M  END'''

you get the red box

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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