Kaynağa Gözat

todo_variants_agg tested

Thomas 1 yıl önce
ebeveyn
işleme
63c5922d5d
4 değiştirilmiş dosya ile 607 ekleme ve 103 silme
  1. 548 100
      Cargo.lock
  2. 31 1
      src/collection/mod.rs
  3. 1 1
      src/functions/variants.rs
  4. 27 1
      src/lib.rs

Dosya farkı çok büyük olduğundan ihmal edildi
+ 548 - 100
Cargo.lock


+ 31 - 1
src/collection/mod.rs

@@ -339,6 +339,20 @@ impl Collections {
         Ok(tasks)
     }
 
+    /// Generates pairs of diagnostic and MRD BAM files.
+    ///
+    /// This function performs the following steps:
+    /// 1. Extracts and deduplicates IDs from all BAM files.
+    /// 2. For each unique ID, attempts to find a pair of BAM files:
+    ///    - One labeled as "diag" (diagnostic)
+    ///    - One labeled as "mrd" (minimal residual disease)
+    /// 3. Returns pairs where both "diag" and "mrd" BAMs are found.
+    ///
+    /// # Returns
+    ///
+    /// * `Vec<(bam::Bam, bam::Bam)>` - A vector of tuples, each containing a pair of BAM files
+    ///   (diagnostic and MRD) for a unique ID.
+    ///
     pub fn bam_pairs(&self) -> Vec<(bam::Bam, bam::Bam)> {
         let mut ids: Vec<String> = self.bam.bams.iter().map(|b| b.id.clone()).collect();
         ids.sort();
@@ -357,7 +371,23 @@ impl Collections {
             .collect()
     }
 
-    // UNTESTED
+    /// Aggregates variant tasks based on BAM pairs and VCF files.
+    ///
+    /// This function performs the following operations:
+    /// 1. Iterates through BAM pairs (DIAG/MRD).
+    /// 2. Checks for the existence of a _constit.bytes.gz file for each pair.
+    /// 3. If the file exists, compares its modification time with VCF files.
+    /// 4. Creates variant tasks if the file is older than one of VCF or if it doesn't exist.
+    ///
+    /// # Arguments
+    ///
+    /// * `self` - The struct instance containing BAM pairs and VCF information.
+    ///
+    /// # Returns
+    ///
+    /// * `anyhow::Result<Vec<CollectionsTasks>>` - A Result containing a vector of `CollectionsTasks::Variants`
+    ///   if successful, or an error if file metadata cannot be accessed.
+    ///
     pub fn todo_variants_agg(&self) -> anyhow::Result<Vec<CollectionsTasks>> {
         let mut tasks = Vec::new();
         let config = VariantsConfig::default();

+ 1 - 1
src/functions/variants.rs

@@ -27,7 +27,7 @@ impl Variants {
     pub fn run(&self) -> anyhow::Result<()> {
         let multi = MultiProgress::default();
         multi.suspend(|| {
-            variants::run_pipe(&self.id, &multi).unwrap();
+            variants::run_pipe(&self.id, true, &multi).unwrap();
         });
 
         Ok(())

+ 27 - 1
src/lib.rs

@@ -140,6 +140,32 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn todo_agg() -> anyhow::Result<()> {
+        init();
+        let collections = Collections::new(
+            CollectionsConfig::default()
+        )?;
+        info!("Runing todo with config: {:#?}", collections);
+        let agg_tasks = collections.todo_variants_agg()?;
+        println!("{:#?}", agg_tasks);
+        println!("{}", agg_tasks.len());
+        Ok(())
+    }
+
+    #[test]
+    fn run_agg() -> anyhow::Result<()> {
+        init();
+        let mut collections = Collections::new(
+            CollectionsConfig::default()
+        )?;
+        info!("Runing todo with config: {:#?}", collections);
+        collections.tasks = collections.todo_variants_agg()?;
+        collections.run()?;
+        
+        Ok(())
+    }
+
     // export RUST_LOG="debug"
     #[test_log::test]
     fn run_t() -> anyhow::Result<()> {
@@ -179,7 +205,7 @@ mod tests {
 
     #[test_log::test]
     fn todo_assembler() -> anyhow::Result<()> {
-        let mut collections = Collections::new(
+        let collections = Collections::new(
             CollectionsConfig::default()
         )?;
         collections.todo_assembler()?;

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor