|
|
@@ -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");
|