Skip to content

Commit

Permalink
feat: Add DistanceMatrix type and conversion from/to Phylip matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
RagnarGrootKoerkamp committed Nov 29, 2021
1 parent d78b8ca commit 7a60d8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/distancematrix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! A distance matrix is stored as a list of taxon names, together with a square
//! or triangular matrix representing all pairwise distances.

/// The type of the matrix. Either square, lower triangular (excluding the
/// diagonal), or upper triangular (excluding the diagonal).
/// Square matrices are assumed to be symmetric, but this is not enforced nor checked.
#[derive(Debug, PartialEq, Eq)]
pub enum MatrixType {
Square,
Lower,
Upper,
}

/// A distance matrix containing a list of taxon names and a matrix of pairwise distances.
#[derive(Debug)]
pub struct DistanceMatrix {
names: Vec<String>,
distances: Vec<Vec<f32>>,
matrix_type: MatrixType,
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern crate petgraph;

pub mod alignment;
pub mod annot;
pub mod distancematrix;
pub mod genome;
#[cfg(feature = "phylogeny")]
pub mod phylogeny;
Expand Down

0 comments on commit 7a60d8b

Please sign in to comment.