Skip to content

Commit

Permalink
Add more precision to output rotation matrices.
Browse files Browse the repository at this point in the history
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/IHMCIF#30.
  • Loading branch information
benmwebb committed May 18, 2017
1 parent 617e08c commit 6d69188
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pyext/src/mmcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/test_mmcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
""")

Expand Down

0 comments on commit 6d69188

Please sign in to comment.