fn validate_alignment(aln: &Alignment, x: &[u8], y: &[u8]) {

    let y = &y[aln.ystart..aln.yend];

    let mut ix = 0;
    let mut iy = 0;
    let mut calc_dist = 0;
    for op in &aln.operations {
        match *op {
            Match => {
                assert!(x[ix] == y[iy], "Match operation, but characters are not equal");
                ix += 1;
                iy += 1;
            }
            Subst => {
                assert!(x[ix] != y[iy], "Subst operation, but characters are equal");
                calc_dist += 1;
                ix += 1;
                iy += 1;
            }
            Del => {
                calc_dist += 1;
                iy += 1;
            }
            Ins => {
                calc_dist += 1;
                ix += 1;
            }
            _ => unreachable!()
        }
    }

    assert_eq!(calc_dist, aln.score as usize);
}
// Validates an Alignment based on the sequences that were used to construct it.
// - calculates the score using edit distance (mismatches / gap penalties = 1) and
//   then compares it to the stored score
// - checks if matches and substitutions are really correct given the actual sequences
Validates an Alignment based on the sequences that were used to construct it.
calculates the score using edit distance (mismatches / gap penalties = 1) and
then compares it to the stored score
checks if matches and substitutions are really correct given the actual sequences
Validates an Alignment based on the sequences that were used to construct it . calculates the score using edit distance ( mismatches / gap penalties = 1 ) and then compares it to the stored score checks if matches and substitutions are really correct given the actual sequences
fn validate_alignment(aln: &Alignment, x: &[u8], y: &[u8]) {
    let y = &y[aln.ystart..aln.yend];
    let mut ix = 0;
    let mut iy = 0;
    let mut calc_dist = 0;
    for op in &aln.operations {
        match *op {
            Match => {
                assert!(x[ix] == y[iy], "Match operation, but characters are not equal");
                ix += 1;
                iy += 1;
            }
            Subst => {
                assert!(x[ix] != y[iy], "Subst operation, but characters are equal");
                calc_dist += 1;
                ix += 1;
                iy += 1;
            }
            Del => {
                calc_dist += 1;
                iy += 1;
            }
            Ins => {
                calc_dist += 1;
                ix += 1;
            }
            _ => unreachable!()
        }
    }
    assert_eq!(calc_dist, aln.score as usize);
}
fn validate_alignment ( aln : & Alignment , x : & [ u8 ] , y : & [ u8 ] ) { let y = & y [ aln . ystart .. aln . yend ] ; let mut ix = 0 ; let mut iy = 0 ; let mut calc_dist = 0 ; for op in & aln . operations { match * op { Match => { assert ! ( x [ ix ] y [ iy ] " " ) ; ix += 1 ; iy += 1 ; } Subst => { assert ! ( x [ ix ] y [ iy ] " " ) ; calc_dist += 1 ; ix += 1 ; iy += 1 ; } Del => { calc_dist += 1 ; iy += 1 ; } Ins => { calc_dist += 1 ; ix += 1 ; } _ => unreachable ! ( ) } } assert_eq ! ( calc_dist aln score as usize ) ; }
Validates an Alignment based on the sequences that were used to construct it.
Validates an Alignment based on the sequences that were used to construct it .
aln
&Alignment
x
&[u8]
y
&[u8]
aln
&Alignment
x
&[u8]
y
&[u8]