The other answers on this thread have been right on point with the
exception of neglecting to explicitly encourage you to call
Chem.SanitizeMol() on your joined molecule before you do anything else with
it. In your case you'd call:
Chem.SanitizeMol(back)
This will lead to the error that Nik explains...

Christos (in a different reply) provides the two possible strategies I'd
recommend for combining fragments:
1) using dummy atoms to mark the attachment points on the fragments,
combing the fragments, forming a bond between the atoms that are bonded to
the dummy atoms, and then removing the dummy atoms
2) using a chemical reaction. I'd probably also use dummy atoms here to
mark attachment points.

Note that this whole process will give you a single molecule with the two
fragments combined and bonded to each other with a bond having the
appropriate length (you set that explicitly) but it won't orient the
fragments automatically. You'd probably like the bonds between the atoms to
connect and their dummy atoms to be antiparallel to each other when you
actually connect the fragments. Once you've done the geometry to figure out
the appropriate rotations, the RDKit has the code required to do the
rotations. Note that you should do this on one of the fragments before
combining them.

(very) pseudo code for what I think you want to do:

   1. Add Hs to fragments that have attachment points.
   2. Generate conformations for each fragment
   3. Figure out the connection vectors for each fragment. This is the
   vector from the atom to be connected to its dummy atom. Let's call these
   CV1 (for fragment 1) and CV2 (for fragment 2)
   4. Translate fragment 2 to the origin
   5. Rotate fragment 2 so that CV2 is anti-parallel to CV1
   6. Translate fragment 2 so that it's atom to be connected is at the same
   position as the dummy atom from fragment 1 (note: you could also set the
   target bond length now, skipping step 11 below, but that's a bit of
   additional prep work)
   7. Combine fragment 1 and fragment 2 to form mol 1
   8. remove the attachment points in mol1
   9. form a bond between the two atoms that should be connected in mol 1
   10. sanitize mol 1
   11. set the bond length

If you use the reaction based approach, you'd skip steps 7-9 because mol 1
would come from the reaction.

I hope this helps; it's not a trivial task, so feel free to keep asking
followup questions if there's something you don't understand.

-greg



On Mon, Aug 7, 2017 at 5:46 PM, Per Jr. Greisen <pgrei...@gmail.com> wrote:

> Hi Nikolaus and Ling,
>
> Thanks for your help (the atom numbe shouldnt be 43 but it still gives the
> error I will clarify)- yes Nikolaus you are right it is a sanitization
> issue and in this case I am trying to use it as a molecular editor to build
> a model molecule (a transition state model to be exact) - I would normally
> do this calling some other script but it would be very nice to do all of it
> in the framework of RDkit - can this be done? Thanks
>
> On Mon, Aug 7, 2017 at 12:05 PM, Stiefl, Nikolaus <
> nikolaus.sti...@novartis.com> wrote:
>
>> 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
>>
>> Nik
>>
>>
>>
>>
>>
>> *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)
>>
>> oh.SetProp("_Name","OH-")
>>
>> AllChem.EmbedMolecule(oh, AllChem.ETKDG())
>>
>>
>>
>> smiles_ = 'CCCCC'
>>
>> m = Chem.MolFromSmiles(smiles_)
>>
>> m_h = Chem.AddHs(vxm)
>>
>> m_h.SetProp("_Name","XP")
>>
>> 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)
>>
>>
>>
>> edcombo.AddBond(3,1,order=Chem.rdchem.BondType.SINGLE)
>>
>> 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)
>>
>>
>>
>> rdmt.SetBondLength(conf,3,43,10)
>>
>>
>>
>> writer3 = Chem.SDWriter('out_long.sdf')
>>
>> writer3.write(back,confId=0)
>>
>>
>>
>>
>>
>>
>>
>> RuntimeError                              Traceback (most recent call last)
>>
>> <ipython-input-193-36d3c0480a45> in <module>()
>>
>> *      2* conf = back.GetConformer(0)
>>
>> *      3*
>>
>> ----> 4 rdmt.SetBondLength(conf,3,43,10)
>>
>> *      5*
>>
>> *      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
>>
>>
>> Per
>>
>
>
>
> --
> With kind regards
>
> Per
>
> ------------------------------------------------------------
> ------------------
> 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
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
------------------------------------------------------------------------------
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to