Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Regression test for all_introns_counts_and_info.py #62

Merged
merged 5 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
pip install --upgrade virtualenv
pip install --upgrade pip setuptools
virtualenv --upgrade-embed-wheels
pip install numpy
pip show numpy
pip install cgatcore
pip install cgat
pip install -e .[tests]
- name: Test with pytest
run: |
Expand Down
538 changes: 538 additions & 0 deletions isoslam/all_introns_counts_and_info.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ keywords = [
]
dependencies = [
"apsw",
"cgat",
"cgatcore",
"gevent",
"matplotlib",
"numpy",
"pandas",
"pysam",
"ruffus",
# "ruffus",
"sqlalchemy",
]

Expand All @@ -55,8 +56,8 @@ tests = [
"pytest-cov",
"pytest-github-actions-annotate-failures",
"pytest-mpl",
"pytest-regtest",
"pytest-testmon",
"syrupy",
]
docs = [
"Sphinx",
Expand Down
Empty file added tests/__init__.py
Empty file.
1,120 changes: 1,120 additions & 0 deletions tests/_regtest_outputs/test_all_introns_counts_and_info.test_main[file_1].out

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/resources/bed/test_coding_introns.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
9 14940 15080 ENST00000442898_intron 0 -
9 15149 15908 ENST00000442898_intron 0 -
9 16061 16717 ENST00000442898_intron 0 -
9 16876 16964 ENST00000442898_intron 0 -
9 17166 17343 ENST00000442898_intron 0 -
9 17479 17718 ENST00000442898_intron 0 -
9 17855 18027 ENST00000442898_intron 0 -
9 18174 18380 ENST00000442898_intron 0 -
9 18492 24850 ENST00000442898_intron 0 -
9 25004 29601 ENST00000442898_intron 0 -
10 changes: 10 additions & 0 deletions tests/resources/bed6/test_coding_introns.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
9 14940 15080 ENST00000442898_intron 0 -
9 15149 15908 ENST00000442898_intron 0 -
9 16061 16717 ENST00000442898_intron 0 -
9 16876 16964 ENST00000442898_intron 0 -
9 17166 17343 ENST00000442898_intron 0 -
9 17479 17718 ENST00000442898_intron 0 -
9 17855 18027 ENST00000442898_intron 0 -
9 18174 18380 ENST00000442898_intron 0 -
9 18492 24850 ENST00000442898_intron 0 -
9 25004 29601 ENST00000442898_intron 0 -
518 changes: 518 additions & 0 deletions tests/resources/fasta/hg38_noalt_filtered.fa

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/resources/fasta/hg38_noalt_filtered.fa.fai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chr9 31000 6 60 61
12 changes: 12 additions & 0 deletions tests/resources/gtf/test_wash1.gtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
chr9 StringTie transcript 14521 30753 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 14521 14940 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "1"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 15081 15149 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "2"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 15909 16061 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "3"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 16718 16876 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "4"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 16965 17166 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "5"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 17344 17479 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "6"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 17719 17855 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "7"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 18028 18174 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "8"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 18381 18492 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "9"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 24851 25004 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "10"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
chr9 StringTie exon 29602 30753 1000 - . gene_id "MSTRG.63147"; transcript_id "ENST00000442898"; exon_number "11"; gene_name "WASH1"; ref_gene_id "ENSG00000181404";
Binary file added tests/resources/vcf/d0.vcf.gz
Binary file not shown.
Binary file added tests/resources/vcf/d0.vcf.gz.tbi
Binary file not shown.
41 changes: 41 additions & 0 deletions tests/test_all_introns_counts_and_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Tests for all_introns_counts_and_info module."""

import argparse
from pathlib import Path

import pytest

# import syrupy
from isoslam import all_introns_counts_and_info

BASE_DIR = Path.cwd()
TEST_DIR = BASE_DIR / "tests"
RESOURCES = TEST_DIR / "resources"
GTF_DIR = RESOURCES / "gtf"
BED_DIR = RESOURCES / "bed"
VCF_DIR = RESOURCES / "vcf"
BAM_DIR = RESOURCES / "bam"


@pytest.mark.parametrize(
("file_path"),
[
pytest.param(BAM_DIR / "sorted_assigned" / "d0_0hr1_filtered_remapped_sorted.sorted.assigned.bam", id="file 1"),
pytest.param(
BAM_DIR / "sorted_assigned" / "d0_no4sU_filtered_remapped_sorted.sorted.assigned.bam", id="file 2"
),
],
)
def test_main(file_path: Path, tmp_path: Path, regtest) -> None:
"""Regression test to check that main() function returns the expected data structure."""
args = argparse.Namespace(
infile_bam=str(file_path),
gtf_path=list(GTF_DIR.glob("*.gtf"))[0],
utron_bed=list(BED_DIR.glob("*.bed"))[0],
vcf_path=list(VCF_DIR.glob("*.vcf.gz"))[0],
outfile_tsv=str(tmp_path / "test.tsv"),
)
results = all_introns_counts_and_info.main(argv=args)
# Ideally would like to use syrupy to test snapshots but pd.DataFrame() are not yet supported
# https://github.com/syrupy-project/syrupy/issues/887
print(results.to_string(float_format="{:.4e}".format), file=regtest)
Loading