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
2 changes: 1 addition & 1 deletion barcodeforge/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.1.1"
1 change: 1 addition & 0 deletions barcodeforge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ def barcode(
)

process_and_reroot_lineages(
debug=is_debug,
sample_muts_path=os.path.join(intermediate_dir, "samplePaths.txt"),
reference_fasta_path=reference_genome,
sequences_fasta_path=alignment,
Expand Down
6 changes: 6 additions & 0 deletions barcodeforge/ref_muts.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def _sanitize_mutation_data(mutations):


def process_and_reroot_lineages(
debug: bool,
sample_muts_path: str,
reference_fasta_path: str,
sequences_fasta_path: str,
Expand Down Expand Up @@ -146,6 +147,11 @@ def process_and_reroot_lineages(
for i in additional_muts.keys():
additional_muts[i]["ref"] = additional_muts[i].pop("base")
additional_muts[i]["root"] = additional_muts[i].pop("mut")

if debug:
console.print(
f"[{STYLES['debug']}]Additional mutations derived from reference {ref.id}: {additional_muts}[/{STYLES['debug']}]"
)
# else generate the root sequence
else:
console.print(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "BarcodeForge"
version = "1.0.0"
version = "1.1.1"
description = "A CLI tool for generating pathogen-specific barcodes for Freyja."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
19 changes: 11 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def test_barcode_command_default_options(runner, temp_files, mocker):
mock_run_subp.assert_has_calls(expected_subprocess_calls, any_order=False)

mock_process_reroot.assert_called_once_with(
debug=False,
sample_muts_path=matutils_S_output_fn,
reference_fasta_path=temp_files["ref_genome"],
sequences_fasta_path=temp_files["alignment"],
Expand All @@ -207,9 +208,9 @@ def test_barcode_command_default_options(runner, temp_files, mocker):
prefix="", # Default prefix ""
)
mock_create_plot.assert_called_once_with(
debug=False, # Add the debug argument
debug=False,
input_file_path=final_barcodes_csv_fn,
chunk_size=100, # Add chunk_size, default from CLI is 100
chunk_size=100,
output_file_path=final_barcode_plot_fn,
)

Expand Down Expand Up @@ -349,6 +350,7 @@ def test_barcode_command_custom_options(runner, temp_files, mocker):
mock_run_subp.assert_has_calls(expected_subprocess_calls, any_order=False)

mock_process_reroot.assert_called_once_with(
debug=False,
sample_muts_path=matutils_S_output_fn,
reference_fasta_path=temp_files["ref_genome"],
sequences_fasta_path=temp_files["alignment"],
Expand All @@ -357,15 +359,15 @@ def test_barcode_command_custom_options(runner, temp_files, mocker):
output_rerooted_lineage_paths_path=rerooted_lineage_paths_fn,
)
mock_create_barcodes.assert_called_once_with(
debug=False, # Add the debug argument
debug=False,
input_file_path=rerooted_lineage_paths_fn,
output_file_path=final_barcodes_csv_fn,
prefix=prefix,
)
mock_create_plot.assert_called_once_with(
debug=False, # Add the debug argument
debug=False,
input_file_path=final_barcodes_csv_fn,
chunk_size=100, # Add chunk_size, default from CLI is 100 unless specified
chunk_size=100,
output_file_path=final_barcode_plot_fn,
)

Expand Down Expand Up @@ -511,6 +513,7 @@ def test_barcode_command_debug_flag(runner, temp_files, mocker):
)

mock_process_reroot.assert_called_once_with(
debug=True,
sample_muts_path=matutils_S_output_fn,
reference_fasta_path=temp_files["ref_genome"],
sequences_fasta_path=temp_files["alignment"],
Expand All @@ -522,12 +525,12 @@ def test_barcode_command_debug_flag(runner, temp_files, mocker):
debug=True,
input_file_path=rerooted_lineage_paths_fn,
output_file_path=final_barcodes_csv_fn,
prefix="", # Default prefix ""
prefix="",
)
mock_create_plot.assert_called_once_with(
debug=True, # Add the debug argument, should be True here
debug=True,
input_file_path=final_barcodes_csv_fn,
chunk_size=100, # Add chunk_size, default from CLI is 100
chunk_size=100,
output_file_path=final_barcode_plot_fn,
)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_ref_muts.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def test_process_and_reroot_lineages_ref_present(
output_rerooted_lineages = tmp_path / "rerooted_lineages.tsv"

process_and_reroot_lineages(
debug=False,
sample_muts_path=str(muts_file_ref_present),
reference_fasta_path=sample_ref_fasta_file,
sequences_fasta_path=sample_seqs_fasta_file, # sampleA is in here
Expand Down Expand Up @@ -265,6 +266,7 @@ def test_process_and_reroot_lineages_ref_not_in_muts_infer_root(
mocker.patch("barcodeforge.ref_muts.console", mocked_console)

process_and_reroot_lineages(
debug=False,
sample_muts_path=str(muts_file),
reference_fasta_path=sample_ref_fasta_file, # ref_genome AAAAAAAAAA
sequences_fasta_path=str(seqs_file),
Expand Down Expand Up @@ -349,6 +351,7 @@ def test_process_and_reroot_lineages_value_error_empty_root_seqs(
match="No valid root sequences could be generated. Check input FASTA and sample mutations.",
):
process_and_reroot_lineages(
debug=False,
sample_muts_path=str(muts_file),
reference_fasta_path=sample_ref_fasta_file,
sequences_fasta_path=str(seqs_file),
Expand Down Expand Up @@ -385,6 +388,7 @@ def test_process_and_reroot_lineages_warning_missing_sample_in_fasta(
# Additional muts (ref vs inferred): none
# Rerooted paths: original
process_and_reroot_lineages(
debug=False,
sample_muts_path=str(muts_file),
reference_fasta_path=sample_ref_fasta_file,
sequences_fasta_path=str(seqs_file),
Expand Down
Loading