-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added two unit tests for reading BAM files (#6)
* Fixed indexing from 1 vs 0. * Added two unit tests for basic reading of BAM files. * Fixed spelling mistake in comment line. * Removed extra parens. * Changed use of pytest fixture invocation to apparently make ruff happy.
- Loading branch information
1 parent
00d0ae4
commit 2d6a0f6
Showing
4 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,40 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
def test_read_bam(): | ||
pass | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
|
||
import dask_ngs | ||
|
||
|
||
@pytest.fixture() | ||
def example_bam(): | ||
return dask_ngs.read_bam(str(Path(__file__).parent / "fixtures" / "example.bam")) | ||
|
||
|
||
def test_read_bam_pnext_value(example_bam): | ||
# Verifies that the pnext value was read correctly from the BAM file | ||
few_pnext_values = example_bam["pnext"].head() | ||
assert few_pnext_values[2] == 82982 | ||
|
||
|
||
def test_read_correct_data_types_from_bam(example_bam): | ||
# Compares data types of read values against expected | ||
assert example_bam.dtypes["qname"] == np.dtype("O") | ||
assert example_bam.dtypes["flag"] == np.dtype("uint16") | ||
assert isinstance( | ||
example_bam.dtypes["rname"], pd.core.dtypes.dtypes.CategoricalDtype | ||
) | ||
assert example_bam.dtypes["pos"] == np.dtype("int32") | ||
assert example_bam.dtypes["mapq"] == np.dtype("uint8") | ||
assert example_bam.dtypes["cigar"] == np.dtype("O") | ||
assert isinstance( | ||
example_bam.dtypes["rnext"], pd.core.dtypes.dtypes.CategoricalDtype | ||
) | ||
assert example_bam.dtypes["pnext"] == np.dtype("int32") | ||
assert example_bam.dtypes["tlen"] == np.dtype("int32") | ||
assert example_bam.dtypes["seq"] == np.dtype("O") | ||
assert example_bam.dtypes["qual"] == np.dtype("O") | ||
assert example_bam.dtypes["end"] == np.dtype("int32") |