diff --git a/barcodeforge/cli.py b/barcodeforge/cli.py index 81e60d3..4ec6b03 100644 --- a/barcodeforge/cli.py +++ b/barcodeforge/cli.py @@ -318,7 +318,6 @@ def extract_auspice_data( Inspired by Dr. John Huddleston's Gist on processing Auspice JSON files. Source: https://gist.github.com/huddlej/5d7bd023d3807c698bd18c706974f2db """ - is_debug = ctx.obj.get("DEBUG", False) # More robust way to get debug status print_info(f"Processing Auspice JSON file:\t{auspice_json_path}", bold=True) process_auspice_json( tree_json_path=auspice_json_path, diff --git a/barcodeforge/generate_barcodes.py b/barcodeforge/generate_barcodes.py index f8977ed..9344115 100755 --- a/barcodeforge/generate_barcodes.py +++ b/barcodeforge/generate_barcodes.py @@ -4,7 +4,7 @@ import pandas as pd import rich_click as click -from .utils import sortFun, print_error, print_success, print_info, print_debug +from .utils import sortFun, print_error, print_success, print_info def parse_tree_paths(df: pd.DataFrame) -> pd.DataFrame: diff --git a/barcodeforge/plot_barcode.py b/barcodeforge/plot_barcode.py index 132447a..cab40a0 100755 --- a/barcodeforge/plot_barcode.py +++ b/barcodeforge/plot_barcode.py @@ -1,7 +1,7 @@ """Plot barcode from CSV file.""" import pandas as pd -from .utils import sortFun, print_info, print_debug +from .utils import print_info, print_debug import seaborn as sns import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap @@ -46,7 +46,6 @@ def create_barcode_visualization( # Prepare chunks chunks = [] dims = [] - cat_dtype = pd.CategoricalDtype(categories=base_list, ordered=True) for i in range(num_chunks): ps = all_pos[i * CHUNK : (i + 1) * CHUNK] sub = plot_df[plot_df.pos.isin(ps)] diff --git a/barcodeforge/ref_muts.py b/barcodeforge/ref_muts.py index fae360a..909ae62 100755 --- a/barcodeforge/ref_muts.py +++ b/barcodeforge/ref_muts.py @@ -2,7 +2,7 @@ from Bio import SeqIO from collections import OrderedDict import re -from .utils import print_error, print_warning, print_success, print_info, print_debug +from .utils import print_warning, print_success, print_info, print_debug def _load_sample_mutations(path): diff --git a/tests/test_cli.py b/tests/test_cli.py index 73dd79c..a61152a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -90,9 +90,7 @@ def test_barcode_command_default_options(runner, temp_files, mocker): "barcodeforge.cli.create_barcodes_from_lineage_paths" ) mock_create_plot = mocker.patch("barcodeforge.cli.create_barcode_plot") - mock_cli_console = mocker.patch.object( - barcodeforge.utils, "console", MagicMock(spec=Console) - ) + mocker.patch.object(barcodeforge.utils, "console", MagicMock(spec=Console)) args = [ "barcode", @@ -225,9 +223,7 @@ def test_barcode_command_custom_options(runner, temp_files, mocker): "barcodeforge.cli.create_barcodes_from_lineage_paths" ) mock_create_plot = mocker.patch("barcodeforge.cli.create_barcode_plot") - mock_cli_console = mocker.patch.object( - barcodeforge.utils, "console", MagicMock(spec=Console) - ) + mocker.patch.object(barcodeforge.utils, "console", MagicMock(spec=Console)) prefix = "MYPREFIX" custom_usher_args = "-U -l" @@ -376,9 +372,7 @@ def test_barcode_command_nexus_tree(runner, temp_files, mocker): mocker.patch("barcodeforge.cli.process_and_reroot_lineages") mocker.patch("barcodeforge.cli.create_barcodes_from_lineage_paths") mocker.patch("barcodeforge.cli.create_barcode_plot") - mock_cli_console = mocker.patch.object( - barcodeforge.utils, "console", MagicMock(spec=Console) - ) + mocker.patch.object(barcodeforge.utils, "console", MagicMock(spec=Console)) args = [ "barcode", @@ -432,9 +426,7 @@ def test_barcode_command_newick_tree_reformat(runner, temp_files, mocker): mocker.patch("barcodeforge.cli.process_and_reroot_lineages") mocker.patch("barcodeforge.cli.create_barcodes_from_lineage_paths") mocker.patch("barcodeforge.cli.create_barcode_plot") - mock_cli_console = mocker.patch.object( - barcodeforge.utils, "console", MagicMock(spec=Console) - ) + mocker.patch.object(barcodeforge.utils, "console", MagicMock(spec=Console)) args = [ "barcode", diff --git a/tests/test_format_tree.py b/tests/test_format_tree.py index 4c05222..aef2f21 100644 --- a/tests/test_format_tree.py +++ b/tests/test_format_tree.py @@ -2,7 +2,6 @@ from pathlib import Path from barcodeforge.format_tree import convert_nexus_to_newick, _remove_quotes_from_file import tempfile -import os # Sample Nexus content SAMPLE_NEXUS_CONTENT = """ diff --git a/tests/test_generate_barcodes.py b/tests/test_generate_barcodes.py index 3941b0a..f9e4326 100644 --- a/tests/test_generate_barcodes.py +++ b/tests/test_generate_barcodes.py @@ -12,7 +12,6 @@ create_barcodes_from_lineage_paths, check_allele_consistency, ) -from barcodeforge.utils import sortFun # Assuming sortFun is in utils # Sample data for testing diff --git a/tests/test_plot_barcode.py b/tests/test_plot_barcode.py index 0d60347..78bfba7 100644 --- a/tests/test_plot_barcode.py +++ b/tests/test_plot_barcode.py @@ -1,10 +1,7 @@ import pytest import pandas as pd from pathlib import Path -from barcodeforge.plot_barcode import create_barcode_visualization, create_barcode_plot -import matplotlib.pyplot as plt -import seaborn as sns -from matplotlib.colors import ListedColormap +from barcodeforge.plot_barcode import create_barcode_visualization @pytest.fixture diff --git a/tests/test_ref_muts.py b/tests/test_ref_muts.py index 9a7d62b..60a3102 100644 --- a/tests/test_ref_muts.py +++ b/tests/test_ref_muts.py @@ -3,11 +3,9 @@ from Bio.Seq import Seq from Bio.SeqRecord import SeqRecord from collections import OrderedDict -from pathlib import Path import copy # Ensure copy is imported -from unittest.mock import MagicMock, call # For console mocking +from unittest.mock import MagicMock # For console mocking from rich.console import Console # For console spec -import barcodeforge.utils from barcodeforge.ref_muts import ( _load_sample_mutations, _extract_mutations, @@ -74,11 +72,6 @@ def test_load_sample_mutations(sample_muts_file): def test_extract_mutations(): - sample_with_muts = {"mutations": "gene1:A123T,C456G>gene2:X1Y"} - extracted = _extract_mutations(sample_with_muts) - expected = OrderedDict( - [("gene2:X1Y", ["gene2:X1Y"]), ("gene1:A123T,C456G", ["gene1:A123T", "C456G"])] - ) # The original code's MUT_PATTERN and splitting logic might be different. # This test is based on a common interpretation. Adjust if your MUT_PATTERN is more complex. # Based on the provided code: MUT_PATTERN = re.compile(r"([^:]+):([A-Za-z0-9,]+)")