Skip to content

Add optional STAR alignment with isolated BAM and junction outputs - #16

Merged
Fuki-Kudoh merged 4 commits into
mainfrom
codex/implement-cli-parsing-and-validation-for-star-nn85k8
Jul 17, 2026
Merged

Add optional STAR alignment with isolated BAM and junction outputs#16
Fuki-Kudoh merged 4 commits into
mainfrom
codex/implement-cli-parsing-and-validation-for-star-nn85k8

Conversation

@Fuki-Kudoh

@Fuki-Kudoh Fuki-Kudoh commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Supersedes #15 and implements issue #14.

Motivation

Add optional STAR genome alignment while preserving the existing
Salmon/kallisto quantification workflow and output contract.

Implementation

  • Added --aligner {none,star} with default none.
  • Added validation and provenance tracking for STAR indices.
  • Added a conditional align phase using trimmed FASTQs.
  • Added paired-end and single-end STAR support.
  • Added two-pass STAR alignment with coordinate-sorted BAM output.
  • Added BAM indexing with samtools.
  • Stored STAR outputs under align/star/<sample>/.
  • Preserved existing Salmon/kallisto outputs under abundance/.
  • Added resume handling and STAR index change detection.
  • Added unit and fake-tool integration tests.
  • Updated CI, README, and software specification.

Outputs

Per sample:

  • Aligned.sortedByCoord.out.bam
  • Aligned.sortedByCoord.out.bam.bai
  • SJ.out.tab
  • ReadsPerGene.out.tab
  • Log.final.out

Human real-data validation

Validated on a 500,000-pair subset of GSE157878 BMDM RNA-seq.

  • Reference: mm10
  • Layout: paired-end
  • Strandedness: none
  • Threads: 12
  • Pipeline completed successfully.
  • BAM passed samtools quickcheck.
  • Unique mapping rate: 68.51%.
  • Reads mapped to multiple loci: 9.73%.
  • Total detected splices: 333,024.
  • STAR and Salmon outputs were both generated.
  • A second identical invocation skipped every completed phase,
    confirming resume behavior.

@Fuki-Kudoh Fuki-Kudoh changed the title Add --aligner option with STAR index validation, tests, and CI pytest step Phase 1: Add STAR CLI and reference validation Jul 17, 2026
@Fuki-Kudoh Fuki-Kudoh changed the title Phase 1: Add STAR CLI and reference validation Phase 1: Add optional STAR alignment with isolated BAM and junction outputs Jul 17, 2026
@Fuki-Kudoh

Copy link
Copy Markdown
Owner Author

Human real-data validation

Validated manually by Fuki Kudoh.

Dataset

  • GEO series: GSE157878
  • Sample: BMDM
  • Input: deterministic 500,000-pair subset
  • Layout: paired-end
  • Reference: mm10
  • Strandedness: none
  • Threads: 12
  • WulfRNA commit: f8cd86a

Results

  • The complete WulfRNA pipeline finished successfully.
  • STAR and Salmon outputs were generated in isolated output paths.
  • samtools quickcheck completed with exit code 0.
  • STAR input reads: 500,000.
  • Uniquely mapped reads: 68.51%.
  • Reads mapped to multiple loci: 9.73%.
  • Total splices: 333,024.
  • BAM, BAI, SJ.out.tab, ReadsPerGene.out.tab, Log.final.out,
    quant.sf, gene expected-count matrix, and gene TPM matrix were
    non-empty.
  • A second identical run skipped all completed phases:
    fastqc_raw, cutadapt, fastqc_trimmed, align, quant, aggregate,
    and multiqc.

Interpretation

This validates real paired-end execution, BAM integrity, splice-junction
output, coexistence with Salmon quantification, and phase-level resume.
It is an execution validation rather than a biological benchmark of
STAR counts against Salmon estimates.

…support, and tests

### Motivation

- Add an optional alignment phase using STAR so users can run STAR alongside existing Salmon/kallisto quantification without replacing quant outputs.
- Validate STAR index contents and required tools, and record STAR-related fingerprints to ensure correct resume/force-from behavior.
- Surface STAR outputs in documentation and README and capture STAR/samtools versions in metadata.
- Integrate automated tests and CI changes to exercise the new aligner code paths.

### Description

- Added a `--aligner` CLI option (choices `none|star`, default `none`) in `src/wulfrna/cli.py` and updated argument parsing to accept `aligner` and include `align` in `--force-from` choices.
- Implemented STAR index validation (`validate_star_index`), STAR fingerprinting (`fingerprint_star_index`), STAR execution (`run_star_align`), STAR output expectations and phase integration in `src/wulfrna/pipeline.py`, plus helper functions `star_sample_outputs` and `selected_phases` and inclusion of `align` in `PHASES` when enabled.
- Updated resume/manifest logic to record `aligner` and `star_index_fingerprint` and to force reruns of `align` when aligner or STAR index content changes, and added `align` phase marker behavior and output checks.
- Added STAR and samtools version capture in `src/wulfrna/io.py`, created align directories in `ensure_dirs`, updated docs (`README.md`, `docs/spec.md`) to document the `--aligner` option and STAR index layout, and updated `pyproject.toml` and CI workflow to install test extras and run `pytest`.
- Added comprehensive tests: `tests/test_cli.py`, `tests/test_reference_validation.py`, and `tests/test_star_integration.py` to cover CLI parsing, reference/index validation and end-to-end STAR integration with fake tools.

### Testing

- Installed the package with test extras via `pip install -e .[test]` and compiled package sources with `python -m compileall src/wulfrna` without errors.
- Ran the test suite with `pytest -q`, which executed the new tests under `tests/` and completed successfully.
- CI workflow was updated to include running `pytest -q` as part of the `smoke` job (installation, compile, pytest, and existing CLI/parser smoke checks are invoked).
@Fuki-Kudoh Fuki-Kudoh changed the title Phase 1: Add optional STAR alignment with isolated BAM and junction outputs Add optional STAR alignment with isolated BAM and junction outputs Jul 17, 2026
@Fuki-Kudoh
Fuki-Kudoh marked this pull request as ready for review July 17, 2026 07:44
@Fuki-Kudoh
Fuki-Kudoh merged commit 7662a86 into main Jul 17, 2026
2 checks passed
@Fuki-Kudoh
Fuki-Kudoh deleted the codex/implement-cli-parsing-and-validation-for-star-nn85k8 branch July 17, 2026 07:44
@Fuki-Kudoh Fuki-Kudoh mentioned this pull request Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant