From 023b686aeb8985166c0a3dde1ae60662541840bb Mon Sep 17 00:00:00 2001 From: gp201 Date: Thu, 12 Jun 2025 22:24:30 -0700 Subject: [PATCH 1/4] feat: add new command line options for tree format, usher arguments, threads, matutils overlap, prefix, and plot chunk size --- barcodeforge/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/barcodeforge/cli.py b/barcodeforge/cli.py index 4ff7d12..75ea685 100644 --- a/barcodeforge/cli.py +++ b/barcodeforge/cli.py @@ -34,17 +34,20 @@ def cli(ctx, debug): @click.argument("tree", type=click.Path(exists=True, readable=True)) @click.argument("lineages", type=click.Path(exists=True, readable=True)) @click.option( + "-t", "--tree_format", type=click.Choice(["newick", "nexus"], case_sensitive=False), help="Specify the format of the tree file (newick or nexus)", ) @click.option( + "-u", "--usher-args", type=str, default="", help="Additional arguments to pass to usher (e.g., '-U -l'). Quote multiple arguments.", ) @click.option( + "-T", "--threads", type=int, default=8, @@ -52,6 +55,7 @@ def cli(ctx, debug): help="Number of CPUs/threads to use.", ) @click.option( + "-m", "--matutils-overlap", type=float, metavar="FLOAT", @@ -60,6 +64,7 @@ def cli(ctx, debug): help="Value for --set-overlap in matUtils annotate.", ) @click.option( + "-p", "--prefix", type=str, default="", @@ -67,6 +72,7 @@ def cli(ctx, debug): help="Prefix to add to lineage names in the barcode file.", ) @click.option( + "-c", "--plot-chunk-size", type=int, default=100, From 059138f83441b10eac5ff636cc9b9599074ceb11 Mon Sep 17 00:00:00 2001 From: gp201 Date: Thu, 12 Jun 2025 22:36:05 -0700 Subject: [PATCH 2/4] fix: update option types for threads and matutils overlap in CLI to enforce input constraints --- barcodeforge/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barcodeforge/cli.py b/barcodeforge/cli.py index 75ea685..c9f829d 100644 --- a/barcodeforge/cli.py +++ b/barcodeforge/cli.py @@ -49,7 +49,7 @@ def cli(ctx, debug): @click.option( "-T", "--threads", - type=int, + type=click.IntRange(min=1), default=8, show_default=True, help="Number of CPUs/threads to use.", @@ -57,7 +57,7 @@ def cli(ctx, debug): @click.option( "-m", "--matutils-overlap", - type=float, + type=click.FloatRange(min=0.0, max=1.0), metavar="FLOAT", default="0", show_default=True, From 3175a689436287f7fbf4cd7e8b2ea1823d4cf4a0 Mon Sep 17 00:00:00 2001 From: gp201 Date: Thu, 12 Jun 2025 22:40:23 -0700 Subject: [PATCH 3/4] refactor: standardize option names and types in CLI for consistency --- barcodeforge/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/barcodeforge/cli.py b/barcodeforge/cli.py index c9f829d..b04e2ff 100644 --- a/barcodeforge/cli.py +++ b/barcodeforge/cli.py @@ -35,7 +35,7 @@ def cli(ctx, debug): @click.argument("lineages", type=click.Path(exists=True, readable=True)) @click.option( "-t", - "--tree_format", + "--tree-format", type=click.Choice(["newick", "nexus"], case_sensitive=False), help="Specify the format of the tree file (newick or nexus)", ) @@ -50,6 +50,7 @@ def cli(ctx, debug): "-T", "--threads", type=click.IntRange(min=1), + metavar="INT", default=8, show_default=True, help="Number of CPUs/threads to use.", @@ -59,7 +60,7 @@ def cli(ctx, debug): "--matutils-overlap", type=click.FloatRange(min=0.0, max=1.0), metavar="FLOAT", - default="0", + default=0, show_default=True, help="Value for --set-overlap in matUtils annotate.", ) From 466e983e3a595ef7cbb5f109dc3697886d305353 Mon Sep 17 00:00:00 2001 From: gp201 Date: Thu, 12 Jun 2025 22:48:06 -0700 Subject: [PATCH 4/4] fix: standardize CLI option name for tree format to improve consistency --- barcodeforge/utils.py | 2 +- tests/test_cli.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/barcodeforge/utils.py b/barcodeforge/utils.py index 5639529..31305ca 100644 --- a/barcodeforge/utils.py +++ b/barcodeforge/utils.py @@ -43,7 +43,7 @@ def resolve_tree_format( f"[{STYLES['error']}]Error: Unknown tree format for file '{tree_path}'. Extension '{ext}' is not recognized.[/{STYLES['error']}]" ) console.print( - f"[{STYLES['error']}]Please specify the format using --tree_format ('newick' or 'nexus').[/]" + f"[{STYLES['error']}]Please specify the format using --tree-format ('newick' or 'nexus').[/]" ) raise click.Abort() diff --git a/tests/test_cli.py b/tests/test_cli.py index 51b09d6..c738802 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -389,7 +389,7 @@ def test_barcode_command_nexus_tree(runner, temp_files, mocker): temp_files["alignment"], temp_files["tree"], temp_files["lineages"], - "--tree_format", + "--tree-format", "nexus", ] result = runner.invoke(cli, args, catch_exceptions=False) @@ -446,7 +446,7 @@ def test_barcode_command_newick_tree_reformat(runner, temp_files, mocker): temp_files["alignment"], temp_files["tree"], temp_files["lineages"], - "--tree_format", + "--tree-format", "newick", ] result = runner.invoke(cli, args, catch_exceptions=False)