From 8ed6651925e4460bf822e420ac30c12d22be34cc Mon Sep 17 00:00:00 2001 From: Lorenzo Gaifas Date: Fri, 25 Aug 2023 12:02:38 +0200 Subject: [PATCH] small changes --- pyproject.toml | 1 + src/waretomo/_aretomo.py | 2 +- src/waretomo/_fix.py | 2 +- src/waretomo/_fix_mdoc.py | 13 +++++++------ src/waretomo/_stack.py | 2 +- src/waretomo/main.py | 28 +++++++++++++++------------- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ee59394..5991895 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ dependencies = [ "pandas", "rich", "topaz-em", + "sh", ] # extras diff --git a/src/waretomo/_aretomo.py b/src/waretomo/_aretomo.py index 32ae556..578a314 100644 --- a/src/waretomo/_aretomo.py +++ b/src/waretomo/_aretomo.py @@ -9,7 +9,7 @@ import GPUtil from rich import print -from .threaded import run_threaded +from ._threaded import run_threaded @contextmanager diff --git a/src/waretomo/_fix.py b/src/waretomo/_fix.py index 1ecb377..b144f9e 100644 --- a/src/waretomo/_fix.py +++ b/src/waretomo/_fix.py @@ -4,7 +4,7 @@ from rich import print -from .threaded import run_threaded +from ._threaded import run_threaded def _ccderaser( diff --git a/src/waretomo/_fix_mdoc.py b/src/waretomo/_fix_mdoc.py index 53d2b02..4d9aeea 100644 --- a/src/waretomo/_fix_mdoc.py +++ b/src/waretomo/_fix_mdoc.py @@ -1,21 +1,22 @@ import pandas as pd -from mdocfile.mdoc import Mdoc +from mdocfile.data_models import Mdoc -from .threaded import run_threaded +from ._threaded import run_threaded def _tilt_mdoc( mdoc_file, tlt_file, skipped_tilts, verbose=False, dry_run=False, overwrite=False ): - if verbose: - print(f"Tilting mdoc: {mdoc_file}") - print(f"using: {tlt_file}") - output = mdoc_file.parent / "mdoc_tilted" / mdoc_file.name if not overwrite and output.exists(): raise FileExistsError(output) + if verbose: + print(f"Tilting mdoc: {mdoc_file}") + print(f"using: {tlt_file}") + print(f"saving to {output}") + if not dry_run: mdoc = Mdoc.from_file(mdoc_file) new_angles = iter(pd.read_csv(tlt_file, header=None)[0]) diff --git a/src/waretomo/_stack.py b/src/waretomo/_stack.py index b57e4cc..329c2bc 100644 --- a/src/waretomo/_stack.py +++ b/src/waretomo/_stack.py @@ -4,7 +4,7 @@ from rich import print -from .threaded import run_threaded +from ._threaded import run_threaded def _stack( diff --git a/src/waretomo/main.py b/src/waretomo/main.py index 758c930..f501c35 100644 --- a/src/waretomo/main.py +++ b/src/waretomo/main.py @@ -164,7 +164,7 @@ def cli( from rich.panel import Panel from rich.progress import Progress - from .parse import parse_data + from ._parse import parse_data if gpus is not None: gpus = [int(gpu) for gpu in gpus.split(",")] @@ -174,7 +174,7 @@ def cli( mdoc_dir = warp_dir mdoc_dir = Path(mdoc_dir) if output_dir is None: - output_dir = warp_dir / "stemia" + output_dir = warp_dir / "waretomo_processing" output_dir = Path(output_dir) output_dir.mkdir(parents=True, exist_ok=True) @@ -223,16 +223,18 @@ def cli( nl = "\n" - not_ready = "".join(f'{nl}{" " * 12}- {ts}' for ts in tilt_series_unprocessed) - ready = "".join(f'{nl}{" " * 12}- {ts["name"]}' for ts in tilt_series) + not_ready_log = "".join( + f'{nl}{" " * 12}- {ts}' for ts in tilt_series_unprocessed + ) + ready_log = "".join(f'{nl}{" " * 12}- {ts["name"]}' for ts in tilt_series) excluded = "".join(f'{nl}{" " * 12}- {ts}' for ts in tilt_series_excluded) - steps = "".join( + steps_log = "".join( f'{nl}{" " * 12}- ' - '[{"green" if v else "red"}]{k}[/{"green" if v else "red"}] ' + f'[{"green" if v else "red"}]{k}[/{"green" if v else "red"}] ' for k, v in steps.items() ) - opts = "".join(f'{nl}{" " * 12}- {k}: {v}' for k, v in meta_kwargs.items()) - aretomo_opts = "".join( + opts_log = "".join(f'{nl}{" " * 12}- {k}: {v}' for k, v in meta_kwargs.items()) + aretomo_opts_log = "".join( f'{nl}{" " * 12}- {k}: {v}' for k, v in aretomo_kwargs.items() ) @@ -242,12 +244,12 @@ def cli( f""" [bold]Warp directory[/bold]: {warp_dir} [bold]Mdoc directory[/bold]: {mdoc_dir} - [bold]Tilt series - NOT READY[/bold]: {not_ready} - [bold]Tilt series - READY[/bold]: {ready} + [bold]Tilt series - NOT READY[/bold]: {not_ready_log} + [bold]Tilt series - READY[/bold]: {ready_log} [bold]Tilt series - EXCLUDED[/bold]: {excluded} - [bold]Processing steps[/bold]: {steps} - [bold]Run options[/bold]: {opts} - [bold]AreTomo options[/bold]: {aretomo_opts} + [bold]Processing steps[/bold]: {steps_log} + [bold]Run options[/bold]: {opts_log} + [bold]AreTomo options[/bold]: {aretomo_opts_log} """ ) )