Dear Joey,

you could use Chem.RenumberAtoms() to enforce Hs to always follow heavy
atoms in the atom list, e.g.:

from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
IPythonConsole.drawOptions.addAtomIndices = True
IPythonConsole.molSize = (400, 400)

mol1 = Chem.AddHs(Chem.MolFromSmiles("CCN"))
mol2 = Chem.AddHs(Chem.MolFromSmiles("OCC"))
mol3 = Chem.CombineMols(mol1, mol2)
print(Chem.MolToMolBlock(mol3))

     RDKit          2D

 19 17  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000   -1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.7500    1.2990    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.7500   -1.2990    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5000    4.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    4.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    4.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.2500    2.7010    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    5.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000    2.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.0000    4.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    2.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    5.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
  2  3  1  0
  1  4  1  0
  1  5  1  0
  1  6  1  0
  2  7  1  0
  2  8  1  0
  3  9  1  0
  3 10  1  0
 11 12  1  0
 12 13  1  0
 11 14  1  0
 12 15  1  0
 12 16  1  0
 13 17  1  0
 13 18  1  0
 13 19  1  0
M  END

mol3
[image: image.png]
new_order = [a.GetIdx() for a in mol3.GetAtoms() if a.GetAtomicNum() > 1] +
[a.GetIdx() for a in mol3.GetAtoms() if a.GetAtomicNum() == 1]
mol4 = Chem.RenumberAtoms(mol3, new_order)
print(Chem.MolToMolBlock(mol4))

     RDKit          2D

 19 17  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5000    4.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    4.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    4.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000   -1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    1.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.7500    1.2990    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.7500   -1.2990    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
   -2.2500    2.7010    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    5.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000    2.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    3.0000    4.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    2.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.5000    5.5000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
  2  3  1  0
  1  7  1  0
  1  8  1  0
  1  9  1  0
  2 10  1  0
  2 11  1  0
  3 12  1  0
  3 13  1  0
  4  5  1  0
  5  6  1  0
  4 14  1  0
  5 15  1  0
  5 16  1  0
  6 17  1  0
  6 18  1  0
  6 19  1  0
M  END

mol4
[image: image.png]
Cheers,
p.

On Tue, Mar 1, 2022 at 6:36 AM Storer, Joey (J) via Rdkit-discuss <
rdkit-discuss@lists.sourceforge.net> wrote:

> Dear All,
>
>
>
> I have experienced a few consistency problems in 3D coordinate output with
> H’s not always at the end of the coordinate list.
>
>
>
> RDKit mostly does this by default except in a few cases every few thousand
> and even with simple organics.
>
>
>
> How can I check/verify/enforce “H’s at the end” on coordinate output?
>
>
>
> *Example sequence is:*
>
> mol_1 = Chem.MolFromSmiles(smile)
>
> mol_2 = Chem.AddHs(mol_1)
>
> AllChem.EmbedMolecule(mol_2)
>
> symbols = [a.GetSymbol() for a in mol_2.GetAtoms()]   *# need H’s to be
> last in the list (always)*
>
>
>
> Thanks!
>
> Joey Storer
>
> Dow, Inc.
>
> General Business
> _______________________________________________
> Rdkit-discuss mailing list
> 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