Skip to content

Commit

Permalink
fix: pretty print with suffix xclip or yclip
Browse files Browse the repository at this point in the history
Co-authored-by: slyo <[email protected]>
  • Loading branch information
dcroote and kwuiee committed Jul 14, 2023
1 parent 907b3d9 commit be9eac7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl Alignment {
y_pretty.push('-');
}
AlignmentOperation::Xclip(len) => {
for k in x.iter().take(len) {
for k in x.iter().skip(x_i).take(len) {
x_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[*k])));
x_i += 1;

Expand All @@ -269,7 +269,7 @@ impl Alignment {
}
}
AlignmentOperation::Yclip(len) => {
for k in y.iter().take(len) {
for k in y.iter().skip(y_i).take(len) {
y_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[*k])));
y_i += 1;

Expand Down Expand Up @@ -537,4 +537,21 @@ mod tests {
]
)
}

#[test]
fn test_pretty_suffix_xclip_or_yclip() {
let alignment = Alignment {
score: -7,
ystart: 1,
xstart: 0,
yend: 4,
xend: 3,
ylen: 4,
xlen: 4,
operations: vec![Yclip(1), Match, Match, Match, Xclip(1)],
mode: AlignmentMode::Custom,
};
let pretty = concat!(" TCGC\n ||| \nATCG \n\n\n");
assert_eq!(alignment.pretty(b"TCGC", b"ATCG", 100), pretty);
}
}

0 comments on commit be9eac7

Please sign in to comment.