Skip to content

Add test suite and CI#7

Merged
Robaina merged 2 commits into
mainfrom
add-test-suite
Jun 19, 2026
Merged

Add test suite and CI#7
Robaina merged 2 commits into
mainfrom
add-test-suite

Conversation

@Robaina

@Robaina Robaina commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the pytest battery + CI that was written alongside #6 but didn't make it into main (PR #6 merged at the -p 1 fix commit only). This is a tests-only change — no production code is modified.

What's covered (32 tests)

  • Metric helpers (percent_identity, percent_matched, getQueryLength, getNumberOfMatches, sumMatchesAndMismatches, has_MD_tag) against hand-crafted segments with values verified via pysam.
  • filterSAMbyIdentity / filterSAMbyPercentMatched retention at several cutoffs, on both SAM and BAM input, and MD-less reads always dropped.
  • Output-format selection — SAM stays text, BAM is binary, and the output extension wins over the input one (regression guard for the merged single-process BAM-output fix).
  • Default output-path naming for filenames containing sam/bam (guard for the suffix-based extension fix).
  • filterSAM dispatch — invalid filter / out-of-range cutoff raising; single-vs-parallel routing, including that n_processes <= 1 never invokes the splitting machinery (regression guard for performance in multiprocessing mode much worse than single processor #3); and an end-to-end parallel run matching the serial result.

CI

GitHub Actions workflow (.github/workflows/tests.yml): conda + bioconda samtools/pysam, pip parallelbam, then pytest on push to main and on PRs. It will register and run once merged to the default branch.

🤖 Generated with Claude Code

Robaina and others added 2 commits June 19, 2026 19:11
Adds a pytest battery (32 tests) covering:
- the per-segment metric helpers (identity, matched, query length, MD-tag
  detection) against hand-crafted segments with known values;
- filterSAMbyIdentity / filterSAMbyPercentMatched retention at several
  cutoffs, on both SAM and BAM input, and that MD-less reads are dropped;
- output-format selection (SAM stays text, BAM is binary, and the *output*
  extension wins over the input one) — guarding the single-process fixes;
- default output-path naming for filenames containing 'sam'/'bam';
- filterSAM dispatch: invalid filter / out-of-range cutoff raising, and the
  single-vs-parallel routing, including that n_processes<=1 never invokes the
  splitting machinery (regression guard for #3), plus an end-to-end parallel
  run that matches the serial result.

Adds a GitHub Actions workflow (conda + bioconda samtools/pysam, pip
parallelbam) running pytest on push and PRs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The conda-based workflow failed to solve: with channel-priority strict
and the action's implicit `defaults` channel, the solver pulled ancient
`defaults` pysam builds (pysam 0.7.7 needs python <3.0) and hit a
libdeflate conflict.

Switch to actions/setup-python + apt samtools + pip (pysam, numpy,
pytest, parallelbam all have wheels / are pure-python). Simpler, faster,
and avoids the conda channel/ToS mess. Verified locally against the
PyPI pysam 0.24.0 wheel: 32 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Robaina Robaina merged commit bab3cfc into main Jun 19, 2026
2 checks passed
@Robaina Robaina self-assigned this Jun 19, 2026
@Robaina Robaina deleted the add-test-suite branch June 19, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant