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

clean up print_clonotypes #409

Merged
merged 12 commits into from
Mar 28, 2024
Merged

Conversation

macklin-10x
Copy link
Contributor

Tidies up the implementation of print_clonotypes in preparation for additional refactoring.

enclone_print/src/print_clonotypes.rs Show resolved Hide resolved
@@ -359,7 +345,7 @@ pub fn print_clonotypes(
// Generate Loupe data.

if (!ctl.gen_opt.binary.is_empty() || !ctl.gen_opt.proto.is_empty()) && pass == 2 {
loupe_clonotypes.push(make_loupe_clonotype(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, this was always a vector with 0 or 1 elements, so we changed it to an option. Makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there are a lot of places in this codebase where a vector is used as a proxy for optionality. It is confusing at first but ends up making way more sense once refactored to an option, especially in cases where several vectors represent several items that are all either present or absent together. I have more clean-up along these lines in subsequent patches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This section of code is kind of confusing because it has this two-pass loop with a lot of pass-wise conditionals. I'm unrolling this in follow-up code to make it easier to understand what's happening.

Comment on lines -914 to -918
for ri in &results {
for vj in &ri.11 {
fate[vj.0].insert(vj.1.clone(), vj.2.clone());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, good catch! I tried to fold all of the multiple for-loops into a single pass and it looks like I missed this one. I will restore this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, no, I know why this went away - the 11th field of that results tuple was initialized with an empty vector but it was never actually written to anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Put another way - this section of code doesn't actually modify fate. The mutability was only necessary because of this little piece of code which was actually dead, just not in a way that the compiler could notice. I remove the mutability in a subsequent PR.

@macklin-10x macklin-10x merged commit 9ff82a8 into main Mar 28, 2024
2 checks passed
@macklin-10x macklin-10x deleted the macklin/clean-up-print-clonotypes branch March 28, 2024 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants