Thomas 1 долоо хоног өмнө
parent
commit
27489a85bc

+ 4 - 0
pandora-config.example.toml

@@ -199,6 +199,10 @@ clairs_image = "/mnt/beegfs02/scratch/t_steimle/somatic_pipe_tools/clairs_latest
 # Force ClairS recomputation.
 # Force ClairS recomputation.
 clairs_force = false
 clairs_force = false
 
 
+# Keep per-part directories after chunked ClairS merging.
+# Set to true to retain intermediate VCFs (raw SNV/indel/germline) for reanalysis.
+clairs_keep_parts = false
+
 # Platform preset for ClairS.
 # Platform preset for ClairS.
 clairs_platform = "ont_r10_dorado_sup_5khz_ssrs"
 clairs_platform = "ont_r10_dorado_sup_5khz_ssrs"
 
 

+ 31 - 0
src/callers/clairs.rs

@@ -945,6 +945,37 @@ pub fn run_clairs_chunked(id: &str, config: &Config, n_parts: usize) -> anyhow::
     merge_clairs_parts(&base, actual_n_parts)?;
     merge_clairs_parts(&base, actual_n_parts)?;
     merge_clairs_germline_parts(&base, actual_n_parts)?;
     merge_clairs_germline_parts(&base, actual_n_parts)?;
 
 
+    if !config.clairs_keep_parts {
+        let somatic_final = config.clairs_passed_vcf(id);
+        let germline_final = config.clairs_germline_passed_vcf(id);
+
+        anyhow::ensure!(
+            Path::new(&somatic_final).exists(),
+            "Refusing to clean up parts: merged somatic VCF not found at {}",
+            somatic_final
+        );
+        anyhow::ensure!(
+            Path::new(&germline_final).exists(),
+            "Refusing to clean up parts: merged germline VCF not found at {}",
+            germline_final
+        );
+
+        let base_dir = config.clairs_output_dir(id);
+        for i in 1..=actual_n_parts {
+            let part_dir = format!("{base_dir}/part{i}");
+            if Path::new(&part_dir).exists() {
+                fs::remove_dir_all(&part_dir)
+                    .with_context(|| format!("Failed to remove part directory: {part_dir}"))?;
+                debug!("Removed part directory: {part_dir}");
+            }
+        }
+
+        info!(
+            "Cleaned up {} part directories for {}",
+            actual_n_parts, id
+        );
+    }
+
     info!(
     info!(
         "ClairS completed for {}: {} parts merged (somatic + germline)",
         "ClairS completed for {}: {} parts merged (somatic + germline)",
         id, actual_n_parts
         id, actual_n_parts

+ 13 - 0
src/config.rs

@@ -191,6 +191,9 @@ pub struct Config {
     /// Force ClairS recomputation.
     /// Force ClairS recomputation.
     pub clairs_force: bool,
     pub clairs_force: bool,
 
 
+    /// Keep per-part directories after chunked ClairS merging (default: false).
+    pub clairs_keep_parts: bool,
+
     /// Platform preset for ClairS (e.g. "ont_r10_dorado_sup_5khz_ssrs").
     /// Platform preset for ClairS (e.g. "ont_r10_dorado_sup_5khz_ssrs").
     pub clairs_platform: String,
     pub clairs_platform: String,
 
 
@@ -666,6 +669,16 @@ impl Config {
         )
         )
     }
     }
 
 
+    /// Normal haplotagged BAM.
+    pub fn panel_bam(&self, id: &str) -> String {
+        format!(
+            "{}/panel/{}_panel_{}.bam",
+            self.tumoral_dir(id),
+            id,
+            self.reference_name,
+        )
+    }
+
     /// Normal count directory: `<normal_dir>/counts`.
     /// Normal count directory: `<normal_dir>/counts`.
     pub fn normal_dir_count(&self, id: &str) -> String {
     pub fn normal_dir_count(&self, id: &str) -> String {
         format!("{}/{}", self.normal_dir(id), self.count_dir_name)
         format!("{}/{}", self.normal_dir(id), self.count_dir_name)