Skip to main content

normalize_sam_whitespace

Function normalize_sam_whitespace 

Source
pub fn normalize_sam_whitespace(text: &str) -> (Cow<'_, str>, bool)
Expand description

Normalize SAM header lines that use spaces instead of tabs.

Browsers and copy-paste often convert tabs to spaces. This function detects SAM header lines (@XX prefix) where fields are space-separated instead of tab-separated and converts the spaces to tabs.

Only normalizes lines that start with a SAM header record type (@HD, @SQ, @RG, @PG) followed by a space and a TAG: pattern. Lines that already contain tabs are left unchanged. @CO (comment) lines are not normalized because their content is free-form text where spaces are meaningful.

Returns the (possibly normalized) text and a boolean indicating whether any normalization was performed. Uses Cow to avoid allocation when no normalization is needed (the common case for well-formed input).