Hi Michal,

V2000 format is restricted by its specification to fixed format with 4 decimals. V3000 output is not restricted to a fixed format, but the current code still rounds it in practice as seen below.

To get extra precision you could change the formatting of x, y, and z coordinate output in Code/GraphMol/FileParsers/MolFileWriter.cpp, function GetV3000MolFileAtomLine(), look for the

    ss << " " << x << " " << y << " " << z;

line. Adding extra digits to the X, Y, and Z coordinates *should* not cause issues for compliant V3000 readers.

Cheers
-- Jan

>>> import rdkit
>>> from rdkit import Chem
>>> from Chem import AllChem
>>> m = Chem.MolFromSmiles('CC')
>>> AllChem.Compute2DCoords(m)
0
>>> m.GetConformer(0).SetAtomPosition(0, rdkit.Geometry.Point3D(0.123456789, 0.2, 0.3))
>>> print(Chem.MolToMolBlock(m))
     RDKit          2D

  2  1  0  0  0  0  0  0  0  0999 V2000
    0.1235    0.2000    0.3000 C   0  0  0  0  0  0  0 0  0  0  0  0    <== 4 decimal digits
    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

>>> print(Chem.MolToMolBlock(m, forceV3000=True))

     RDKit          2D

  0  0  0  0  0  0  0  0  0  0999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 2 1 0 0 0
M  V30 BEGIN ATOM
M  V30 1 C 0.123457 0.2 0.3 0    <== 6 decimal digits
M  V30 2 C 0.75 -5.55112e-17 0 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 END BOND
M  V30 END CTAB
M  END

>>>

On 2018-10-05 11:42, Michal Krompiec wrote:
Hello,
Is it possible to control the number of significant digits of XYZ coordinates? I am modifying coordinates of my molecules using SetAtomPosition but when I save them into an SDF it seems that the precision is limited to 4 digits after the decimal point (I'd like 10 instead...).
Best wishes,
Michal

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

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

Reply via email to