Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Alignment reconstruction on the Record
  • Loading branch information
ingolia committed Sep 29, 2018
commit 8a5e3acb42a9759a5725e36569a337289e7e95a4
13 changes: 13 additions & 0 deletions src/bam/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,19 @@ impl Record {
.filter_map(|pos| pos.ref_nt(&self))
.collect())
}

/// Reconstruct alignment from Cigar and MD information on a record.
///
/// # Errors
///
/// An error variant is returned when the record has no MD aux
/// field, when the MD aux field is malformed, or when there are
/// inconsistencies between the Cigar string and the MD field.
pub fn alignment_from_md(&self) -> Result<Alignment, MDAlignError> {
let cigar_md: Result<Vec<CigarMDPos>, MDAlignError> =
CigarMDIter::new_from_record(&self)?.collect();
Ok(cigar_md?.into_iter().collect::<Alignment>())
}
}

impl Drop for Record {
Expand Down