Rocco,

Great. You nailed it!

Many thanks.

Tim

On 04/09/2019 17:41, Rocco Moretti wrote:
I think the issue is that you're making an explicit bond to a Xenon atom, and Xenon's valence model in the RDKit says that it has either zero bond or it has two bonds. (Don't worry - it's not really something you should have known /a priori /- valence models are funky. <https://nextmovesoftware.com/blog/2013/02/27/explicit-and-implicit-hydrogens-taking-liberties-with-valence/>)

list( Chem.GetPeriodicTable().GetValenceList("Xe") ) # Returns [0, 2]

Since you have at least one bond to Xenon (to the carbon), you can't have zero bonds, so you must have two bonds, so RDKit fills in the missing valence with an implicit hydrogen:

atom.GetTotalValence() # returns 2
atom.GetNumImplicitHs() # returns 1

The hydrogen is implicit, so removing the hydrogens with Chem.RemoveHs() won't do anything.

This then interacts with the Smiles code. The Smiles model says that if you have an atom in brackets (which Xenon always is), you need to explicitly record the hydrogens it has. (See here <https://baoilleach.blogspot.com/2017/01/counting-hydrogens-in-smiles-string.html > for more.)

Ways around it: The easiest would be if you could change your element to something which takes a single valence, or something that doesn't have valences for implicit hydrogen purposes. (Astatine is a decent choice for the former, many of the the actinides work well for the latter.) If you really do want to use Xenon, you can always manually flag the atom to not have any implicit hydrogens.*
*
*
*
*...*
xe = Chem.Atom(54) # 54 is Xenon
*xe.SetNoImplicit(True)*
idx = mw.AddAtom(xe)
mw.AddBond(0,6,Chem.BondType.SINGLE)
Chem.SanitizeMol(mw)
atom = mw.GetAtomWithIdx(idx)
atom.GetExplicitValence() # returns 1
atom.GetTotalValence() *# returns 1*
atom.GetNumImplicitHs() *# returns 0***
Chem.MolToSmiles(mw) *# returns '[Xe]c1ccccc1'*

On Wed, Sep 4, 2019 at 9:35 AM Tim Dudgeon <tdudgeon...@gmail.com <mailto:tdudgeon...@gmail.com>> wrote:

    I'm finding that if I add a Xenon atom to a molecule it seems to
    get an
    unwanted hydrogen added to it.
    Example notebook here:
    https://gist.github.com/tdudgeon/ba3497341d9de95b4d78f3e5ed9fc0f7

    Basic code is like this:

    from rdkit import Chem
    m = Chem.MolFromSmiles("c1ccccc1")
    mw = Chem.RWMol(m)
    xe = Chem.Atom(54) # 54 is Xenon
    idx = mw.AddAtom(xe)
    mw.AddBond(0,6,Chem.BondType.SINGLE)
    Chem.SanitizeMol(mw)
    atom = mw.GetAtomWithIdx(idx)
    atom.GetExplicitValence() # returns 1
    Chem.MolToSmiles(mw) # returns [XeH]c1ccccc1, expecting [Xe]c1ccccc1

    Even if I do a Chem.RemoveHs() the H remains.

    Any ideas why and how to fix?





    _______________________________________________
    Rdkit-discuss mailing list
    Rdkit-discuss@lists.sourceforge.net
    <mailto:Rdkit-discuss@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to