Skip to content

fix(sam): STAR's header text, from @HD VN:1.4 to the @CO command line - #297

Open
BenjaminDEMAILLE wants to merge 3 commits into
mainfrom
fix/sam-hd-version
Open

BenjaminDEMAILLE wants to merge 3 commits into
mainfrom
fix/sam-hd-version

Conversation

@BenjaminDEMAILLE

@BenjaminDEMAILLE BenjaminDEMAILLE commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

STAR's SAM/BAM header, line for line (started as @HD VN:1.4, extended after review).

Finding

Headers differed from STAR 2.7.11b in four ways: no @CO user command line line; --outSAMheaderCommentFile lines got a second @CO\t prefix; Aligned.toTranscriptome.out.bam carried @HD and @PG; a user --outSAMheaderHD without VN got VN:1.4 added; and the line order was @hd @sq @rg @pg @co instead of STAR's.

Cause and fix

samHeaders.cpp:samHeaders writes @hd, @sq, user @pg (outSAMheaderPG), program @pg, comment-file lines verbatim (blank lines skipped), @rg, @CO\tuser command line: <commandLine>. The transcriptome BAM header is @sq and @rg only (top of the same function). Parameters.cpp builds commandLine as argv joined by spaces, a value argument with white space wrapped in quotes.

The header text is now rendered once by io::sam::render_header_text (kinds Main, MainSorted, Transcriptome) and used by the SAM, BAM, sorted BAM and stdout writers, instead of noodles' serializer. The user @HD string is emitted verbatim, so no VN is invented (the noodles map is no longer the source of the @hd line). Parameters::star_command_line holds STAR's command line format. The @PG ID/PN/VN/CL stay rustar-aligner's own (intended difference).

Results

Full headers compared with STAR on the yeast index (SAM, BAM Unsorted, BAM SortedByCoordinate, TranscriptomeSAM, with RG line, --outSAMheaderPG, comment file, --outSAMheaderHD with and without VN): identical apart from the program @pg line and the binary path in @co.

Tests

New header_text_follows_stars_layout; sorted-header test uses the new renderer; tests/determinism.rs also drops @CO (it records the thread count). cargo test --release, clippy -D warnings, fmt clean.

Earlier commits in this PR

  • @HD VN:1.4 by default (samHeaders.cpp:94), SO:coordinate appended after the user's @HD fields for sorted BAM, --outSAMheaderHD - accepted as STAR's default.

Part of #298.

🤖 Generated with Claude Code

STAR hard-codes `@HD VN:1.4` (samHeaders.cpp:94); rustar wrote noodles'
default 1.6, so the first header line differed from STAR's in every SAM and
BAM. A VN given in --outSAMheaderHD now sets the version instead of being
stored as an extra field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BenjaminDEMAILLE and others added 2 commits October 8, 2026 21:15
…outSAMheaderHD -

STAR builds the sorted header as samHeaderHD + "\tSO:coordinate"
(samHeaders.cpp:100), so a user @hd keeps its field order and SO comes last.
'-' is STAR's default for --outSAMheaderHD and was rejected as a malformed
field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…file, user @hd, transcriptome BAM

STAR's header layout (samHeaders.cpp): @hd as the user wrote it (VN:1.4 by
default, no VN added to a user @hd), @sq, user @pg, program @pg, comment-file
lines verbatim (blank lines skipped), @rg, then @co user command line. The
transcriptome BAM carries only @sq and @rg. The text is rendered once from the
parameters and shared by the SAM and BAM writers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BenjaminDEMAILLE BenjaminDEMAILLE changed the title fix(sam): write STAR's @HD VN:1.4 header version fix(sam): STAR's header text, from @HD VN:1.4 to the @CO command line Oct 8, 2026

This branch has not been deployed

No deployments
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