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

fix: pretty print with suffix xclip or yclip #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
21 changes: 19 additions & 2 deletions src/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
Custom,
}

impl Default for AlignmentMode {
fn default() -> Self {
AlignmentMode::Global
}
}

Check warning on line 56 in src/alignment.rs

View workflow job for this annotation

GitHub Actions / clippy

this `impl` can be derived

warning: this `impl` can be derived --> src/alignment.rs:52:1 | 52 | / impl Default for AlignmentMode { 53 | | fn default() -> Self { 54 | | AlignmentMode::Global 55 | | } 56 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls = note: `#[warn(clippy::derivable_impls)]` on by default = help: remove the manual implementation... help: ...and instead derive it... | 45 + #[derive(Default)] 46 | pub enum AlignmentMode { | help: ...and mark the default variant | 48 ~ #[default] 49 ~ Global, |

/// We consider alignment between two sequences x and y. x is the query or read sequence
/// and y is the reference or template sequence. An alignment, consisting of a score,
Expand Down Expand Up @@ -259,7 +259,7 @@
y_pretty.push('-');
}
AlignmentOperation::Xclip(len) => {
for k in x.iter().take(len) {
for k in x.iter().skip(x_i).take(len) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this doesn't break non-Custom Alignments? Or maybe to be clearer, is there either (i) a test case that also covers this for for some non-custom Alignment? I could imagine, that the special casing further up is the actual problem? But you dug into this code in more detail, so are probably more confident in answering those question.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcroote Will you have time to have another look here? Otherwise I would probably move ahead with release 1.0.1 at #62 for now...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay- I'll need more time to flesh out the test cases so feel free to move ahead with the release

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick ping to see if there is any planned activity, here. If so, feel free to update the branch, first.

x_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[*k])));
x_i += 1;

Expand All @@ -269,7 +269,7 @@
}
}
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 @@
]
)
}

#[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);
}
}
Loading