1use crate::genome;
2use crate::sequence::{Base, Sequence};
3
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7pub trait AbstractVariant: genome::AbstractLocus {
9 fn kind(&self) -> &Kind;
10}
11
12#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
14#[derive(Debug, PartialEq, Eq, Clone, Hash)]
15pub enum Kind {
16 SNV(Base),
17 MNV(Sequence),
18 Insertion(Sequence),
19 Deletion(genome::Length),
20 Duplication(genome::Length),
21 Inversion(genome::Length),
22 None,
23}
24
25impl Kind {
26 pub fn len(&self) -> genome::Length {
28 match *self {
29 Kind::SNV(_) => 1,
30 Kind::MNV(ref s) => s.len() as u64,
31 Kind::Insertion(ref s) => s.len() as u64,
32 Kind::Deletion(l) => l,
33 Kind::Duplication(l) => l,
34 Kind::Inversion(l) => l,
35 Kind::None => 1,
36 }
37 }
38 pub fn is_empty(&self) -> bool {
40 self.len() == 0
41 }
42}