瀏覽代碼

nanomonsv tested

Thomas 16 小時之前
父節點
當前提交
e516dd6b4d

+ 11 - 10
Cargo.lock

@@ -822,7 +822,7 @@ version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
 dependencies = [
- "thiserror 2.0.15",
+ "thiserror 2.0.17",
 ]
 
 [[package]]
@@ -3017,6 +3017,7 @@ dependencies = [
  "serde_json",
  "tar",
  "tempfile",
+ "thiserror 2.0.17",
  "toml 0.9.8",
  "tracing",
  "uuid",
@@ -3137,7 +3138,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
 dependencies = [
  "memchr",
- "thiserror 2.0.15",
+ "thiserror 2.0.17",
  "ucd-trie",
 ]
 
@@ -3562,7 +3563,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
 dependencies = [
  "getrandom 0.2.16",
  "libredox",
- "thiserror 2.0.15",
+ "thiserror 2.0.17",
 ]
 
 [[package]]
@@ -3743,7 +3744,7 @@ dependencies = [
  "linear-map",
  "newtype_derive",
  "regex",
- "thiserror 2.0.15",
+ "thiserror 2.0.17",
  "url",
 ]
 
@@ -3765,7 +3766,7 @@ dependencies = [
  "linear-map",
  "newtype_derive",
  "regex",
- "thiserror 2.0.15",
+ "thiserror 2.0.17",
  "url",
 ]
 
@@ -4484,11 +4485,11 @@ dependencies = [
 
 [[package]]
 name = "thiserror"
-version = "2.0.15"
+version = "2.0.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850"
+checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
 dependencies = [
- "thiserror-impl 2.0.15",
+ "thiserror-impl 2.0.17",
 ]
 
 [[package]]
@@ -4504,9 +4505,9 @@ dependencies = [
 
 [[package]]
 name = "thiserror-impl"
-version = "2.0.15"
+version = "2.0.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0"
+checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
 dependencies = [
  "proc-macro2",
  "quote",

+ 1 - 0
Cargo.toml

@@ -52,6 +52,7 @@ directories = "6.0.0"
 rustc-hash = "2.1.1"
 hex = "0.4.3"
 walkdir = "2.5.0"
+thiserror = "2.0.17"
 
 [profile.dev]
 opt-level = 0

+ 7 - 9
src/callers/clairs.rs

@@ -170,10 +170,7 @@ use crate::{
     annotation::{Annotation, Annotations, Caller, CallerCat, Sample},
     collection::vcf::Vcf,
     commands::{
-        bcftools::{BcftoolsConcat, BcftoolsKeepPass},
-        samtools::SamtoolsMergeMany,
-        Command as JobCommand, LocalBatchRunner, LocalRunner, SbatchRunner, SlurmParams,
-        SlurmRunner,
+        Command as JobCommand, LocalBatchRunner, LocalRunner, SbatchRunner, SlurmParams, SlurmRunner, bcftools::{BcftoolsConcat, BcftoolsKeepPass}, samtools::SamtoolsMergeMany
     },
     config::Config,
     helpers::{
@@ -183,10 +180,10 @@ use crate::{
     io::vcf::read_vcf,
     pipes::{Initialize, ShouldRun, Version},
     run, run_many,
-    runners::Run,
+    runners::{Run, RunErr},
     variant::{
-        vcf_variant::{Label, Variants},
         variant_collection::VariantCollection,
+        vcf_variant::{Label, Variants},
     },
 };
 
@@ -403,7 +400,9 @@ impl SbatchRunner for ClairS {
 impl Run for ClairS {
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("ClairS is up-to-data.");
+            info!("ClairS is up-to-date.");
+            return Ok(());
+            // return Err(RunErr::UpToDate("ClairS").into());
         }
 
         if self.config.slurm_runner {
@@ -536,8 +535,7 @@ impl ClairS {
         let passed_vcf = self.somatic_passed_vcf_path();
 
         // Filter PASS
-        let keep_pass =
-            BcftoolsKeepPass::from_config(&self.config, tmp_path, passed_vcf.clone());
+        let keep_pass = BcftoolsKeepPass::from_config(&self.config, tmp_path, passed_vcf.clone());
 
         Ok(keep_pass)
     }

+ 2 - 1
src/callers/deep_somatic.rs

@@ -358,7 +358,8 @@ impl DeepSomatic {
 impl Run for DeepSomatic {
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("DeepSomatic is up-to-data.");
+            info!("DeepSomatic is up-to-data.");
+            return Ok(())
         }
 
         if self.config.slurm_runner {

+ 2 - 1
src/callers/deep_variant.rs

@@ -482,7 +482,8 @@ impl DeepVariant {
 impl Run for DeepVariant {
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("DeepVariant is up-to-data.");
+            info!("DeepVariant is up-to-data.");
+            return Ok(());
         }
 
         if self.config.slurm_runner {

+ 49 - 10
src/callers/mod.rs

@@ -122,6 +122,8 @@
 //! - Usage examples
 //! - Scientific publications
 
+use std::{sync::Arc, thread};
+
 use crate::{
     callers::{
         clairs::ClairS, deep_somatic::DeepSomatic, deep_variant::DeepVariant, nanomonsv::NanomonSV,
@@ -205,23 +207,60 @@ pub mod straglr;
 /// ```
 pub fn run_somatic_callers(id: &str, config: &Config) -> anyhow::Result<()> {
     // ClairS - somatic SNV/indels with haplotype awareness
+    // First gives germlines for phasing/haplotagging
     ClairS::initialize(id, config)?.run()?;
 
+    // if slurm send jobs in parallel else run caller sequentially
+    if config.slurm_runner {
+        let config = Arc::new(config.clone());
+        let id: Arc<str> = Arc::from(id);
+
+        let handles = vec![
+            {
+                let config = Arc::clone(&config);
+                let id = Arc::clone(&id);
+                thread::spawn(move || -> anyhow::Result<()> {
+                    Severus::initialize(&id, &config)?.run()
+                })
+            },
+            {
+                let config = Arc::clone(&config);
+                let id = Arc::clone(&id);
+                thread::spawn(move || -> anyhow::Result<()> {
+                    Savana::initialize(&id, &config)?.run()
+                })
+            },
+            {
+                let config = Arc::clone(&config);
+                let id = Arc::clone(&id);
+                thread::spawn(move || -> anyhow::Result<()> {
+                    NanomonSV::initialize(&id, &config)?.run()
+                })
+            },
+            {
+                let config = Arc::clone(&config);
+                let id = Arc::clone(&id);
+                thread::spawn(move || -> anyhow::Result<()> {
+                    DeepSomatic::initialize(&id, &config)?.run()
+                })
+            },
+        ];
+
+        for h in handles {
+            h.join().expect("thread panicked")?;
+        }
+    } else {
+        Severus::initialize(id, config)?.run()?;
+        Savana::initialize(id, config)?.run()?;
+        NanomonSV::initialize(id, config)?.run()?;
+    }
+
     // DeepVariant - germline variants for normal sample
     DeepVariant::initialize(id, &config.normal_name, config)?.run()?;
 
     // DeepVariant - germline variants for tumor sample
     DeepVariant::initialize(id, &config.tumoral_name, config)?.run()?;
 
-    // Severus - structural variants and VNTRs
-    Severus::initialize(id, config)?.run()?;
-
-    // Savana - haplotype-aware SVs and CNVs
-    Savana::initialize(id, config)?.run()?;
-
-    // NanomonSV - structural variants (paired analysis)
-    NanomonSV::initialize(id, config)?.run()?;
-
     // DeepSomatic - somatic SNV/indels
     DeepSomatic::initialize(id, config)?.run()?;
 
@@ -240,6 +279,6 @@ mod tests {
     fn callers_run_all() -> anyhow::Result<()> {
         test_init();
         let config = Config::default();
-        run_somatic_callers("DUMCO", &config)
+        run_somatic_callers("CHAHA", &config)
     }
 }

+ 2 - 1
src/callers/nanomonsv.rs

@@ -269,7 +269,8 @@ impl Run for NanomonSV {
     /// - Reference genome or control panel files are missing
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("NanomonSV is up-to-data.");
+            info!("NanomonSV is up-to-data.");
+            return Ok(());
         }
 
         let diag_bam = self.config.tumoral_bam(&self.id);

+ 2 - 1
src/callers/savana.rs

@@ -235,7 +235,8 @@ impl Run for Savana {
     /// `Ok(())` if the run completes successfully, or an error otherwise.
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("Savana is up-to-date.");
+            info!("Savana is up-to-date.");
+            return Ok(());
         }
 
         let output_vcf = &self.config.savana_output_vcf(&self.id);

+ 2 - 1
src/callers/severus.rs

@@ -199,7 +199,8 @@ impl Run for Severus {
     /// - Log files cannot be written
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("Severus is up-to-date");
+            info!("Severus is up-to-date");
+            return Ok(());
         }
 
         let id = &self.id;

+ 2 - 1
src/callers/straglr.rs

@@ -246,7 +246,8 @@ impl Run for Straglr {
     /// - Log files cannot be written
     fn run(&mut self) -> anyhow::Result<()> {
         if !self.should_run() {
-            anyhow::bail!("Straglr is up-to-date");
+            info!("Straglr is up-to-date");
+            return Ok(());
         }
 
         let id = &self.id;

+ 6 - 0
src/runners.rs

@@ -30,6 +30,12 @@ pub trait Run {
     fn run(&mut self) -> anyhow::Result<()>;
 }
 
+#[derive(Debug, thiserror::Error)]
+pub enum RunErr {
+    #[error("{0} is up-to-date")]
+    UpToDate(&'static str),
+}
+
 /// Trait for waiting on a command to complete.
 pub trait Wait {
     /// Waits for the command to complete.