use crate::genome;
use crate::sequence::{Base, Sequence};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
pub trait AbstractVariant: genome::AbstractLocus {
fn kind(&self) -> &Kind;
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum Kind {
SNV(Base),
MNV(Sequence),
Insertion(Sequence),
Deletion(genome::Length),
Duplication(genome::Length),
Inversion(genome::Length),
None,
}
impl Kind {
pub fn len(&self) -> genome::Length {
match *self {
Kind::SNV(_) => 1,
Kind::MNV(ref s) => s.len() as u64,
Kind::Insertion(ref s) => s.len() as u64,
Kind::Deletion(l) => l,
Kind::Duplication(l) => l,
Kind::Inversion(l) => l,
Kind::None => 1,
}
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}