Hi Per
Just by looking at your code I would assume you have a sanitization issue. You 
create your pentane molecule and then add H’s. This will saturate each single 
carbon. When you then add a bond between the two fragments your atom 3 will 
have a valence of 5 and this causes issues.
Maybe do the fragment combination first and then add the H’s? Or do an explicit 
handling of the correct carbon you link to upfront.
Hope this helps

From: "Per Jr. Greisen" <pgrei...@gmail.com>
Date: Sunday 6 August 2017 at 19:55
To: RDKit <rdkit-discuss@lists.sourceforge.net>
Subject: [Rdkit-discuss] adding fragment to existing molecule

Hi all,

I am trying to add a fragment to an existing molecule using RDkit - I start by 
generating the desired molecules I would like to combine:

oh = '[OH-]'
ohh = Chem.MolFromSmiles(oh)
oh = Chem.AddHs(ohh)
AllChem.EmbedMolecule(oh, AllChem.ETKDG())

smiles_ = 'CCCCC'
m = Chem.MolFromSmiles(smiles_)
m_h = Chem.AddHs(vxm)
AllChem.EmbedMolecule(m_h, AllChem.ETKDG())

I combine them which works fine:

combo = Chem.CombineMols(m_h,oh)

and I can add the bond between the desired atoms:

edcombo = Chem.EditableMol(combo)

back = edcombo.GetMol()

The problems arises when I want to edit the geometry between the two :

from rdkit.Chem import rdMolTransforms as rdmt
conf = back.GetConformer(0)


writer3 = Chem.SDWriter('out_long.sdf')

RuntimeError                              Traceback (most recent call last)

<ipython-input-193-36d3c0480a45> in <module>()

      2 conf = back.GetConformer(0)


----> 4 rdmt.SetBondLength(conf,3,43,10)


      6 writer3 = Chem.SDWriter('out_long.sdf')

RuntimeError: Pre-condition Violation

        RingInfo not initialized

        Violation occurred on line 66 in file Code/GraphMol/RingInfo.cpp

        Failed Expression: df_init

        RDKIT: 2017.03.3

        BOOST: 1_56

So I am not sure how fix - thanks in advance

With kind regards

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Rdkit-discuss mailing list

Reply via email to