Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion barcodeforge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion barcodeforge/generate_barcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions barcodeforge/plot_barcode.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion barcodeforge/ref_muts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 4 additions & 12 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion tests/test_format_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
1 change: 0 additions & 1 deletion tests/test_generate_barcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions tests/test_plot_barcode.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 1 addition & 8 deletions tests/test_ref_muts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,]+)")
Expand Down
Loading