Sfoglia il codice sorgente

should_run befor lock

Thomas 1 settimana fa
parent
commit
85fae9dc92
2 ha cambiato i file con 27 aggiunte e 13 eliminazioni
  1. 22 9
      src/annotation/mod.rs
  2. 5 4
      src/callers/clairs.rs

+ 22 - 9
src/annotation/mod.rs

@@ -18,7 +18,7 @@ use std::{
 
 use crate::{
     helpers::{mean, Blake3BuildHasher, Hash128},
-    variant::{vcf_variant::AlterationCategory, variant_collection::VariantCollection},
+    variant::{variant_collection::VariantCollection, vcf_variant::AlterationCategory},
 };
 use bitcode::{Decode, Encode};
 use cosmic::Cosmic;
@@ -563,17 +563,30 @@ impl Annotations {
         self.store.retain(|key, _| !keys_to_remove.contains(key));
     }
 
+    /// Adds constitutional-boundary annotations to variants lacking somatic evidence.
+    ///
+    /// This method scans all stored variant entries and identifies those that:
+    /// - have tumor-only support (`Sample::SoloTumor`), and
+    /// - lack any somatic call (`Sample::Somatic`).
+    ///
+    /// For such variants, it conditionally appends boundary annotations:
+    /// - [`Annotation::LowConstitDepth`] if any constitutional depth
+    ///   (`Annotation::ConstitDepth`) is below `min_constit_depth`;
+    /// - [`Annotation::HighConstitAlt`] if any constitutional alternate allele count
+    ///   (`Annotation::ConstitAlt`) exceeds `max_alt_constit`.
+    ///
+    /// Each boundary annotation is added at most once per variant.
     pub fn somatic_constit_boundaries(&self, max_alt_constit: u16, min_constit_depth: u16) {
         for mut entry in self.store.iter_mut() {
             let anns = entry.value_mut();
             // tumor but no somatic
-            let has_tumor = anns
-                .iter()
-                .any(|a| matches!(a, Annotation::Callers(_, Sample::SoloTumor)));
-            let has_somatic = anns
-                .iter()
-                .any(|a| matches!(a, Annotation::Callers(_, Sample::Somatic)));
-            if has_tumor && !has_somatic {
+            // let has_tumor = anns
+            //     .iter()
+            //     .any(|a| matches!(a, Annotation::Callers(_, Sample::SoloTumor)));
+            // let has_somatic = anns
+            //     .iter()
+            //     .any(|a| matches!(a, Annotation::Callers(_, Sample::Somatic)));
+            // if has_tumor && !has_somatic {
                 // push at most once
                 if anns
                     .iter()
@@ -587,7 +600,7 @@ impl Annotations {
                 {
                     anns.push(Annotation::HighConstitAlt);
                 }
-            }
+            // }
         }
     }
 

+ 5 - 4
src/callers/clairs.rs

@@ -390,15 +390,16 @@ impl SbatchRunner for ClairS {
 
 impl Run for ClairS {
     fn run(&mut self) -> anyhow::Result<()> {
+        if !self.should_run() {
+            info!("ClairS is up-to-date.");
+            return Ok(());
+        }
+
         // Acquire lock before any work
         let lock_dir = format!("{}/locks", self.config.result_dir);
         let _lock = SampleLock::acquire(&lock_dir, &self.id, "clairs")
             .with_context(|| format!("Cannot start ClairS for {}", self.id))?;
 
-        if !self.should_run() {
-            info!("ClairS is up-to-date.");
-            return Ok(());
-        }
 
         if self.config.slurm_runner {
             run_clairs_chunked(&self.id, &self.config, 50)?;