Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [0.26.1] - 2019-12-03
## Changes
- Various bug fixes in CIGAR string handling, INFO tag reading and FORMAT tag reading.
- bam::Record.set() will panic if seq.len() != qual.len(). Previously, mismatched length would cause
uninitialized memory to be written into the BAM file.

## [0.26.0] - 2019-09-27
## Changes
Expand Down
9 changes: 8 additions & 1 deletion src/bam/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,17 @@ impl Record {
/// Set variable length data (qname, cigar, seq, qual).
/// Note: Pre-existing aux data will be invalidated
/// if called on an existing record. For this
/// reason, never call push_aux() before set().
/// reason, never call push_aux() before set(). `qual` is Phred-scaled
/// quality values, without any offset.
/// NOTE: seq.len() must equal qual.len() or this method
/// will panic. If you don't have quality values use
/// `let quals = vec![ 255 as u8; seq.len()];` as a placeholder that will
/// be recognized as missing QVs by `samtools`.
pub fn set(&mut self, qname: &[u8], cigar: Option<&CigarString>, seq: &[u8], qual: &[u8]) {
self.cigar = None;

assert!(seq.len() == qual.len(), "seq.len() must equal qual.len()");

let cigar_width = if let Some(cigar_string) = cigar {
cigar_string.len()
} else {
Expand Down