-
Notifications
You must be signed in to change notification settings - Fork 4
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
break up main annotation function into small pieces #405
Conversation
88b4193
to
8fb4a75
Compare
8bf9191
to
760494f
Compare
8fb4a75
to
276a5f0
Compare
760494f
to
f048159
Compare
f048159
to
16096b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like the small functions with well chosen names
) | ||
}; | ||
key(a).cmp(&key(b)) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! A lot cleaner now. This mem swap makes the changes confusing, but looks like we have it right
let mut to_delete: Vec<bool> = vec![false; annx.len()]; | ||
let (mut u, mut v) = (Vec::<String>::new(), Vec::<String>::new()); | ||
for a in &annx { | ||
let t = a.ref_id as usize; | ||
if !rheaders[t].contains("segment") { | ||
let name = rheaders[t].after("|").between("|", "|"); | ||
if rheaders[t].contains("UTR") { | ||
u.push(name.to_string()); | ||
} | ||
if rheaders[t].contains("V-REGION") { | ||
v.push(name.to_string()); | ||
} | ||
} | ||
} | ||
v.sort(); | ||
for item in &u { | ||
if !bin_member(&v, item) { | ||
for j in 0..annx.len() { | ||
let t = annx[j].ref_id as usize; | ||
if !rheaders[t].contains("segment") { | ||
let name = rheaders[t].after("|").between("|", "|"); | ||
if rheaders[t].contains("UTR") && item == name { | ||
to_delete[j] = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
erase_if(&mut annx, &to_delete); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to get rid of this large duplicated block
Mechanistic refactoring of the annotation code from a single straight-shot function into a collection of smaller individual pieces. The only non-trivial changes to code were untangling the use of
std::mem::swap
left over from when the internal annotation types were tuples instead of structs.