From 8133e9ab32a490deac5ac7b7a70bf99cd6afde87 Mon Sep 17 00:00:00 2001 From: Marten Chaillet <58044494+McHaillet@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:00:36 +0200 Subject: [PATCH] Fix relion5 compat (#220) * fix: starfile write as dict so blocks are saved with _data_particles * fix: change rlnDetectorPixelSize to rlnTomoTiltSeriesPixelSize for relion5 compatibility * add: make sure new column name is also checked in tests --- src/pytom_tm/entry_points.py | 8 ++++++-- src/pytom_tm/extract.py | 1 + tests/test_tmjob.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pytom_tm/entry_points.py b/src/pytom_tm/entry_points.py index d565ecab..fd6c28c0 100644 --- a/src/pytom_tm/entry_points.py +++ b/src/pytom_tm/entry_points.py @@ -548,7 +548,9 @@ def extract_candidates(argv=None): # write out as a RELION type starfile starfile.write( - df, job.output_dir.joinpath(f"{job.tomo_id}_particles.star"), overwrite=True + {"particles": df}, + job.output_dir.joinpath(f"{job.tomo_id}_particles.star"), + overwrite=True, ) @@ -1007,5 +1009,7 @@ def merge_stars(argv=None): dataframes = [starfile.read(f) for f in files] starfile.write( - pd.concat(dataframes, ignore_index=True), args.output_file, overwrite=True + {"particles": pd.concat(dataframes, ignore_index=True)}, + args.output_file, + overwrite=True, ) diff --git a/src/pytom_tm/extract.py b/src/pytom_tm/extract.py index 61f40939..2c628f12 100644 --- a/src/pytom_tm/extract.py +++ b/src/pytom_tm/extract.py @@ -346,6 +346,7 @@ def extract_particles( "rlnCoordinateY": "rlnCenteredCoordinateYAngst", "rlnCoordinateZ": "rlnCenteredCoordinateZAngst", "rlnMicrographName": "rlnTomoName", + "rlnDetectorPixelSize": "rlnTomoTiltSeriesPixelSize", } output = output.rename(columns=column_change) diff --git a/tests/test_tmjob.py b/tests/test_tmjob.py index 9db731ec..902c1e6b 100644 --- a/tests/test_tmjob.py +++ b/tests/test_tmjob.py @@ -631,6 +631,7 @@ def test_extraction(self): "rlnCenteredCoordinateYAngst", "rlnCenteredCoordinateZAngst", "rlnTomoName", + "rlnTomoTiltSeriesPixelSize", ): self.assertTrue( column in df_rel5.columns,