From 974db1f435ea0b314b5135aba9c9ae6674f3944d Mon Sep 17 00:00:00 2001 From: thoffman Date: Fri, 24 May 2024 16:00:22 +0200 Subject: [PATCH 1/2] add executable parameter --- lil_aretomo/aretomo.py | 6 ++++-- lil_aretomo/utils.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lil_aretomo/aretomo.py b/lil_aretomo/aretomo.py index 6f275ee..1bdfcbe 100644 --- a/lil_aretomo/aretomo.py +++ b/lil_aretomo/aretomo.py @@ -22,7 +22,8 @@ def align_tilt_series( nominal_rotation_angle: Optional[float] = None, correct_tilt_angle_offset: bool = False, gpu_ids: Optional[Sequence[int]] = None, - skip_if_completed: bool = False + skip_if_completed: bool = False, + executable: Optional[str]='AreTomo' ) -> AreTomoOutput: """Align a single-axis tilt-series using AreTomo. @@ -43,7 +44,7 @@ def align_tilt_series( gpu_ids: integer ids for GPUs on the system (zero indexed). skip_if_completed: skip alignment if previous results found. """ - if check_aretomo_on_path() is False: + if check_aretomo_on_path(executable) is False: raise RuntimeError("AreTomo executable was not found. \ Put 'AreTomo' on the PATH to proceed.") if do_local_alignments is True and n_patches_xy is None: @@ -68,6 +69,7 @@ def align_tilt_series( do_local_alignments=do_local_alignments, n_patches_xy=n_patches_xy, gpu_ids=gpu_ids, + executable=executable ) aretomo_output = AreTomoOutput(tilt_series_file=tilt_series_file, reconstruction_file=reconstruction_file) if aretomo_output.contains_alignment_results is False or skip_if_completed is False: diff --git a/lil_aretomo/utils.py b/lil_aretomo/utils.py index 5994258..a26db38 100644 --- a/lil_aretomo/utils.py +++ b/lil_aretomo/utils.py @@ -47,11 +47,12 @@ def get_aretomo_command( nominal_tilt_axis_angle: Optional[float] = None, do_local_alignments: bool = True, n_patches_xy: Optional[Tuple[int, int]] = None, - gpu_ids: Optional[Sequence[int]] = None + gpu_ids: Optional[Sequence[int]] = None, + executable: Optional[str] = 'AreTomo', ) -> List[str]: """Generate a command which can be used to run AreTomo.""" command = [ - 'AreTomo', + executable, '-InMrc', f'{tilt_series_file}', '-OutMrc', f'{reconstruction_file}', '-OutBin', f'{binning_factor:.3f}', @@ -71,9 +72,9 @@ def get_aretomo_command( return command -def check_aretomo_on_path(): +def check_aretomo_on_path(executable: Optional[str] = 'AreTomo'): """Check the PATH for AreTomo.""" - return shutil.which('AreTomo') is not None + return shutil.which(executable) is not None def read_aln(filename: os.PathLike) -> pd.DataFrame: From 09901ccd2e5ce2aa1e6f229a5fab0d1cbd1a501f Mon Sep 17 00:00:00 2001 From: Thomas Hoffmann <81254262+ThomasHoffmann77@users.noreply.github.com> Date: Fri, 24 May 2024 16:28:57 +0200 Subject: [PATCH 2/2] Update utils.py --- lil_aretomo/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lil_aretomo/utils.py b/lil_aretomo/utils.py index a26db38..97f006b 100644 --- a/lil_aretomo/utils.py +++ b/lil_aretomo/utils.py @@ -52,7 +52,7 @@ def get_aretomo_command( ) -> List[str]: """Generate a command which can be used to run AreTomo.""" command = [ - executable, + f'{executable}', '-InMrc', f'{tilt_series_file}', '-OutMrc', f'{reconstruction_file}', '-OutBin', f'{binning_factor:.3f}',