I can't seem to reproduce the problem.

Here's an example showing that the original atom coordinates are preserved
when Chem.AddHs is called with the addCoords argument:

#--------------------------------

In [9]: mb="""
   ...:   Mrv0541 08211405312D
   ...:
   ...:   6  6  0  0  0  0            999 V2000
   ...:    -3.5578    0.8250    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
 0
   ...:    -4.2723    0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
 0
   ...:    -4.2723   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
 0
   ...:    -3.5578   -0.8250    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
 0
   ...:    -1.8268   -0.7219    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
 0
   ...:    -2.8433    0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
 0
   ...:   1  2  1  0  0  0  0
   ...:   1  6  2  0  0  0  0
   ...:   2  3  2  0  0  0  0
   ...:   3  4  1  0  0  0  0
   ...:   4  5  2  0  0  0  0
   ...:   5  6  1  0  0  0  0
   ...: M  END
   ...: """

In [10]: m = Chem.MolFromMolBlock(mb)

In [11]: nm = Chem.AddHs(m,addCoords=True)

In [12]: print Chem.MolToMolBlock(nm)

     RDKit          2D

 12 12  0  0  0  0  0  0  0  0999 V2000
   -3.5578    0.8250    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.2723    0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.2723   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.5578   -0.8250    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.8268   -0.7219    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8433    0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.5578    1.9250    0.0000 H   0  0  0  0  0  1  0  0  0  0  0  0
   -5.2249    0.9625    0.0000 H   0  0  0  0  0  1  0  0  0  0  0  0
   -5.2249   -0.9625    0.0000 H   0  0  0  0  0  1  0  0  0  0  0  0
   -3.8108   -1.8955    0.0000 H   0  0  0  0  0  1  0  0  0  0  0  0
   -0.8095   -1.1404    0.0000 H   0  0  0  0  0  1  0  0  0  0  0  0
   -2.1500    1.2665    0.0000 H   0  0  0  0  0  1  0  0  0  0  0  0
  1  2  2  0
  1  6  1  0
  2  3  1  0
  3  4  2  0
  4  5  1  0
  5  6  2  0
  1  7  1  0
  2  8  1  0
  3  9  1  0
  4 10  1  0
  5 11  1  0
  6 12  1  0
M  END

#--------------------------------

Note that addCoords does add the Hs in 3D:

#--------------------------------

In [5]: print Chem.MolToMolBlock(m)

     RDKit          2D

  2  1  0  0  0  0  0  0  0  0999 V2000
   -0.7500    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7500   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
M  END

In [7]: nm=Chem.AddHs(m,addCoords=True)

In [8]: print Chem.MolToMolBlock(nm)

     RDKit          2D

  8  7  0  0  0  0  0  0  0  0999 V2000
   -0.7500    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7500   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1167    0.0000    1.0371 H   0  0  0  0  0  1  0  0  0  0  0  0
   -1.1167    0.8981   -0.5185 H   0  0  0  0  0  1  0  0  0  0  0  0
   -1.1167   -0.8981   -0.5185 H   0  0  0  0  0  1  0  0  0  0  0  0
    1.1167   -0.0000    1.0371 H   0  0  0  0  0  1  0  0  0  0  0  0
    1.1167   -0.8981   -0.5185 H   0  0  0  0  0  1  0  0  0  0  0  0
    1.1167    0.8981   -0.5185 H   0  0  0  0  0  1  0  0  0  0  0  0
  1  2  1  0
  1  3  1  0
  1  4  1  0
  1  5  1  0
  2  6  1  0
  2  7  1  0
  2  8  1  0
M  END

#--------------------------------

It is probably feasible to modify the code to add Hs in 2D when the
conformer is 2D, but it's likely a non-trivial amount of work and, as
Dimitri pointed out, there are many situations where the results aren't
going to look particularly good.

-greg



On Wed, Aug 20, 2014 at 7:34 PM, Greg Landrum <[email protected]>
wrote:

>
>
> On Wednesday, August 20, 2014, Michał Nowotka <[email protected]> wrote:
>
>>
>> I've just checked and actually adding this flag doesn't solve my problem.
>> It seems that adding this flag actually calls Compute2dCoords (at
>> least this is how it looks like), because all coordinates are computed
>> from scratch, for example if my compound was translated by some vector
>> on 2D plane, after executing addHs it will be centered, if the
>> compound had one atom dragged unusually, it will be aligned back.
>>
>> The only difference between this flag and calling Compute2dCoords is
>> that H bonds are longer, which actually looks worse...
>>
>>
> Hmmm, that doesn't sound like what is supposed to happen.  I think that
> it should just add coords for the Hs that it adds. I will take a look
> tomorrow morning to see what is going on. There may be something odd for
> 2d conformers, but I  really don't think it should redo the whole
> coordinate generation.
>
> -greg
>
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to