CRAM writer option for read name omission #328
+203
−49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new option to enable read name omission for the CRAM writer.
By default, read name omission is disabled. To enable it, specify the option
:omit-read-names? true
:Specification
According to the CRAM specification, a CRAM encoder may omit encoding read names (
QNAME
), which makes the decoder regenerate them automatically. Details about the CRAM specification have been summarized in a previous PR.Note that read name omission relies on non-detached mate record encoding. This means that read names can only be omitted for records encoded as non-detached mates. Records encoded as detached, including those for single-end reads, cannot have their read names omitted.
Implementation
When the option
:omit-read-names? true
is specified, the CRAM writer sets theRN
field in the compression header totrue
and attempts to omit encoding read names for each record.Read name omission applies only to non-detached mate records consisting of primary and representative alignments. For other mate records, such as those involving secondary or supplementary alignments, read names will still be written to the
RN
data series, even if:omit-read-names? true
is specified.There is no surefire way to determine whether a set of mate records involves secondary or supplementary alignments. cljam's CRAM writer identifies the presence of secondary alignments using the
TC
tag and supplementary alignments using theSA
tag (which is the same approach taken by htslib).However, it's still the user's responsibility to ensure that these tags are appropriately attached to records so that the writer can correctly identify secondary and supplementary alignments.