|
@@ -12,6 +12,7 @@ use crate::{
|
|
|
nanomonsv::{NanomonsvFormat, NanomonsvInfo},
|
|
nanomonsv::{NanomonsvFormat, NanomonsvInfo},
|
|
|
sniffles::{SnifflesFormat, SnifflesInfo},
|
|
sniffles::{SnifflesFormat, SnifflesInfo},
|
|
|
},
|
|
},
|
|
|
|
|
+ config::Config,
|
|
|
in_out::{
|
|
in_out::{
|
|
|
dict_reader::read_dict,
|
|
dict_reader::read_dict,
|
|
|
get_reader,
|
|
get_reader,
|
|
@@ -23,9 +24,8 @@ use crate::{
|
|
|
chi_square_test_for_proportions, estimate_shannon_entropy, get_hts_nt_pileup, new_pg,
|
|
chi_square_test_for_proportions, estimate_shannon_entropy, get_hts_nt_pileup, new_pg,
|
|
|
new_pg_speed, print_stat_cat,
|
|
new_pg_speed, print_stat_cat,
|
|
|
},
|
|
},
|
|
|
- config::Config,
|
|
|
|
|
};
|
|
};
|
|
|
-use anyhow::{anyhow, Context, Ok, Result, Error};
|
|
|
|
|
|
|
+use anyhow::{anyhow, Context, Error, Ok, Result};
|
|
|
use csv::ReaderBuilder;
|
|
use csv::ReaderBuilder;
|
|
|
use dashmap::DashMap;
|
|
use dashmap::DashMap;
|
|
|
use hashbrown::HashMap;
|
|
use hashbrown::HashMap;
|
|
@@ -109,7 +109,15 @@ impl fmt::Display for StatsBAM {
|
|
|
|
|
|
|
|
impl Variants {
|
|
impl Variants {
|
|
|
pub fn from_vec(name: String, mp: &MultiProgress, data: Vec<Variant>) -> Self {
|
|
pub fn from_vec(name: String, mp: &MultiProgress, data: Vec<Variant>) -> Self {
|
|
|
- Self { name, data, constit: DashMap::new(), stats_vcf: StatsVCF::default(), stats_bam: StatsBAM::default(), cfg: Config::get().unwrap(), mp: mp.clone() }
|
|
|
|
|
|
|
+ Self {
|
|
|
|
|
+ name,
|
|
|
|
|
+ data,
|
|
|
|
|
+ constit: DashMap::new(),
|
|
|
|
|
+ stats_vcf: StatsVCF::default(),
|
|
|
|
|
+ stats_bam: StatsBAM::default(),
|
|
|
|
|
+ cfg: Config::get().unwrap(),
|
|
|
|
|
+ mp: mp.clone(),
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
pub fn from_vcfs(
|
|
pub fn from_vcfs(
|
|
|
name: String,
|
|
name: String,
|
|
@@ -519,7 +527,6 @@ impl Variants {
|
|
|
e.callers_data.iter().for_each(|cd| {
|
|
e.callers_data.iter().for_each(|cd| {
|
|
|
v.callers_data.push(cd.clone());
|
|
v.callers_data.push(cd.clone());
|
|
|
v.callers_data.dedup();
|
|
v.callers_data.dedup();
|
|
|
-
|
|
|
|
|
});
|
|
});
|
|
|
v.source.extend(e.source.clone());
|
|
v.source.extend(e.source.clone());
|
|
|
v.source.dedup();
|
|
v.source.dedup();
|
|
@@ -631,6 +638,23 @@ impl Variants {
|
|
|
});
|
|
});
|
|
|
Ok(())
|
|
Ok(())
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ pub fn category_iter(&self, category: &VariantCategory) -> Vec<&Variant> {
|
|
|
|
|
+ self.data.par_iter().filter(|v| {
|
|
|
|
|
+ for annotation in v.annotations.iter() {
|
|
|
|
|
+ match annotation {
|
|
|
|
|
+ AnnotationType::VariantCategory(cat) => {
|
|
|
|
|
+ if cat == category {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ _ => (),
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }).collect::<Vec<&Variant>>()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
pub fn filter_snp(&mut self) -> Result<i32> {
|
|
pub fn filter_snp(&mut self) -> Result<i32> {
|
|
|
let n_snp = AtomicI32::new(0);
|
|
let n_snp = AtomicI32::new(0);
|
|
|
self.data = self
|
|
self.data = self
|
|
@@ -866,6 +890,7 @@ impl CallerData {
|
|
|
Format::Nanomonsv(v) => v.tr - v.vr,
|
|
Format::Nanomonsv(v) => v.tr - v.vr,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/// Variants filter rules
|
|
/// Variants filter rules
|
|
|
pub fn should_filter(&self) -> bool {
|
|
pub fn should_filter(&self) -> bool {
|
|
|
if let Info::Sniffles(info) = &self.info {
|
|
if let Info::Sniffles(info) = &self.info {
|
|
@@ -954,21 +979,6 @@ impl Variant {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // fn get_vaf(&mut self) -> f32 {
|
|
|
|
|
- // if let Some(vaf) = self.vaf {
|
|
|
|
|
- // return vaf;
|
|
|
|
|
- // } else {
|
|
|
|
|
- // let vaf = match &self.format {
|
|
|
|
|
- // Format::DeepVariant(v) => v.vaf as f32,
|
|
|
|
|
- // Format::ClairS(v) => v.af as f32,
|
|
|
|
|
- // Format::Sniffles(v) => v.dv as f32 / self.get_depth() as f32,
|
|
|
|
|
- // Format::Nanomonsv(v) => v.vr as f32 / self.get_depth() as f32,
|
|
|
|
|
- // };
|
|
|
|
|
- // self.vaf = Some(vaf);
|
|
|
|
|
- // return vaf;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
pub fn get_depth(&mut self) -> u32 {
|
|
pub fn get_depth(&mut self) -> u32 {
|
|
|
if let Some(depth) = self.depth {
|
|
if let Some(depth) = self.depth {
|
|
|
return depth;
|
|
return depth;
|
|
@@ -1057,20 +1067,6 @@ impl Variant {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // fn get_n_ref(&mut self) -> u32 {
|
|
|
|
|
- // if let Some(n_ref) = self.n_ref {
|
|
|
|
|
- // return n_ref;
|
|
|
|
|
- // } else {
|
|
|
|
|
- // let n_ref = match &self.format {
|
|
|
|
|
- // Format::DeepVariant(v) => v.ad.get(0).unwrap().to_owned(),
|
|
|
|
|
- // Format::ClairS(v) => v.ad.get(0).unwrap().to_owned(),
|
|
|
|
|
- // Format::Sniffles(v) => v.dr,
|
|
|
|
|
- // Format::Nanomonsv(v) => v.tr,
|
|
|
|
|
- // };
|
|
|
|
|
- // self.n_ref = Some(n_ref);
|
|
|
|
|
- // return n_ref;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
pub fn get_veps(&self) -> Vec<VEP> {
|
|
pub fn get_veps(&self) -> Vec<VEP> {
|
|
|
self.annotations
|
|
self.annotations
|
|
|
.iter()
|
|
.iter()
|
|
@@ -1210,14 +1206,6 @@ impl fmt::Display for Base {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
|
|
|
-// enum VCFSource {
|
|
|
|
|
-// DeepVariant,
|
|
|
|
|
-// ClairS,
|
|
|
|
|
-// Sniffles,
|
|
|
|
|
-// Nanomonsv,
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
|
|
pub enum Format {
|
|
pub enum Format {
|
|
|
DeepVariant(DeepVariantFormat),
|
|
DeepVariant(DeepVariantFormat),
|
|
@@ -1234,9 +1222,6 @@ pub enum Info {
|
|
|
Nanomonsv(NanomonsvInfo),
|
|
Nanomonsv(NanomonsvInfo),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// type DeepVariantInfo = String;
|
|
|
|
|
-// type ClairSInfo = String;
|
|
|
|
|
-
|
|
|
|
|
fn parse_info(s: &str, source: &VCFSource) -> Result<Info> {
|
|
fn parse_info(s: &str, source: &VCFSource) -> Result<Info> {
|
|
|
match source {
|
|
match source {
|
|
|
VCFSource::DeepVariant => Ok(Info::DeepVariant(s.parse()?)),
|
|
VCFSource::DeepVariant => Ok(Info::DeepVariant(s.parse()?)),
|