Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytests for delly #51

Merged
merged 5 commits into from
Mar 25, 2024
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Added `sequencing_run` and `lims_id` to output (bonsai input)
- Added function for annotating delly variants intersecting with resistance targets
- Added capability of handling empty dictionaries from serotypefinder output
- Added pytest for `prp annotate-delly`
- Added `pyyaml` to docker image

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ dependencies = [
"pandas==2.1.3",
"Biopython==1.83",
"cyvcf2",
"pysam"
"pysam",
"pyyaml"
]

[project.urls]
Expand Down
15 changes: 15 additions & 0 deletions tests/fixtures/mtuberculosis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@ def mtuberculosis_snv_vcf_path(data_path):
def mtuberculosis_sv_vcf_path(data_path):
"""Get path for mtuberculosis meta file"""
return str(data_path.joinpath("mtuberculosis", "sv.vcf"))

@pytest.fixture()
def mtuberculosis_delly_bcf_path(data_path):
"""Get path for mtuberculosis meta file"""
return str(data_path.joinpath("mtuberculosis", "delly.bcf"))

@pytest.fixture()
def converged_bed_path(data_path):
"""Get path for mtuberculosis converged who fohm tbdb bgzipped bed file"""
return str(data_path.joinpath("mtuberculosis", "converged_who_fohm_tbdb.bed.gz"))

@pytest.fixture()
def annotated_delly_path(data_path):
"""Get path for annotated delly vcf file"""
return str(data_path.joinpath("mtuberculosis", "annotated_delly.vcf"))
98 changes: 98 additions & 0 deletions tests/fixtures/mtuberculosis/annotated_delly.vcf

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file added tests/fixtures/mtuberculosis/delly.bcf
Binary file not shown.
32 changes: 31 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from click.testing import CliRunner

from prp.cli import create_bonsai_input, create_cdm_input
from prp.cli import create_bonsai_input, create_cdm_input, annotate_delly


def test_create_output_saureus(
Expand Down Expand Up @@ -160,6 +160,36 @@ def test_cdm_input_cmd(
assert cmd_output == ecoli_cdm_input


def test_annotate_delly(
mtuberculosis_delly_bcf_path, converged_bed_path, annotated_delly_path
):
"""Test command for annotating delly output."""
runner = CliRunner()
with runner.isolated_filesystem():
sample_id = "test_mtuberculosis_1"
output_fname = f"{sample_id}_annotated_delly.vcf"
result = runner.invoke(
annotate_delly,
[
"--vcf",
mtuberculosis_delly_bcf_path,
"--bed",
converged_bed_path,
"--output",
output_fname,
],
)

# test successful execution of command
assert result.exit_code == 0

# test correct output format
with open(output_fname, "r", encoding="utf-8") as test_annotated_delly_output, \
open(annotated_delly_path, "r", encoding="utf-8") as annotated_delly_output:
test_contents = test_annotated_delly_output.read()
expected_contents = annotated_delly_output.read()
assert test_contents == expected_contents


def test_create_output_mtuberculosis(
mtuberculosis_analysis_meta_path,
Expand Down
Loading