Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment and reference sequence from CIGAR and MD #110

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
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
Generic over MatchDesc iterator type
ingolia committed Sep 28, 2018
commit 401c58c5ff2f16a3747f7f9c4d70bc824410f17d
12 changes: 7 additions & 5 deletions src/bam/md_align.rs
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ impl<'a> MDAlignPos<'a> {
/// order. For a reverse-strand alignment, they run from the last to
/// the first sequenced base.
pub struct MDAlignPosIter<'a> {
align_iter: CigarMDPosIter,
align_iter: CigarMDPosIter<IntoIter<MatchDesc>>,
record: &'a bam::record::Record,
}

@@ -415,15 +415,15 @@ impl CigarMDPos {
/// order. For a reverse-strand alignment, they run from the last to
/// the first sequenced base.
#[derive(Debug)]
pub struct CigarMDPosIter {
md_iter: IntoIter<MatchDesc>,
pub struct CigarMDPosIter<I> {
md_iter: I,
md_curr: Option<MatchDesc>,
cigar_stack: Vec<Cigar>,
ref_pos_curr: u32,
read_pos_curr: u32,
}

impl CigarMDPosIter {
impl CigarMDPosIter<IntoIter<MatchDesc>> {
/// Create a new iterator for a BAM record.
///
/// # Arguments
@@ -444,7 +444,9 @@ impl CigarMDPosIter {
read_pos_curr: 0,
})
}
}

impl <I: Iterator<Item = MatchDesc>> CigarMDPosIter<I> {
// Utility function that yields the next CigarMDPos.
// Requires the cigar stack is non-empty
// Requires that 0-length matches and non-yielding cigar entries
@@ -710,7 +712,7 @@ impl CigarMDPosIter {
}
}

impl Iterator for CigarMDPosIter {
impl <I: Iterator<Item = MatchDesc>> Iterator for CigarMDPosIter<I> {
type Item = Result<CigarMDPos, MDAlignError>;

fn next(&mut self) -> Option<Self::Item> {