Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib_tsalign/src/a_star_aligner/alignment_geometry.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use std::{fmt::Display, ops::Range};

#[derive(Debug, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub struct AlignmentRange {
offset: AlignmentCoordinates,
limit: AlignmentCoordinates,
}

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub struct AlignmentCoordinates {
reference: usize,
Expand Down
11 changes: 5 additions & 6 deletions lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub use compact_genome::implementation::alphabets;
pub use compact_genome::interface::alphabet::Alphabet;

#[derive(Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum MinLengthStrategySelector {
None,
Expand All @@ -68,7 +68,7 @@ pub enum MinLengthStrategySelector {
}

#[derive(Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum ChainingStrategySelector {
#[default]
Expand All @@ -78,7 +78,7 @@ pub enum ChainingStrategySelector {
}

#[derive(Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum TotalLengthStrategySelector {
None,
Expand All @@ -97,10 +97,9 @@ struct QueryData<'a> {
memory_limit: Option<usize>,
}

#[cfg_attr(feature = "serde", derive(serde::Deserialize))] // Mostly used for kwargs in python bindings
#[cfg_attr(feature = "serde", serde(default))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default, bound = ""))]
pub struct Aligner<AlphabetType: Alphabet = DnaAlphabetOrN> {
#[cfg_attr(feature = "serde", serde(skip))] // Not deserializable
costs: TemplateSwitchConfig<AlphabetType, U64Cost>,

// ↓ Settings for how the alignment (definition)
Expand Down
9 changes: 9 additions & 0 deletions lib_tsalign/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ use crate::{
pub mod io;

#[derive(Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(
feature = "serde",
serde(bound(
deserialize = "Cost: serde::Deserialize<'de>", // omit AlphabetType
serialize = "Cost: serde::Serialize" // omit AlphabetType
))
)]
pub struct TemplateSwitchConfig<AlphabetType, Cost> {
// Limits
pub left_flank_length: isize,
Expand All @@ -39,6 +47,7 @@ pub struct TemplateSwitchConfig<AlphabetType, Cost> {
pub reverse_anti_primary_gap_costs: CostFunction<isize, Cost>,
}

#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct BaseCost<Cost> {
/// Primary: reference; secondary: reference; direction: forward.
Expand Down
1 change: 1 addition & 0 deletions lib_tsalign/src/costs/cost_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod io;
/// * `f(x) = 3` for `2 <= x`.
///
/// The function can be evaluated via its [`evaluate`](Self::evaluate) function.
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct CostFunction<SourceType, Cost> {
function: Vec<(SourceType, Cost)>,
Expand Down
16 changes: 15 additions & 1 deletion lib_tsalign/src/costs/gap_affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@ use generic_a_star::cost::AStarCost;

pub mod io;

#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(
feature = "serde",
serde(bound(
deserialize = "Cost: serde::Deserialize<'de>", // omit AlphabetType
serialize = "Cost: serde::Serialize" // omit AlphabetType
))
)]
#[derive(Debug, Eq, PartialEq)]
pub struct GapAffineAlignmentCostTable<AlphabetType, Cost> {
name: String,
substitution_cost_table: Vec<Cost>,
gap_open_cost_vector: Vec<Cost>,
gap_extend_cost_vector: Vec<Cost>,
phantom_data: PhantomData<AlphabetType>,

// Establish invariance over AlphabetType
// Because we don't actually store any data of type AlphabetType,
// we do not want to use PhantomData<AlphabetType> directly,
// for example so that AlphabetType does not need to be Send + Sync for
// this cost table to be Send + Sync.
phantom_data: PhantomData<fn(AlphabetType) -> AlphabetType>,

// Cache some values that are potentially used often.
min_substitution_cost: Cost,
Expand Down
Loading