-
Notifications
You must be signed in to change notification settings - Fork 7
Review of #164 #165
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
Review of #164 #165
Conversation
|
||
/// Result of analyzing blocks for reconsensus operation | ||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
struct BlockAnalysis { |
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.
Added Edit
to BlockAnalysis to avoid re-computing and taking decisions on separate objects
} | ||
|
||
/// Applies full reconsensus including indels and realignment | ||
fn apply_full_reconsensus( |
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.
Moved this method to the Block class edit_consensus_and_realign
.
Given a set of edits that method changes the block consensus and re-aligns all the sequences
|
||
/// Change a nucleotide in the consensus sequence at a specific position by applying a substitution. | ||
/// Updates the alignment substitutions accordingly, without changing the underlying sequences. | ||
pub fn change_consensus_nucleotide_at_pos(&mut self, s: &Sub) -> Result<(), Report> { |
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.
Given a substitution, it applies it to the block consensus sequence and updates all alignment edits for consistency.
|
||
/// Applies a set of edits to the block's consensus sequence and re-aligns the sequences | ||
/// to the new consensus. Returns a new `PangraphBlock` object with the same BlockId. | ||
pub fn edit_consensus_and_realign(self, edits: &Edit, args: &PangraphBuildArgs) -> Result<Self, Report> { |
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.
Given a set of edits (also indels) it applies them to the block consensus, and then re-aligns all block sequences to the new consensus.
- I made it return a new block instead of modifying the one existing in-place, since it has to store the new sequences anyways
- I did not parallelize the re-alignment since this should be a relatively rare operation and I don't expect it to matter much...
} | ||
|
||
/// Updates the consensus sequence of the block and re-aligns the sequences to the new consensus. | ||
fn update_block_consensus( |
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.
moved this method to the Block class edit_consensus_and_realign
// Then apply indels and realign if present | ||
if majority_edits.has_indels() { | ||
let consensus = block.consensus(); | ||
let new_consensus = majority_edits.apply(consensus)?; |
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.
this was applying substitutions twice and is now removed.
dcf6c32
into
refactor/reconsensus-updated
Review of #164
BlockAnalysis
to avoid recomputing edits (can be removed if not needed, the save should be minimal, it's more a matter of computing the object just once to avoid confusion...)apply_full_reconsensus
, avoiding dealing with substitutions twice.