Skip to content

Commit

Permalink
WIP: unit test for ParallelBaseWrapper ...
Browse files Browse the repository at this point in the history
  • Loading branch information
eudesbarbosa committed Feb 22, 2022
1 parent d49f4fb commit c199440
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
2 changes: 1 addition & 1 deletion snappy_wrappers/wrapper_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class ParallelBaseWrapper:
#: don't go further into config dict).
tool_name = None
#: The token to use for job names and temporary directories. Constructed from ``step_name``
#: and ``tool_name`` if not specified explicitely here.
#: and ``tool_name`` if not specified explicitly here.
job_name_token = None
#: The number of bases to pad the parallelization windows with.
window_padding = 0
Expand Down
70 changes: 69 additions & 1 deletion tests/snappy_wrappers/test_wrapper_parallel.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,76 @@
import pytest
from snakemake.io import InputFiles, Log, OutputFiles, Params, Resources, Wildcards
from snakemake.script import Snakemake

from snappy_wrappers.wrapper_parallel import (
ParallelBaseWrapper,
days,
gib,
hours,
kib,
mib,
minutes,
)


@pytest.fixture
def snakemake_obj():
"""Returns Snakemake object."""
# Define helper variables
rule_name = "somatic_variant_calling_mutect2_run"
threads = 2
scriptdir = "/work"
input_dict = {
"tumor_bai": "NGS_MAPPING/output/bwa.P001-T1-DNA1-WGS1/out/bwa.P001-T1-DNA1-WGS1.bam.bai",
"tumor_bam": "NGS_MAPPING/output/bwa.P001-T1-DNA1-WGS1/out/bwa.P001-T1-DNA1-WGS1.bam",
"normal_bai": "NGS_MAPPING/output/bwa.P001-N1-DNA1-WGS1/out/bwa.P001-N1-DNA1-WGS1.bam.bai",
"normal_bam": "NGS_MAPPING/output/bwa.P001-N1-DNA1-WGS1/out/bwa.P001-N1-DNA1-WGS1.bam",
}
output_base_name = "work/bwa.mutect2.P001-T1-DNA1-WGS1/out/bwa.mutect2.P001-T1-DNA1-WGS1"
output_dict = {
"raw": output_base_name + ".raw.vcf.gz",
"raw_md5": output_base_name + ".raw.vcf.gz.md5",
"raw_tbi": output_base_name + ".raw.vcf.gz.tbi",
"raw_tbi_md5": output_base_name + ".raw.vcf.gz.tbi.md5",
"stats": output_base_name + ".raw.vcf.stats",
"stats_md5": output_base_name + ".raw.vcf.stats.md5",
"f1r2": output_base_name + ".raw.f1r2_tar.tar.gz",
"f1r2_md5": output_base_name + ".raw.f1r2_tar.tar.gz.md5",
}
log_base_name = "work/bwa.mutect2.P001-T1-DNA1-WGS1/log/bwa.mutect2.P001-T1-DNA1-WGS1"
log_dict = {
"conda_info": log_base_name + ".conda_info.txt",
"conda_info_md5": log_base_name + ".conda_info.txt.md5",
"conda_list": log_base_name + ".conda_list.txt",
"conda_list_md5": log_base_name + ".conda_list.txt.md5",
"log": log_base_name + ".log",
"log_md5": log_base_name + ".log.md5",
}
wildcards_dict = {"mapper": "bwa", "tumor_library": "P001-T1-DNA1-WGS1"}
params_dict = {"normal_lib_name": "P001-N1-DNA1-WGS1"}

# Define Snakemake class input
input_ = InputFiles(fromdict=input_dict)
output_ = OutputFiles(fromdict=output_dict)
params_ = Params(fromdict=params_dict)
log_ = Log(fromdict=log_dict)
wildcards_ = Wildcards(fromdict=wildcards_dict)

return Snakemake(
rulename=rule_name,
threads=threads,
input_=input_,
output=output_,
log=log_,
params=params_,
wildcards=wildcards_,
scriptdir=scriptdir,
)

from snappy_wrappers.wrapper_parallel import days, gib, hours, kib, mib, minutes

# Test isolated methods ----------------------------------------------------------------------------


def test_kib():
"""Tests wrapper_parallel.kib() call."""
# Define expected dictionary
Expand Down Expand Up @@ -100,3 +167,4 @@ def test_days():
assert actual == expected


# Test ParallelBaseWrapper -----------------------------------------------------------------------

0 comments on commit c199440

Please sign in to comment.