Skip to content

Commit

Permalink
Merge pull request #43 from ThomasHoffmann77/main
Browse files Browse the repository at this point in the history
add executable parameter
  • Loading branch information
EuanPyle authored Jun 5, 2024
2 parents 5455703 + 09901cc commit 6f59641
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lil_aretomo/aretomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions lil_aretomo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
f'{executable}',
'-InMrc', f'{tilt_series_file}',
'-OutMrc', f'{reconstruction_file}',
'-OutBin', f'{binning_factor:.3f}',
Expand All @@ -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:
Expand Down

0 comments on commit 6f59641

Please sign in to comment.