|
|
@@ -1,7 +1,7 @@
|
|
|
use crate::{
|
|
|
annotation::Annotations,
|
|
|
collection::ShouldRun,
|
|
|
- helpers::{estimate_shannon_entropy, Hash128},
|
|
|
+ helpers::{estimate_shannon_entropy, mean, Hash128},
|
|
|
positions::{GenomePosition, GetGenomePosition, VcfPosition},
|
|
|
runners::Run,
|
|
|
variant::variant_collection::VariantCollection,
|
|
|
@@ -198,6 +198,15 @@ impl VcfVariant {
|
|
|
self.infos.0.iter().any(|i| matches!(i, Info::SVTYPE(_)))
|
|
|
}
|
|
|
|
|
|
+ pub fn n_alt_depth(&self) -> Option<(u32, u32)> {
|
|
|
+ let r = self.formats.n_alt_depth();
|
|
|
+ if r.is_some() {
|
|
|
+ r
|
|
|
+ } else {
|
|
|
+ self.infos.n_alt_depth()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// Retrieves the structural variation type of the variant, if present.
|
|
|
///
|
|
|
/// Returns Some(SVType) if the variant has an SVTYPE info field,
|
|
|
@@ -397,13 +406,13 @@ impl VcfVariant {
|
|
|
return Some(DeletionDesc {
|
|
|
contig: bnd_desc.a_contig,
|
|
|
start: bnd_desc.a_position,
|
|
|
- end: bnd_desc.b_position
|
|
|
+ end: bnd_desc.b_position,
|
|
|
});
|
|
|
} else {
|
|
|
return Some(DeletionDesc {
|
|
|
contig: bnd_desc.a_contig,
|
|
|
start: bnd_desc.b_position,
|
|
|
- end: bnd_desc.a_position
|
|
|
+ end: bnd_desc.a_position,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -1067,6 +1076,32 @@ impl fmt::Display for Infos {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl Infos {
|
|
|
+ pub fn n_alt_depth(&self) -> Option<(u32, u32)> {
|
|
|
+ use Info::*;
|
|
|
+ let mut tumor_alt: Option<u32> = None;
|
|
|
+ let mut tumor_depth: Option<u32> = None;
|
|
|
+
|
|
|
+ for info in self.0.iter() {
|
|
|
+ match info {
|
|
|
+ TUMOUR_DP_AT(v) => {
|
|
|
+ let m = mean(v);
|
|
|
+ tumor_depth = Some(m.round() as u32);
|
|
|
+ }
|
|
|
+ TUMOUR_READ_SUPPORT(v) => {
|
|
|
+ tumor_alt = Some(*v);
|
|
|
+ }
|
|
|
+ _ => (),
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ match (tumor_alt, tumor_depth) {
|
|
|
+ (Some(a), Some(d)) => Some((a, d)),
|
|
|
+ _ => None,
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/// Enum representing a single INFO field in a VCF record.
|
|
|
///
|
|
|
/// Supports both standard fields and Severus-specific structural variant annotations.
|