Quellcode durchsuchen

variant and VEP access methods

Thomas vor 7 Monaten
Ursprung
Commit
300db208af
3 geänderte Dateien mit 39 neuen und 15 gelöschten Zeilen
  1. 29 0
      src/annotation/vep.rs
  2. 0 2
      src/io/bed.rs
  3. 10 13
      src/variant/variant_collection.rs

+ 29 - 0
src/annotation/vep.rs

@@ -129,6 +129,35 @@ impl VEP {
     pub fn impact(&self) -> Option<VepImpact> {
         self.extra.impact.clone()
     }
+
+    pub fn gene(&self) -> Option<String> {
+        self.extra.symbol.clone()
+    }
+
+    pub fn gene_distance(&self) -> Option<u32> {
+        self.extra.distance
+    }
+
+    pub fn feature(&self) -> Option<String> {
+        self.feature.clone()
+    }
+
+    pub fn consequences_str(&self) -> Vec<String> {
+        match &self.consequence {
+            Some(csq) => csq.iter().map(|s| s.to_string()).collect(),
+            None => Vec::new(),
+        }
+    }
+
+    pub fn hgvs(&self) -> Option<String> {
+        if self.extra.hgvs_p.is_some() {
+            return self.extra.hgvs_p.clone();
+        }
+        if self.extra.hgvs_c.is_some() {
+            return self.extra.hgvs_c.clone();
+        }
+        None
+    }
 }
 
 /// Represents the predicted consequences of a genetic variant as determined by

+ 0 - 2
src/io/bed.rs

@@ -159,8 +159,6 @@ where
         .collect()
 }
 
-/// Same idea as `extract_contig_indices` but for a `BedRow` slice.
-///
 /// Returns a vector of  
 /// `(contig, slice_start, slice_end)` for each contig present.
 fn extract_contig_indices_bed(rows: &[BedRow]) -> Vec<(u8, usize, usize)> {

+ 10 - 13
src/variant/variant_collection.rs

@@ -595,19 +595,6 @@ impl Variant {
         (mean(&n_alts), mean(&depths))
     }
 
-    pub fn n_cosmic(&self) -> u64 {
-        self.annotations
-            .iter()
-            .find_map(|a| {
-                if let Annotation::Cosmic(c) = a {
-                    Some(c.cosmic_cnt)
-                } else {
-                    None
-                }
-            })
-            .unwrap_or_default()
-    }
-
     pub fn n_callers(&self) -> u8 {
         self.annotations
             .iter()
@@ -634,6 +621,16 @@ impl Variant {
         callers.join(", ")
     }
 
+    pub fn n_cosmic(&self) -> Option<u64> {
+        self.annotations.iter().find_map(|a| {
+            if let Annotation::Cosmic(cosmic) = a {
+                Some(cosmic.cosmic_cnt)
+            } else {
+                None
+            }
+        })
+    }
+
     /// Merge all `Infos` from the list of `VcfVariant`s.
     pub fn merge_infos(&self) -> Infos {
         use log::warn;