Skip to main content

PoaGraph

Struct PoaGraph 

Source
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

Source

pub fn new() -> Self

Create an empty POA graph.

Source

pub fn from_sequence(seq: &[u8]) -> Self

Initialize a POA graph from the first sequence (linear chain of nodes).

Source

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.

Source

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.

Source

pub fn topological_sort(&self) -> Vec<usize>

Topological sort of the graph using Kahn’s algorithm.

Source

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.

Source

pub fn num_nodes(&self) -> usize

Number of nodes in the graph.

Source

pub fn num_sequences(&self) -> usize

Number of sequences that have been added to (or used to initialize) the graph.

Trait Implementations§

Source§

impl Clone for PoaGraph

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PoaGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for PoaGraph

§

impl Freeze for PoaGraph
where *const u8 is !null: Freeze, PhantomData<PoaNode>: Freeze, PhantomData<usize>: Freeze,

§

impl Move for PoaGraph

§

impl RefUnwindSafe for PoaGraph

§

impl Send for PoaGraph
where RawVecInner: Send,

§

impl Sync for PoaGraph
where RawVecInner: Sync,

§

impl Unpin for PoaGraph
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for PoaGraph

§

impl UnwindSafe for PoaGraph
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.