Bug fix: stop using dangling ptrs and buildPattern() in fixPartitions() - #186
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes two issues in the
fixPartitions()function fromphylotesting.cpp:stree->at(i)->alnpointers. This means that the respectivesaln->partitions[i]pointers remain dangling, as they cannot be reset in place due to the general code design. Comparison with a dangling pointer has an implementation-specific behaviour in c++, it might work or might not.Therefore, I opt to avoid it here simply by unconditionally resetting all
saln->partitionspointers and relevantsalninfo (see below). This means that now the reset happens for each PartitionFinder call, but since it happens only once, the time overhead is negligible.SuperAlignment::buildPattern()expects that the alignment pattern vector is empty. This guarantees that the function is used only during superalignment initialization, as any other usage would likely be incorrect.Here, in
fixPartitions(), we change sequence types of subalignments (and hence their pattern numbers and contents), but the patterns of taxon presence/absence remain the same. Sosaln->taxa_indexremains the same as well and it would be pointless to callsaln->buildPattern(), even if we could. But since the pattern contents of the subalignments might have changed, we have to callsaln->computeConstSites()andsaln->orderPatternByNumCharshere.