diff --git a/tests/test_coordinate_source.py b/tests/test_coordinate_source.py index a2c1edb83a..2b45de9218 100644 --- a/tests/test_coordinate_source.py +++ b/tests/test_coordinate_source.py @@ -8,6 +8,7 @@ import mrcfile import numpy as np +import pytest from click.testing import CliRunner from pandas import DataFrame @@ -275,7 +276,7 @@ def createTestCtfFiles(self, index): starfile = StarFile(blocks=blocks) starfile.write(star_fp) - def createTestRelionCtfFile(self): + def createTestRelionCtfFile(self, reverse_optics_block_rows=False): """ Creates example RELION-generated CTF file for a set of micrographs. """ @@ -295,6 +296,11 @@ def createTestRelionCtfFile(self): ["opticsGroup1", 1, 500.0, 700.0, 600.0, 400.0], ["opticsGroup2", 2, 501.0, 701.0, 601.0, 401.0], ] + # Since optics block rows are self-contained, + # reversing their order should have no affect anywhere. + if reverse_optics_block_rows: + optics_block = optics_block[::-1] + blocks["optics"] = DataFrame(optics_block, columns=optics_columns) micrographs_columns = [ @@ -539,6 +545,16 @@ def testImportCtfFromRelion(self): self._testCtfFilters(src) self._testCtfMetadata(src) + @pytest.mark.xfail(strict=True) + def testImportCtfFromRelionReverseOpticsGroup(self): + self.relion_ctf_file = self.createTestRelionCtfFile( + reverse_optics_block_rows=True + ) + src = BoxesCoordinateSource(self.files_box) + src.import_relion_ctf(self.relion_ctf_file) + self._testCtfFilters(src) + self._testCtfMetadata(src) + def testImportCtfFromRelionLegacy(self): src = BoxesCoordinateSource(self.files_box) src.import_relion_ctf(self.relion_legacy_ctf_file)