88
99import mrcfile
1010import numpy as np
11+ import pytest
1112from click .testing import CliRunner
1213from pandas import DataFrame
1314
@@ -275,7 +276,7 @@ def createTestCtfFiles(self, index):
275276 starfile = StarFile (blocks = blocks )
276277 starfile .write (star_fp )
277278
278- def createTestRelionCtfFile (self ):
279+ def createTestRelionCtfFile (self , reverse_optics_block_rows = False ):
279280 """
280281 Creates example RELION-generated CTF file for a set of micrographs.
281282 """
@@ -295,6 +296,11 @@ def createTestRelionCtfFile(self):
295296 ["opticsGroup1" , 1 , 500.0 , 700.0 , 600.0 , 400.0 ],
296297 ["opticsGroup2" , 2 , 501.0 , 701.0 , 601.0 , 401.0 ],
297298 ]
299+ # Since optics block rows are self-contained,
300+ # reversing their order should have no affect anywhere.
301+ if reverse_optics_block_rows :
302+ optics_block = optics_block [::- 1 ]
303+
298304 blocks ["optics" ] = DataFrame (optics_block , columns = optics_columns )
299305
300306 micrographs_columns = [
@@ -539,6 +545,16 @@ def testImportCtfFromRelion(self):
539545 self ._testCtfFilters (src )
540546 self ._testCtfMetadata (src )
541547
548+ @pytest .mark .xfail (strict = True )
549+ def testImportCtfFromRelionReverseOpticsGroup (self ):
550+ self .relion_ctf_file = self .createTestRelionCtfFile (
551+ reverse_optics_block_rows = True
552+ )
553+ src = BoxesCoordinateSource (self .files_box )
554+ src .import_relion_ctf (self .relion_ctf_file )
555+ self ._testCtfFilters (src )
556+ self ._testCtfMetadata (src )
557+
542558 def testImportCtfFromRelionLegacy (self ):
543559 src = BoxesCoordinateSource (self .files_box )
544560 src .import_relion_ctf (self .relion_legacy_ctf_file )
0 commit comments