From 6d691887974d914f17d57fa6fa01ebe9cc96113d Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 17 May 2017 18:15:21 -0700 Subject: [PATCH] Add more precision to output rotation matrices. In order for viewers to be able to reconstruct a rotation matrix that's reasonably close to orthogonal, we need to output the elements with more than 3 digits or precision. Increase to 6 digits. Relates ihmwg/IHM-dictionary#30. --- pyext/src/mmcif.py | 5 ++++- test/test_mmcif.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyext/src/mmcif.py b/pyext/src/mmcif.py index f94ff214..f1e9944d 100644 --- a/pyext/src/mmcif.py +++ b/pyext/src/mmcif.py @@ -1036,7 +1036,10 @@ def dump_fitting(self, writer): for r in self.restraints: trans = r.get_transformation(m) rot = trans.get_rotation() - rm = [rot.get_rotation_matrix_row(i) for i in range(3)] + # mmCIF writer usually outputs floats to 3 decimal places, + # but we need more precision for rotation matrices + rm = [["%.6f" % e for e in rot.get_rotation_matrix_row(i)] + for i in range(3)] t = trans.get_translation() ccc = r.get_cross_correlation(m) l.write(ordinal_id=ordinal, restraint_id=r.id, diff --git a/test/test_mmcif.py b/test/test_mmcif.py index e5d0624f..e9532fa8 100644 --- a/test/test_mmcif.py +++ b/test/test_mmcif.py @@ -1538,8 +1538,8 @@ class DummyProtocol(object): _ihm_2dem_class_average_fitting.tr_vector[1] _ihm_2dem_class_average_fitting.tr_vector[2] _ihm_2dem_class_average_fitting.tr_vector[3] -1 1 1 0.873 -0.407 -0.910 -0.087 0.379 -0.255 0.889 -0.831 0.329 0.449 304.187 -219.586 0.000 +1 1 1 0.873 -0.406503 -0.909500 -0.086975 0.379444 -0.254653 0.889480 -0.831131 +0.328574 0.448622 304.187 219.586 0.000 # """)