pub struct PoaGraph { /* private fields */ }Expand description
Partial Order Alignment graph for multi-sequence consensus.
Implements the Lee 2002 algorithm: sequences are progressively aligned to the graph and integrated, building a DAG that represents the multiple alignment.
Implementations§
Source§impl PoaGraph
impl PoaGraph
Sourcepub fn from_sequence(seq: &[u8]) -> Self
pub fn from_sequence(seq: &[u8]) -> Self
Initialize a POA graph from the first sequence (linear chain of nodes).
Sourcepub fn add_sequence(&mut self, seq: &[u8], scoring: &PoaScoring) -> Result<()>
pub fn add_sequence(&mut self, seq: &[u8], scoring: &PoaScoring) -> Result<()>
Align a sequence to the graph using DP (Lee 2002), then integrate the aligned sequence into the graph.
§Errors
Returns an error if the sequence is empty or the graph is empty.
Sourcepub fn consensus(&self) -> Vec<u8> ⓘ
pub fn consensus(&self) -> Vec<u8> ⓘ
Extract consensus by finding the heaviest weighted path through the DAG.
Uses topological-order DP: for each node, the score is the maximum incoming edge weight plus the predecessor’s best score. The consensus is the path from the highest-scoring node traced back through best predecessors.
Sourcepub fn topological_sort(&self) -> Vec<usize>
pub fn topological_sort(&self) -> Vec<usize>
Topological sort of the graph using Kahn’s algorithm.
Sourcepub fn to_dot(&self) -> String
pub fn to_dot(&self) -> String
Produce a DOT-format string for visualization of the graph.
Nodes are labeled with their base character and index. Edge labels show the weight.
Sourcepub fn num_sequences(&self) -> usize
pub fn num_sequences(&self) -> usize
Number of sequences that have been added to (or used to initialize) the graph.