Skip to content

Commit 772b62a

Browse files
committed
add smoke tests for CRAM
1 parent c005781 commit 772b62a

1 file changed

Lines changed: 93 additions & 1 deletion

File tree

tests/test_cram.py

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
import numpy as np
1515
import pytest
1616

17-
from finaletoolkit.frag import single_coverage, frag_length_bins, wps, delfi
17+
from finaletoolkit.frag import (
18+
single_coverage, coverage,
19+
frag_length, frag_length_bins, frag_length_intervals,
20+
wps, multi_wps,
21+
cleavage_profile, delfi,
22+
)
23+
from finaletoolkit.frag._cleavage_profile import multi_cleavage_profile
1824
from finaletoolkit.genome.gaps import GenomeGaps
1925

2026

@@ -100,3 +106,89 @@ def test_cram_matches_bam(self, cram_file):
100106
cram_result = delfi(cram_file, autosomes, bins_file, fasta, blacklist, gaps)
101107

102108
pd.testing.assert_frame_equal(bam_result, cram_result)
109+
110+
111+
# ---------------------------------------------------------------------------
112+
# Smoke tests — verify each function runs without error when given CRAM input
113+
# ---------------------------------------------------------------------------
114+
115+
CHROM_SIZES = DATA / "human.hg19.chr1.6Mb.genome"
116+
REGION = ("chr1", 1_000_000, 2_000_000)
117+
118+
119+
class TestCoverageCRAMRuns:
120+
def test_cram_runs(self, cram_file, tmp_path):
121+
intervals = tmp_path / "intervals.bed"
122+
intervals.write_text("chr1\t1000000\t2000000\t.\n")
123+
output = tmp_path / "coverage.bed"
124+
results = coverage(
125+
cram_file, str(intervals), str(output),
126+
quality_threshold=0,
127+
reference_file=FASTA,
128+
)
129+
assert len(results) > 0
130+
131+
132+
class TestFragLengthCRAMRuns:
133+
def test_cram_runs(self, cram_file):
134+
contig, start, stop = REGION
135+
lengths = frag_length(
136+
cram_file, contig=contig, start=start, stop=stop,
137+
quality_threshold=0,
138+
reference_file=FASTA,
139+
)
140+
assert lengths is not None
141+
142+
143+
class TestFragLengthIntervalsCRAMRuns:
144+
def test_cram_runs(self, cram_file, tmp_path):
145+
intervals = tmp_path / "intervals.bed"
146+
intervals.write_text("chr1\t1000000\t2000000\t.\n")
147+
results = frag_length_intervals(
148+
cram_file, str(intervals),
149+
quality_threshold=0,
150+
reference_file=FASTA,
151+
)
152+
assert results is not None
153+
154+
155+
class TestMultiWpsCRAMRuns:
156+
def test_cram_runs(self, cram_file, tmp_path):
157+
site_bed = tmp_path / "sites.bed"
158+
site_bed.write_text("chr1\t1000000\t1005000\n")
159+
output = tmp_path / "wps.bed.gz"
160+
multi_wps(
161+
cram_file, str(site_bed),
162+
chrom_sizes=CHROM_SIZES,
163+
output_file=str(output),
164+
quality_threshold=0,
165+
reference_file=FASTA,
166+
)
167+
assert output.exists()
168+
169+
170+
class TestCleavageProfileCRAMRuns:
171+
def test_cram_runs(self, cram_file):
172+
contig, start, stop = REGION
173+
chrom_size = 6_000_000
174+
results = cleavage_profile(
175+
cram_file, chrom_size, contig, start, stop,
176+
quality_threshold=0,
177+
reference_file=FASTA,
178+
)
179+
assert results is not None
180+
181+
182+
class TestMultiCleavageProfileCRAMRuns:
183+
def test_cram_runs(self, cram_file, tmp_path):
184+
intervals = tmp_path / "intervals.bed"
185+
intervals.write_text("chr1\t1000000\t1005000\n")
186+
output = tmp_path / "cleavage.bed.gz"
187+
multi_cleavage_profile(
188+
cram_file, str(intervals),
189+
chrom_sizes=str(CHROM_SIZES),
190+
output_file=str(output),
191+
quality_threshold=0,
192+
reference_file=FASTA,
193+
)
194+
assert output.exists()

0 commit comments

Comments
 (0)