Jason,

    Exactly what I need to do.  Thank you for your example code.  Much 
appreciated.


    Regards,
    Jim Metz





-----Original Message-----
From: Jason Biggs <jasondbi...@gmail.com>
To: James T. Metz <jamestm...@aol.com>
Cc: RDKit Discuss <rdkit-discuss@lists.sourceforge.net>
Sent: Thu, Nov 9, 2017 3:28 pm
Subject: Re: [Rdkit-discuss] transformation of an atom or group of atoms by 
atom indices



Something along these lines?





mol = Chem.MolFromSmiles('CCCC')
emol = Chem.EditableMol(mol)
emol.ReplaceAtom(3, Chem.Atom(1))
mol = emol.GetMol()





In [12]:


Chem.MolToSmiles(mol)





Out[12]:

'[H]CCC'




In [13]:


Chem.MolToSmiles(Chem.RemoveHs(mol))





Out[13]:

'CCC'










Jason Biggs




On Thu, Nov 9, 2017 at 3:12 PM, James T. Metz via Rdkit-discuss 
<rdkit-discuss@lists.sourceforge.net> wrote:

RDKit Discussion Group,


    Suppose I have a molecule



smiles1 = 'CCCC'


    The carbon atoms will be assigned indices 0, 1, 2, and 3.



    Suppose I want to specifically change carbon 3 to a hydrogen.
Is this possible using RDkit?


    I am aware of using SMARTS to match a pattern and then change

that group of atoms.  In my example, I would like to be able to
change an atom or group of atoms based on the atom indices, not
a SMARTS pattern which might be problematic for molecules with
local symmetry.


    Regards,

    Jim Metz






------------------------------------------------------------------------------
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