Your Name hace 1 año
padre
commit
7f527d5b74
Se han modificado 5 ficheros con 104 adiciones y 9 borrados
  1. 2 2
      Cargo.lock
  2. 49 7
      src/collection/mod.rs
  3. 2 0
      src/functions/mod.rs
  4. 50 0
      src/functions/whole_scan.rs
  5. 1 0
      src/lib.rs

+ 2 - 2
Cargo.lock

@@ -2053,9 +2053,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
 
 [[package]]
 name = "openssl-src"
-version = "300.3.1+3.3.1"
+version = "300.3.2+3.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91"
+checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b"
 dependencies = [
  "cc",
 ]

+ 49 - 7
src/collection/mod.rs

@@ -18,6 +18,7 @@ use crate::{
     collection::pod5::FlowCellCase,
     commands::dorado::Dorado as BasecallAlign,
     config::Config,
+    functions::whole_scan::{WholeScan, WholeScanConfig},
 };
 
 pub mod bam;
@@ -58,7 +59,12 @@ pub struct Collections {
 
 impl Collections {
     pub fn new(config: CollectionsConfig) -> anyhow::Result<Self> {
-        let CollectionsConfig { pod_dir, corrected_fc_path, result_dir, .. } = &config;
+        let CollectionsConfig {
+            pod_dir,
+            corrected_fc_path,
+            result_dir,
+            ..
+        } = &config;
         let pod5 = Pod5Collection::new(pod_dir, corrected_fc_path, result_dir)?;
         let bam = BamCollection::new(result_dir);
         let vcf = VcfCollection::new(result_dir);
@@ -115,8 +121,15 @@ impl Collections {
         //     .for_each(|data| tasks.push(CollectionsTasks::DemuxAlign(data)));
 
         // Whole scan
-        for bam in self.bam.by_id_completed(self.config.min_diag_cov, self.config.min_mrd_cov) {
-            let scan_dir = format!("{}/{}/{}/scan", &self.config.result_dir, bam.id, bam.time_point);
+        for bam in self
+            .bam
+            .by_id_completed(self.config.min_diag_cov, self.config.min_mrd_cov)
+        {
+            let config = WholeScanConfig::default();
+            let scan_dir = format!(
+                "{}/{}/{}/{}",
+                &config.result_dir, bam.id, bam.time_point, config.scan_dir
+            );
             if PathBuf::from(&scan_dir).exists() {
                 let dir_mod = fs::metadata(&scan_dir)?.modified()?;
                 if bam.file_metadata.modified()? > dir_mod {
@@ -125,7 +138,21 @@ impl Collections {
             }
 
             if !PathBuf::from(&scan_dir).exists() {
-                par_whole_scan("/data/ref/hs1/chm13v2.0.dict", bam.path.to_str().context("Cant convert path to string")?, &scan_dir)?;
+                tasks.push(CollectionsTasks::WholeScan {
+                    id: bam.id,
+                    time_point: bam.time_point,
+                    bam: bam
+                        .path
+                        .to_str()
+                        .context("Cant convert path to string")?
+                        .to_string(),
+                    config: WholeScanConfig::default(),
+                });
+                // par_whole_scan(
+                //     "/data/ref/hs1/chm13v2.0.dict",
+                //     bam.path.to_str().context("Cant convert path to string")?,
+                //     &scan_dir,
+                // )?;
             }
         }
 
@@ -235,6 +262,8 @@ impl Collections {
             }
         });
 
+        // Variants aggregation
+
         // Tasks sorting and dedup
         let mut hs = HashMap::new();
         tasks.into_iter().for_each(|t| {
@@ -290,6 +319,12 @@ pub enum CollectionsTasks {
         mrd_bam: String,
         config: NanomonSVConfig,
     },
+    WholeScan {
+        id: String,
+        time_point: String,
+        bam: String,
+        config: WholeScanConfig,
+    },
 }
 
 impl CollectionsTasks {
@@ -325,6 +360,14 @@ impl CollectionsTasks {
             } => {
                 NanomonSV::new(&id, &diag_bam, &mrd_bam, config).run();
             }
+            CollectionsTasks::WholeScan {
+                id,
+                time_point,
+                bam,
+                config,
+            } => {
+                WholeScan::new(id, time_point, bam, config)?.run()?;
+            }
         }
         Ok(())
     }
@@ -374,6 +417,7 @@ impl fmt::Display for CollectionsTasks {
                     id, diag_bam, mrd_bam
                 )
             }
+            WholeScan { id, bam, .. } => write!(f, "Whole scan for id: {}, bam: {}", id, bam),
         }
     }
 }
@@ -381,9 +425,7 @@ impl fmt::Display for CollectionsTasks {
 pub fn run_tasks(config: CollectionsConfig) -> anyhow::Result<()> {
     let mut last_n = Vec::new();
     loop {
-        let mut collection = Collections::new(
-            config.clone()
-        )?;
+        let mut collection = Collections::new(config.clone())?;
         collection.todo()?;
         if collection.tasks.is_empty() {
             warn!("All results are update");

+ 2 - 0
src/functions/mod.rs

@@ -0,0 +1,2 @@
+pub mod whole_scan;
+

+ 50 - 0
src/functions/whole_scan.rs

@@ -0,0 +1,50 @@
+use pandora_lib_scan::par_whole_scan;
+
+#[derive(Debug)]
+pub struct WholeScanConfig {
+    pub result_dir: String,
+    pub scan_dir: String,
+    pub dict_file: String,
+}
+
+impl Default for WholeScanConfig {
+    fn default() -> Self {
+        Self {
+            result_dir: "/data/longreads_basic_pipe".to_string(),
+            scan_dir: "scan".to_string(),
+            dict_file: "/data/ref/hs1/chm13v2.0.dict".to_string(),
+        }
+    }
+}
+
+#[derive(Debug)]
+pub struct WholeScan {
+    pub id: String,
+    pub time_point: String,
+    pub bam_path: String,
+    pub config: WholeScanConfig,
+}
+
+impl WholeScan {
+    pub fn new(
+        id: String,
+        time_point: String,
+        bam_path: String,
+        config: WholeScanConfig
+    ) -> anyhow::Result<Self> {
+        Ok(WholeScan {
+            id,
+            time_point,
+            config,
+            bam_path,
+        })
+    }
+    pub fn run(&self) -> anyhow::Result<()> {
+        let scan_dir = format!(
+            "{}/{}/{}/{}",
+            &self.config.result_dir, self.id, self.time_point, self.config.scan_dir
+        );
+        par_whole_scan(&self.config.dict_file, &self.bam_path, &scan_dir)?;
+        Ok(())
+    }
+}

+ 1 - 0
src/lib.rs

@@ -6,6 +6,7 @@ pub mod modkit;
 pub mod callers;
 pub mod runners;
 pub mod collection;
+pub mod functions;
 
 #[macro_use]
 extern crate lazy_static;