Skip to content

Commit

Permalink
Try and figure out the ctf file location for tomograms
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-riggs committed Aug 14, 2024
1 parent 93e31c9 commit cd5a4a2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/cryoemservices/util/tomo_output_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import re
from pathlib import Path
from typing import Callable, Dict, List

Expand Down Expand Up @@ -406,6 +407,24 @@ def _align_tilt_output_files(
if not (job_dir / "tilt_series").is_dir():
(job_dir / "tilt_series").mkdir()

# Try and figure out where the CTF output files will be
mc_job_num_search = re.search("/job[0-9]+", str(input_file))
if input_file.is_relative_to("MotionCorr") and mc_job_num_search:
job_number = int(mc_job_num_search[0][4:])
relative_tilt = input_file.relative_to(f"MotionCorr/job{job_number:03}")
ctf_txt_file = Path(
f"CtfFind/job{job_number + 1:03}"
) / relative_tilt.with_suffix(".txt")
else:
ctf_txt_file = input_file.with_suffix(".txt")

# Later extraction jobs require some ctf parameters for the tilts
if ctf_txt_file.is_file():
with open(ctf_txt_file, "r") as f:
ctf_results = f.readlines()[-1].split()
else:
ctf_results = ["error", "ctf", "not", "found"]

added_line = [
str(relion_options.frame_count),
str(stage_tilt_angle),
Expand All @@ -417,6 +436,9 @@ def _align_tilt_output_files(
),
str(relion_options.defocus),
str(input_file),
ctf_results[1],
ctf_results[2],
ctf_results[3],
results["TomoXTilt"],
results["TomoYTilt"],
results["TomoZRot"],
Expand All @@ -438,6 +460,9 @@ def _align_tilt_output_files(
"MicrographPreExposure",
"TomoNominalDefocus",
"MicrographName",
"DefocusU",
"DefocusV",
"DefocusAngle",
"TomoXTilt",
"TomoYTilt",
"TomoZRot",
Expand Down

0 comments on commit cd5a4a2

Please sign in to comment.