|
|
@@ -1,4 +1,8 @@
|
|
|
-use std::{collections::HashMap, fmt, fs, path::Path};
|
|
|
+use std::{
|
|
|
+ collections::HashMap,
|
|
|
+ fmt, fs,
|
|
|
+ path::{Path, PathBuf},
|
|
|
+};
|
|
|
|
|
|
use log::{info, warn};
|
|
|
|
|
|
@@ -41,6 +45,7 @@ impl Default for CollectionsConfig {
|
|
|
}
|
|
|
#[derive(Debug)]
|
|
|
pub struct Collections {
|
|
|
+ pub result_dir: String,
|
|
|
pub pod5: Pod5Collection,
|
|
|
pub bam: BamCollection,
|
|
|
pub vcf: VcfCollection,
|
|
|
@@ -58,6 +63,7 @@ impl Collections {
|
|
|
bam,
|
|
|
vcf,
|
|
|
tasks: Vec::new(),
|
|
|
+ result_dir: result_dir.to_string(),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -103,6 +109,22 @@ impl Collections {
|
|
|
// .into_values()
|
|
|
// .for_each(|data| tasks.push(CollectionsTasks::DemuxAlign(data)));
|
|
|
|
|
|
+ // Whole scan
|
|
|
+ for bam in self.bam.by_id_completed() {
|
|
|
+ let id = bam.id;
|
|
|
+ let scan_dir = format!("{}/{}/{}/scan", self.result_dir, bam.id, bam.time_point);
|
|
|
+ if PathBuf::from(scan_dir).exists() {
|
|
|
+ let dir_mod = fs::metadata(scan_dir)?.modified()?;
|
|
|
+ if bam.file_metadata.modified() > dir_mod {
|
|
|
+ fs::remove_dir_all(scan_dir)?;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if !PathBuf::from(scan_dir).exists() {
|
|
|
+ par_whole_scan();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Remove VCF anterior to BAM
|
|
|
let vcf_by_id = self.vcf.group_by_id();
|
|
|
vcf_by_id.iter().for_each(|(id, vcfs)| {
|
|
|
@@ -209,14 +231,11 @@ impl Collections {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
- //
|
|
|
-
|
|
|
+ // Tasks sorting and dedup
|
|
|
let mut hs = HashMap::new();
|
|
|
tasks.into_iter().for_each(|t| {
|
|
|
hs.insert(t.to_string(), t);
|
|
|
});
|
|
|
-
|
|
|
self.tasks = hs.into_values().collect();
|
|
|
}
|
|
|
|