Browse Source

utoipa variant

Thomas 1 year ago
parent
commit
b436cf29ab
2 changed files with 22 additions and 13 deletions
  1. 1 0
      src/callers/clairs.rs
  2. 21 13
      src/variants.rs

+ 1 - 0
src/callers/clairs.rs

@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
 use utoipa::ToSchema;
 use std::str::FromStr;
 
+#[derive(ToSchema)]
 pub type ClairSInfo = String;
 
 #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, ToSchema)]

+ 21 - 13
src/variants.rs

@@ -22,7 +22,8 @@ use crate::{
     },
     sql::{stats_sql::insert_stats, variants_sql::insert_variants},
     utils::{
-        chi_square_test_for_proportions, count_repetitions, estimate_shannon_entropy, get_hts_nt_pileup, new_pg, new_pg_speed, print_stat_cat
+        chi_square_test_for_proportions, count_repetitions, estimate_shannon_entropy,
+        get_hts_nt_pileup, new_pg, new_pg_speed, print_stat_cat,
     },
 };
 use anyhow::{anyhow, Context, Ok, Result};
@@ -48,7 +49,7 @@ use std::{
         Arc,
     },
 };
-use utoipa::ToSchema;
+use utoipa::{openapi::schema, ToSchema};
 
 // chr12:25116542|G>T KRAS
 #[derive(Debug, Clone)]
@@ -379,45 +380,50 @@ impl Variants {
                                         // Triplet right
                                         if count_repetitions(seq_right, 3) >= 3 {
                                             n_low_diversity.fetch_add(1, Ordering::SeqCst);
-                                            tumoral.annotations.push(AnnotationType::VariantCategory(
+                                            tumoral.annotations.push(
+                                                AnnotationType::VariantCategory(
                                                     VariantCategory::LowDiversity,
-                                                    ));
+                                                ),
+                                            );
                                             continue;
                                         }
 
                                         // Doublet right
                                         if count_repetitions(seq_right, 2) >= 4 {
                                             n_low_diversity.fetch_add(1, Ordering::SeqCst);
-                                            tumoral.annotations.push(AnnotationType::VariantCategory(
+                                            tumoral.annotations.push(
+                                                AnnotationType::VariantCategory(
                                                     VariantCategory::LowDiversity,
-                                                    ));
+                                                ),
+                                            );
                                             continue;
                                         }
 
                                         // Triplet left
                                         if count_repetitions(seq_left, 3) >= 3 {
                                             n_low_diversity.fetch_add(1, Ordering::SeqCst);
-                                            tumoral.annotations.push(AnnotationType::VariantCategory(
+                                            tumoral.annotations.push(
+                                                AnnotationType::VariantCategory(
                                                     VariantCategory::LowDiversity,
-                                                    ));
+                                                ),
+                                            );
                                             continue;
                                         }
 
                                         // Doublet left
                                         if count_repetitions(seq_left, 2) >= 4 {
                                             n_low_diversity.fetch_add(1, Ordering::SeqCst);
-                                            tumoral.annotations.push(AnnotationType::VariantCategory(
+                                            tumoral.annotations.push(
+                                                AnnotationType::VariantCategory(
                                                     VariantCategory::LowDiversity,
-                                                    ));
+                                                ),
+                                            );
                                             continue;
                                         }
-
                                     }
                                 }
                             }
 
-                            
-
                             // Check if the base is in constitutionnal pileup
                             if let ReferenceAlternative::Nucleotide(alt_b) = &tumoral.alternative {
                                 let alt_b = alt_b.clone().into_u8();
@@ -1461,7 +1467,9 @@ pub enum Format {
 
 #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, ToSchema)]
 pub enum Info {
+    #[schema(value_type=String)]
     DeepVariant(DeepVariantInfo),
+    #[schema(value_type=String)]
     ClairS(ClairSInfo),
     Sniffles(SnifflesInfo),
     Nanomonsv(NanomonsvInfo),