Skip to content

Commit

Permalink
change the convention how the alignment string is generated to match …
Browse files Browse the repository at this point in the history
…the more "canonical" alignment representations
  • Loading branch information
cschin committed Dec 27, 2023
1 parent 2196b35 commit 6f8d14c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pgr-db/src/aln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,10 @@ pub fn sw_align_bases(
open_penalty: i32,
extension_penalty: i32,
) -> Option<(String, String)> {
let target_str = target_str.as_bytes();
let query_str = query_str.as_bytes();

let mut target_str = (*target_str).as_bytes().to_vec();
let mut query_str = (*query_str).as_bytes().to_vec();
target_str.reverse();
query_str.reverse();
let t_len = target_str.len();
let q_len = query_str.len();

Expand Down Expand Up @@ -536,19 +537,19 @@ pub fn sw_align_bases(
f_scores[i] - extension_penalty
};

(trace_back[i][j], match_scores[i]) = if s >= e && s >= f {
(trace_back[i][j], match_scores[i]) = if s > e && s > f {
((-1, -1), s)
} else if e >= f {
} else if e > f {
((-1, 0), e)
} else {
((0, -1), f)
};

let o = match_scores[i] - open_penalty;

e_scores[i] = if o >= e { o } else { e };
e_scores[i] = if o > e { o } else { e };

f_scores[i] = if o >= f { o } else { f }
f_scores[i] = if o > f { o } else { f }
}
}
let mut t_pos = t_len;
Expand All @@ -571,8 +572,8 @@ pub fn sw_align_bases(
aln_q.push(b'-');
}
}
aln_t.reverse();
aln_q.reverse();
//aln_t.reverse();
//aln_q.reverse();

Some((
String::from_utf8_lossy(&aln_t[..]).to_string(),
Expand Down

0 comments on commit 6f8d14c

Please sign in to comment.