Bladeren bron

err on json annot_init

Thomas 1 jaar geleden
bovenliggende
commit
6894b8a60f
4 gewijzigde bestanden met toevoegingen van 25 en 13 verwijderingen
  1. 6 0
      jq_filters/jq_variants.jq
  2. 8 3
      src/lib.rs
  3. 2 2
      src/pipes/somatic.rs
  4. 9 8
      src/variant/variant.rs

+ 6 - 0
jq_filters/jq_variants.jq

@@ -35,3 +35,9 @@ def n_alt_in_constit:
 
 def contig(contig_str):
 	.position.contig == contig_to_num(contig_str);
+
+def get_value(key):
+	map(select(has($key)) | .[$key]) | first // null;
+
+def vcf_format(vcf_variants):
+	vcf_variants | select()

+ 8 - 3
src/lib.rs

@@ -34,7 +34,7 @@ mod tests {
     use functions::assembler::{Assembler, AssemblerConfig};
     use helpers::estimate_shannon_entropy;
     use io::bed::read_bed;
-    use log::{error, info};
+    use log::{error, info, warn};
     use pipes::somatic::Somatic;
     use positions::{overlaps_par, GenomePosition, GenomeRange};
     use rayon::prelude::*;
@@ -629,14 +629,19 @@ mod tests {
          let  collections = Collections::new(
             CollectionsConfig::default()
         )?;
-        for bam in collections.bam.by_id_completed(15.0, 10.0).iter() {
+        let bams = collections.bam.by_id_completed(15.0, 10.0);
+        let n = bams.len();
+        warn!("{n} cases");
+        for (i, bam) in bams.iter().enumerate() {
             let id = &bam.id;
+            warn!("{i}/{n} {id}");
             if id == "BANGA" {
                 continue;
             }
+
             match Somatic::initialize(id, Config::default())?.run() {
                 Ok(_) => (),
-                Err(e) => error!("{e}"),
+                Err(e) => error!("{id} {e}"),
             };
         }
         Ok(())

+ 2 - 2
src/pipes/somatic.rs

@@ -199,12 +199,12 @@ impl SomaticStats {
             .iter()
             .map(|(tumor, row)| {
                 json.push(format!(
-                    "{{caller_name:\"{tumor}\", germline: [{}] }}",
+                    "{{\"caller_name\": \"{tumor}\", \"germline\": [{}] }}",
                     germlines_callers
                         .iter()
                         .map(|g| {
                             let v = row.get(g).unwrap_or(&0);
-                            format!("{{{g}: {v}}}")
+                            format!("{{\"{g}\": {v}}}")
                         })
                         .join(", ")
                 ));

+ 9 - 8
src/variant/variant.rs

@@ -562,8 +562,8 @@ pub enum Format {
 
     // Clairs
     // when format begins with N: normal
-    AF(f32),
-    NAF(f32), // DP(u32),
+    // AF(f32),
+    // NAF(f32), // DP(u32),
     NDP(u32),
     NAD(Vec<u32>),
     AU(u32),
@@ -631,8 +631,8 @@ impl TryFrom<(&str, &str)> for Format {
             "DP" => Format::DP(parse_value(value, key)?),
             "AD" => Format::AD(parse_vec_value(value, key)?),
             "VAF" => Format::VAF(parse_value(value, key)?),
-            "AF" => Format::AF(parse_value(value, key)?),
-            "NAF" => Format::NAF(parse_value(value, key)?),
+            // "AF" => Format::AF(parse_value(value, key)?),
+            // "NAF" => Format::NAF(parse_value(value, key)?),
             "NDP" => Format::NDP(parse_value(value, key)?),
             "NAD" => Format::NAD(parse_vec_value(value, key)?),
             "AU" => Format::AU(parse_value(value, key)?),
@@ -696,8 +696,8 @@ impl From<Format> for (String, String) {
             Format::VAF(value) => ("VAF".to_string(), value.to_string()),
             Format::PL(values) => ("PL".to_string(), concat(values)),
             Format::Other((key, value)) => (key, value),
-            Format::AF(value) => ("AF".to_string(), value.to_string()),
-            Format::NAF(value) => ("NAF".to_string(), value.to_string()),
+            // Format::AF(value) => ("AF".to_string(), value.to_string()),
+            // Format::NAF(value) => ("NAF".to_string(), value.to_string()),
             Format::NDP(value) => ("NDP".to_string(), value.to_string()),
             Format::NAD(values) => ("NAD".to_string(), concat(values)),
             Format::AU(value) => ("AU".to_string(), value.to_string()),
@@ -722,7 +722,8 @@ impl Formats {
             .into_iter()
             .map(|e| {
                 if let Format::VAF(v) = e {
-                    Format::AF(v)
+                    e
+                    // Format::AF(v)
                 } else {
                     e
                 }
@@ -730,7 +731,7 @@ impl Formats {
             .filter(|format| {
                 matches!(
                     format,
-                    Format::GT(_) | Format::GQ(_) | Format::DP(_) | Format::AD(_) | Format::AF(_)
+                    Format::GT(_) | Format::GQ(_) | Format::DP(_) | Format::AD(_) /* | Format::AF(_) */
                 )
             })
             .collect();