Skip to content

fix(params): treat --outFileNamePrefix as a literal string prefix#46

Open
pinin4fjords wants to merge 1 commit into
scverse:mainfrom
pinin4fjords:fix/out-file-name-prefix-string
Open

fix(params): treat --outFileNamePrefix as a literal string prefix#46
pinin4fjords wants to merge 1 commit into
scverse:mainfrom
pinin4fjords:fix/out-file-name-prefix-string

Conversation

@pinin4fjords
Copy link
Copy Markdown

Summary

--outFileNamePrefix SAMPLE. (or any value not ending in /) was treated as a directory by rustar - outputs landed in SAMPLE./Aligned.out.bam etc. STAR concatenates the prefix straight onto each output filename: SAMPLE.Aligned.out.bam at the top level. Every STAR wrapper assumes the latter convention; the directory behaviour breaks the output-glob convention nf-core/rnaseq and most STAR Snakemake wrappers rely on.

Root cause: out_file_name_prefix was typed as PathBuf and joined via .push("Aligned.out.bam"). That always treats the existing value as a directory component.

Fix

Change the type to String and concatenate at every output-write site:

// before:
let mut path = PathBuf::from(&params.out_file_name_prefix);
path.push("Aligned.out.bam");

// after:
let path = PathBuf::from(format!("{}Aligned.out.bam", params.out_file_name_prefix));

A small Parameters::output_path("Aligned.out.bam") helper does this concatenation once so the call sites stay readable. The chimeric junction writer (which already took the prefix as &str) was using PathBuf::push internally and is fixed the same way.

Trailing-slash prefixes (out/) still work - format! produces out/Aligned.out.bam, a valid path. The bare-dot case now produces SAMPLE.Aligned.out.bam at the top level, matching STAR.

Test plan

  • New unit tests on Parameters::output_path cover bare-dot, trailing-slash, default, and path-with-underscore prefixes
  • New integration test test_bare_dot_prefix_is_literal_string runs the binary with <run_dir>/SAMPLE. and asserts SAMPLE.Aligned.out.bam + SAMPLE.Log.final.out land at the top level and that no SAMPLE./ directory is created
  • New chimeric writer unit test test_chimeric_junction_writer_bare_dot_prefix covers the same case for Chimeric.out.junction
  • Existing integration tests (tests/alignment_features.rs, tests/phase9_threading.rs, tests/transcriptome_sam.rs) all already use trailing-slash prefixes and continue to pass unchanged
  • cargo build
  • cargo clippy --lib -- -D warnings
  • cargo fmt --check
  • cargo test - all 402 tests pass (388 lib + 9 alignment_features + 4 phase9_threading + 1 transcriptome_sam)

After this fix, no downstream wrapper needs the workaround that flattens SAMPLE./ back to STAR-style filenames after the run.

Fixes #26

PathBuf semantics joined a bare-dot prefix like SAMPLE. as a directory
component, so outputs landed at SAMPLE./Aligned.out.bam instead of
SAMPLE.Aligned.out.bam. STAR concatenates the prefix straight onto
each output filename and is the convention every STAR wrapper assumes.

Change out_file_name_prefix to String and switch every consumer from
PathBuf::push to a string concatenation. Trailing-slash prefixes
(SAMPLE./) still work since "{prefix}X.bam" produces "SAMPLE./X.bam"
which is a valid path; the bare-dot case now produces
SAMPLE.X.bam at the top level, matching STAR.

Fixes scverse#26

Co-Authored-By: Claude <noreply@anthropic.com>
@pinin4fjords
Copy link
Copy Markdown
Author

Verified end-to-end on macOS/aarch64 against the rebuilt fix branch.

Bare-dot prefix (--outFileNamePrefix SAMPLE.) - the issue's failure case:

$ ls SAMPLE.*
SAMPLE.Aligned.out.bam
SAMPLE.Log.final.out
SAMPLE.SJ.out.tab
SAMPLE.SJ.pass1.out.tab

$ [ -d "SAMPLE." ] && echo dir-exists || echo no-dir
no-dir

Top-level SAMPLE.Aligned.out.bam, SAMPLE.Log.final.out, SAMPLE.SJ.out.tab all land, matching STAR's literal-string-prefix convention. No SAMPLE./ directory created.

Trailing-slash prefix (--outFileNamePrefix outdir/) - regression check:

$ ls outdir/
Aligned.out.bam
Log.final.out
SJ.out.tab
SJ.pass1.out.tab

Still produces files inside the directory as expected; the fix didn't regress the directory-style usage.

LGTM.

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.

--outFileNamePrefix ending in . is treated as a directory (STAR uses it as a literal string prefix)

1 participant