convert_fastqs_to_unmapped_bam_test.py
Here’s a detailed documentation of the target file test/preprocess_tests/convert_fastqs_to_unmapped_bam_test.py
:
High-level description
This file contains unit tests for the convert_fastqs_to_unmapped_bam
function in the cassiopeia.preprocess.pipeline
module. The tests verify the correct conversion of FASTQ files to unmapped BAM files for different sequencing chemistries.
Code Structure
The main class TestConvertFastqsToUnmappedBam
contains several test methods, each testing a different sequencing chemistry. The tests use sample FASTQ files and verify the correct conversion to BAM format, including proper tag assignments.
Symbols
TestConvertFastqsToUnmappedBam
Description
A unittest.TestCase subclass that contains test methods for the convert_fastqs_to_unmapped_bam
function.
Internal Logic
- Sets up test FASTQ file paths in the
setUp
method - Implements test methods for different sequencing chemistries (dropseq, 10xv2, 10xv3, indropsv3, slideseq2)
- Each test method:
- Calls
convert_fastqs_to_unmapped_bam
with appropriate parameters - Reads the resulting BAM file
- Verifies the correct number of alignments, query names, sequences, and qualities
- Checks the correct assignment of BAM tags (UR, UY, CR, CY, RG)
- Calls
setUp
Description
Initializes the test environment by setting up file paths for test FASTQ files.
test_dropseq
Description
Tests the conversion of FASTQ files to BAM for the Drop-seq chemistry.
test_10xv2
Description
Tests the conversion of FASTQ files to BAM for the 10x Genomics v2 chemistry.
test_10xv3
Description
Tests the conversion of FASTQ files to BAM for the 10x Genomics v3 chemistry.
test_indropsv3
Description
Tests the conversion of FASTQ files to BAM for the inDrops v3 chemistry.
test_slideseq2
Description
Tests the conversion of FASTQ files to BAM for the Slide-seq v2 chemistry.
Dependencies
Dependency | Purpose |
---|---|
os | File path operations |
unittest | Unit testing framework |
tempfile | Creating temporary directories |
pysam | Reading and manipulating BAM files |
ngs_tools | FASTQ file handling |
cassiopeia.preprocess.pipeline | Module containing the function being tested |
Error Handling
The tests use assertions to verify the correctness of the BAM conversion. If any assertion fails, the test will raise an AssertionError, indicating a problem with the conversion process.
This test file is crucial for ensuring the correct functionality of the FASTQ to BAM conversion process in the Cassiopeia preprocessing pipeline, covering various sequencing chemistries and verifying the proper assignment of BAM tags.