Skip to content

Commit

Permalink
Add a basic test for merge_fastqs.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Oct 20, 2023
1 parent 2d913bb commit 441cf98
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions micall/tests/test_merge_fastqs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import pytest
import os
import sys

from micall.core.merge_fastqs import main

FASTQ_DATA_A = """@SEQ_ID_A1
AAGTCGACGAATG
+
ABCDEFGHIJKLM"""
FASTQ_DATA_A2 = """@SEQ_ID_A2
AACCTGAAGGGTT
+
ABCDEFGHIJKLM"""
FASTQ_DATA_B = """@SEQ_ID_B1
CCCTAAAGGTTTG
+
ABCDEFGHIJKLM"""
FASTQ_DATA_B2 = """@SEQ_ID_B2
ACGTACGTACGTA
+
ABCDEFGHIJKLM"""

@pytest.fixture
def fastq_files(tmp_path):
# Create forward and reverse fastq files for two samples: A and B.
fastq1_a = tmp_path / "fastq1_a.fastq"
fastq2_a = tmp_path / "fastq2_a.fastq"
fastq1_b = tmp_path / "fastq1_b.fastq"
fastq2_b = tmp_path / "fastq2_b.fastq"
fastq1_a.write_text(FASTQ_DATA_A)
fastq2_a.write_text(FASTQ_DATA_A2)
fastq1_b.write_text(FASTQ_DATA_B)
fastq2_b.write_text(FASTQ_DATA_B2)

# Paths for output files
fastq1_result = tmp_path / "fastq1_result.fastq"
fastq2_result = tmp_path / "fastq2_result.fastq"

args = [str(fastq1_a), str(fastq2_a), str(fastq1_b), str(fastq2_b), '--unzipped', str(fastq1_result), str(fastq2_result)]
return args

def test_basic_main(fastq_files):
main(fastq_files)

# Add some assertions
assert os.path.exists(fastq_files[-2]) # assert fastq1_result exists
assert os.path.exists(fastq_files[-1]) # assert fastq2_result exists
# ...plus more assertions to check content of results...

0 comments on commit 441cf98

Please sign in to comment.