Skip to content

Commit

Permalink
Small test just to make sure GZIP FASTX are OK
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Nov 24, 2023
1 parent 37be503 commit 4c2e82a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fgpyo/fastx/tests/test_fastx_zipped.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import gzip

from pathlib import Path

import pytest
Expand Down Expand Up @@ -44,6 +46,27 @@ def test_fastx_zipped_iterates_over_a_single_fasta(tmp_path: Path) -> None:
assert all(fastx.closed for fastx in context_manager._fastx)


def test_fastx_zipped_iterates_over_a_single_fasta_gzipped(tmp_path: Path) -> None:
"""Test that :class:`FastxZipped` can iterate over a single gzipped FASTA file."""
input = tmp_path / "input"
input.mkdir()
fasta = input / "input.fasta.gz"

with gzip.open(fasta, "wt") as handle:
handle.write(">seq1\nACGT\n>seq2\nTGCA\n")

context_manager = FastxZipped(fasta)
with context_manager as handle:
(record1,) = next(handle)
assert record1.name == "seq1"
assert record1.sequence == "ACGT"
(record2,) = next(handle)
assert record2.name == "seq2"
assert record2.sequence == "TGCA"

assert all(fastx.closed for fastx in context_manager._fastx)


def test_fastx_zipped_iterates_over_a_single_fastq(tmp_path: Path) -> None:
"""Test that :class:`FastxZipped` can iterate over a single FASTQ file."""
input = tmp_path / "input"
Expand Down

0 comments on commit 4c2e82a

Please sign in to comment.