|
|
@@ -6,13 +6,14 @@ use crate::{
|
|
|
variant::variant_collection::VariantCollection,
|
|
|
};
|
|
|
use anyhow::{anyhow, Context};
|
|
|
+use bitcode::{Decode, Encode};
|
|
|
use log::warn;
|
|
|
use rayon::prelude::*;
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
use std::{cmp::Ordering, collections::HashSet, fmt, hash::Hash, str::FromStr};
|
|
|
|
|
|
/// Represents a variant in the Variant Call Format (VCF).
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)]
|
|
|
pub struct VcfVariant {
|
|
|
/// A 128-bit hash of the variant's key properties for efficient comparison and storage.
|
|
|
pub hash: Hash128,
|
|
|
@@ -350,7 +351,7 @@ pub struct BNDDesc {
|
|
|
pub added_nt: String,
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, Encode, Decode)]
|
|
|
pub enum AlterationCategory {
|
|
|
SNV,
|
|
|
DEL,
|
|
|
@@ -395,7 +396,7 @@ impl From<SVType> for AlterationCategory {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Encode, Decode)]
|
|
|
pub enum SVType {
|
|
|
DEL,
|
|
|
INS,
|
|
|
@@ -463,7 +464,7 @@ impl Ord for VcfVariant {
|
|
|
}
|
|
|
|
|
|
/// Info
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default, Encode, Decode)]
|
|
|
pub struct Infos(pub Vec<Info>);
|
|
|
|
|
|
impl FromStr for Infos {
|
|
|
@@ -494,7 +495,7 @@ impl fmt::Display for Infos {
|
|
|
}
|
|
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Encode, Decode)]
|
|
|
pub enum Info {
|
|
|
Empty,
|
|
|
H,
|
|
|
@@ -689,7 +690,7 @@ pub fn concat_numbers<T: ToString>(v: &[T]) -> String {
|
|
|
}
|
|
|
|
|
|
/// Format
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Encode, Decode)]
|
|
|
pub enum Format {
|
|
|
// DeepVariant
|
|
|
GT(String),
|
|
|
@@ -721,7 +722,7 @@ pub enum Format {
|
|
|
Other((String, String)), // (key, value)
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default, Encode, Decode)]
|
|
|
pub struct Formats(pub Vec<Format>);
|
|
|
|
|
|
impl Formats {
|
|
|
@@ -911,7 +912,7 @@ impl Formats {
|
|
|
}
|
|
|
|
|
|
/// Filter
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Encode, Decode)]
|
|
|
pub enum Filter {
|
|
|
PASS,
|
|
|
Other(String),
|
|
|
@@ -937,7 +938,7 @@ impl fmt::Display for Filter {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, Encode, Decode)]
|
|
|
pub enum ReferenceAlternative {
|
|
|
Nucleotide(Base),
|
|
|
Nucleotides(Vec<Base>),
|
|
|
@@ -980,7 +981,7 @@ impl fmt::Display for ReferenceAlternative {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
|
|
|
+#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, Encode, Decode)]
|
|
|
pub enum Base {
|
|
|
A,
|
|
|
T,
|