Skip to content

Commit

Permalink
Move some compression-related tests to separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelm committed Jun 25, 2024
1 parent d9cf273 commit 75c1d0d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 63 deletions.
64 changes: 1 addition & 63 deletions tests/test_commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ def test_example(run):
run("-N -b ADAPTER", "example.fa", "example.fa")


def test_compressed_fasta(run):
run("", "simple.fasta", "simple.fasta.gz")


def test_small(run):
run("-a TTAGACATATCTCCGTCG", "small.fastq", "small.fastq")

Expand Down Expand Up @@ -130,11 +126,6 @@ def test_discard_untrimmed(run):
run("-b CAAGAT --discard-untrimmed", "discard-untrimmed.fastq", "small.fastq")


def test_extensiontxtgz(run):
"""automatic recognition of "_sequence.txt.gz" extension"""
run("-b TTAGACATATCTCCGTCG", "s_1_sequence.txt", "s_1_sequence.txt.gz")


def test_minimum_length(run):
"""-m/--minimum-length"""
stats = run("-m 5 -a TTAGACATATCTCCGTCG", "minlen.fa", "lengths.fa")
Expand Down Expand Up @@ -335,11 +326,6 @@ def test_action_crop(run):
)


def test_gz_multiblock(run):
"""compressed gz file with multiple blocks (created by concatenating two .gz files)"""
run("-b TTAGACATATCTCCGTCG", "small.fastq", "multiblock.fastq.gz")


def test_read_wildcard(run):
"""test wildcards in reads"""
run("--match-read-wildcards -b ACGTACGT", "wildcard.fa", "wildcard.fa")
Expand Down Expand Up @@ -544,37 +530,6 @@ def test_adapter_with_u(run):
run("-a GCCGAACUUCUUAGACUGCCUUAAGGACGU", "illumina.fastq", "illumina.fastq.gz")


def test_bzip2_input(run, cores):
run(
["--cores", str(cores), "-a", "TTAGACATATCTCCGTCG"],
"small.fastq",
"small.fastq.bz2",
)


@pytest.mark.parametrize("extension", ["bz2", "xz", "gz"])
def test_compressed_output(tmp_path, cores, extension):
out_path = str(tmp_path / ("small.fastq." + extension))
params = [
"--cores",
str(cores),
"-a",
"TTAGACATATCTCCGTCG",
"-o",
out_path,
datapath("small.fastq"),
]
main(params)


def test_bzip2_multiblock(run):
run("-b TTAGACATATCTCCGTCG", "small.fastq", "multiblock.fastq.bz2")


def test_xz(run):
run("-b TTAGACATATCTCCGTCG", "small.fastq", "small.fastq.xz")


def test_no_args():
with pytest.raises(SystemExit):
main([])
Expand Down Expand Up @@ -930,26 +885,9 @@ def test_discard_casava(run):
assert stats.filtered["casava_filtered"] == 1


def test_underscore(run):
"""File name ending in _fastq.gz (issue #275)"""
run("-b TTAGACATATCTCCGTCG", "small.fastq", "underscore_fastq.gz")


def test_cores_autodetect(run):
# Just make sure that it runs; functionality is not tested
run("--cores 0 -b TTAGACATATCTCCGTCG", "small.fastq", "underscore_fastq.gz")


def test_write_compressed_fastq(cores, tmp_path):
main(
[
"--cores",
str(cores),
"-o",
str(tmp_path / "out.fastq.gz"),
datapath("small.fastq"),
]
)
run("--cores 0 -b TTAGACATATCTCCGTCG", "small.fastq", "small.fastq.gz")


def test_minimal_report(run):
Expand Down
66 changes: 66 additions & 0 deletions tests/test_compression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pytest

from cutadapt.cli import main
from utils import assert_files_equal, datapath, cutpath


def test_gz_multiblock(run):
"""compressed gz file with multiple blocks (created by concatenating two .gz files)"""
run("-b TTAGACATATCTCCGTCG", "small.fastq", "multiblock.fastq.gz")


def test_extensiontxtgz(run):
"""automatic recognition of "_sequence.txt.gz" extension"""
run("-b TTAGACATATCTCCGTCG", "s_1_sequence.txt", "s_1_sequence.txt.gz")


def test_compressed_fasta(run):
run("", "simple.fasta", "simple.fasta.gz")


def test_write_compressed_fastq(cores, tmp_path):
main(
[
"--cores",
str(cores),
"-o",
str(tmp_path / "out.fastq.gz"),
datapath("small.fastq"),
]
)


@pytest.mark.parametrize("extension", ["bz2", "xz", "gz"])
def test_compressed_output(tmp_path, cores, extension):
out_path = str(tmp_path / ("small.fastq." + extension))
params = [
"--cores",
str(cores),
"-a",
"TTAGACATATCTCCGTCG",
"-o",
out_path,
datapath("small.fastq"),
]
main(params)


def test_bzip2_multiblock(run):
run("-b TTAGACATATCTCCGTCG", "small.fastq", "multiblock.fastq.bz2")


def test_xz(run):
run("-b TTAGACATATCTCCGTCG", "small.fastq", "small.fastq.xz")


def test_bzip2_input(run, cores):
run(
["--cores", str(cores), "-a", "TTAGACATATCTCCGTCG"],
"small.fastq",
"small.fastq.bz2",
)


def test_underscore(run):
"""File name ending in _fastq.gz (issue #275)"""
run("-b TTAGACATATCTCCGTCG", "small.fastq", "underscore_fastq.gz")

0 comments on commit 75c1d0d

Please sign in to comment.