|
@@ -7,9 +7,7 @@ use crate::{
|
|
|
collection::{flowcells::IdInput, pod5::Pod5sRun},
|
|
collection::{flowcells::IdInput, pod5::Pod5sRun},
|
|
|
commands::{
|
|
commands::{
|
|
|
dorado::{DoradoAlign, DoradoBasecall},
|
|
dorado::{DoradoAlign, DoradoBasecall},
|
|
|
- run_many_sbatch,
|
|
|
|
|
samtools::{SamtoolsIndex, SamtoolsMerge, SamtoolsMergeMany, SamtoolsSort, SamtoolsSplit},
|
|
samtools::{SamtoolsIndex, SamtoolsMerge, SamtoolsMergeMany, SamtoolsSort, SamtoolsSplit},
|
|
|
- SlurmRunner,
|
|
|
|
|
},
|
|
},
|
|
|
config::Config,
|
|
config::Config,
|
|
|
helpers::{extract_barcode, list_files_with_ext, remove_bam_with_index, TempDirGuard},
|
|
helpers::{extract_barcode, list_files_with_ext, remove_bam_with_index, TempDirGuard},
|
|
@@ -305,7 +303,8 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
// DoradoBasecall must accept a directory of POD5s here
|
|
// DoradoBasecall must accept a directory of POD5s here
|
|
|
let mut cmd =
|
|
let mut cmd =
|
|
|
DoradoBasecall::from_config(config, local_pod5_dir.clone(), tmp_basecalled_bam.clone());
|
|
DoradoBasecall::from_config(config, local_pod5_dir.clone(), tmp_basecalled_bam.clone());
|
|
|
- let _out = SlurmRunner::exec(&mut cmd)?;
|
|
|
|
|
|
|
+ let _out = crate::run!(config, &mut cmd)?;
|
|
|
|
|
+ // let _out = SlurmRunner::exec(&mut cmd)?;
|
|
|
info!("Basecalled ✅ (run: {})", run.run_id);
|
|
info!("Basecalled ✅ (run: {})", run.run_id);
|
|
|
|
|
|
|
|
// Split by read group
|
|
// Split by read group
|
|
@@ -317,7 +316,7 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
|
|
|
|
|
let mut cmd =
|
|
let mut cmd =
|
|
|
SamtoolsSplit::from_config(config, &tmp_basecalled_bam, local_split_dir.clone());
|
|
SamtoolsSplit::from_config(config, &tmp_basecalled_bam, local_split_dir.clone());
|
|
|
- let _out = SlurmRunner::exec(&mut cmd)?;
|
|
|
|
|
|
|
+ let _out = crate::run!(config, &mut cmd)?;
|
|
|
fs::remove_file(&tmp_basecalled_bam).context(format!(
|
|
fs::remove_file(&tmp_basecalled_bam).context(format!(
|
|
|
"Failed to remove temporary basecalled BAM: {}",
|
|
"Failed to remove temporary basecalled BAM: {}",
|
|
|
tmp_basecalled_bam.display()
|
|
tmp_basecalled_bam.display()
|
|
@@ -437,10 +436,14 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- run_many_sbatch(align_jobs).context(format!(
|
|
|
|
|
|
|
+ crate::run_many!(config, align_jobs).context(format!(
|
|
|
"Failed to run alignment batch for {} jobs (run: {})",
|
|
"Failed to run alignment batch for {} jobs (run: {})",
|
|
|
n_jobs, run.run_id
|
|
n_jobs, run.run_id
|
|
|
))?;
|
|
))?;
|
|
|
|
|
+ // run_many_sbatch(align_jobs, config).context(format!(
|
|
|
|
|
+ // "Failed to run alignment batch for {} jobs (run: {})",
|
|
|
|
|
+ // n_jobs, run.run_id
|
|
|
|
|
+ // ))?;
|
|
|
|
|
|
|
|
info!("Alignments done ✅ (run: {})", run.run_id);
|
|
info!("Alignments done ✅ (run: {})", run.run_id);
|
|
|
|
|
|
|
@@ -455,14 +458,18 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
let mut sort_cmd = SamtoolsSort::from_config(config, &bam, &sorted_bam);
|
|
let mut sort_cmd = SamtoolsSort::from_config(config, &bam, &sorted_bam);
|
|
|
- SlurmRunner::exec(&mut sort_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut sort_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut sort_cmd)?;
|
|
|
|
|
|
|
|
// remove unsorted chunk
|
|
// remove unsorted chunk
|
|
|
fs::remove_file(&bam)?;
|
|
fs::remove_file(&bam)?;
|
|
|
|
|
|
|
|
- let mut index_cmd =
|
|
|
|
|
- SamtoolsIndex::from_config(config, sorted_bam.to_string_lossy().to_string().as_ref());
|
|
|
|
|
- SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
+ let mut index_cmd = SamtoolsIndex::from_config(
|
|
|
|
|
+ config,
|
|
|
|
|
+ sorted_bam.to_string_lossy().to_string().as_ref(),
|
|
|
|
|
+ );
|
|
|
|
|
+ crate::run!(config, &mut index_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
|
// replace path in case_bam_map with sorted version
|
|
// replace path in case_bam_map with sorted version
|
|
|
*bam = sorted_bam;
|
|
*bam = sorted_bam;
|
|
@@ -528,7 +535,8 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
|
|
|
|
|
let mut merge_many_cmd =
|
|
let mut merge_many_cmd =
|
|
|
SamtoolsMergeMany::from_config(tmp_merged.clone(), aligned_bams.clone(), config);
|
|
SamtoolsMergeMany::from_config(tmp_merged.clone(), aligned_bams.clone(), config);
|
|
|
- SlurmRunner::exec(&mut merge_many_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut merge_many_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut merge_many_cmd)?;
|
|
|
|
|
|
|
|
// Remove chunk BAMs and their indices
|
|
// Remove chunk BAMs and their indices
|
|
|
for bam in aligned_bams {
|
|
for bam in aligned_bams {
|
|
@@ -555,16 +563,19 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
// Index both source (per-case) and destination BAMs
|
|
// Index both source (per-case) and destination BAMs
|
|
|
let mut index_cmd =
|
|
let mut index_cmd =
|
|
|
SamtoolsIndex::from_config(config, case_merged_bam.to_string_lossy().as_ref());
|
|
SamtoolsIndex::from_config(config, case_merged_bam.to_string_lossy().as_ref());
|
|
|
- SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut index_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
|
let mut index_cmd =
|
|
let mut index_cmd =
|
|
|
SamtoolsIndex::from_config(config, final_bam_path.to_string_lossy().as_ref());
|
|
SamtoolsIndex::from_config(config, final_bam_path.to_string_lossy().as_ref());
|
|
|
- SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut index_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
|
// Merge into existing final BAM.
|
|
// Merge into existing final BAM.
|
|
|
let mut merge_cmd =
|
|
let mut merge_cmd =
|
|
|
SamtoolsMerge::from_config(config, &case_merged_bam, &final_bam_path);
|
|
SamtoolsMerge::from_config(config, &case_merged_bam, &final_bam_path);
|
|
|
- SlurmRunner::exec(&mut merge_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut merge_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut merge_cmd)?;
|
|
|
} else {
|
|
} else {
|
|
|
info!(
|
|
info!(
|
|
|
" Creating new final BAM for case {} → {}",
|
|
" Creating new final BAM for case {} → {}",
|
|
@@ -589,7 +600,8 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
let mut sort_cmd = SamtoolsSort::from_config(config, &final_bam_path, &sorted_tmp);
|
|
let mut sort_cmd = SamtoolsSort::from_config(config, &final_bam_path, &sorted_tmp);
|
|
|
- SlurmRunner::exec(&mut sort_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut sort_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut sort_cmd)?;
|
|
|
|
|
|
|
|
// Replace unsorted BAM with sorted BAM
|
|
// Replace unsorted BAM with sorted BAM
|
|
|
fs::rename(&sorted_tmp, &final_bam_path)?;
|
|
fs::rename(&sorted_tmp, &final_bam_path)?;
|
|
@@ -597,7 +609,8 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
// Index the **sorted** final BAM
|
|
// Index the **sorted** final BAM
|
|
|
let mut index_cmd =
|
|
let mut index_cmd =
|
|
|
SamtoolsIndex::from_config(config, final_bam_path.to_string_lossy().as_ref());
|
|
SamtoolsIndex::from_config(config, final_bam_path.to_string_lossy().as_ref());
|
|
|
- SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
+ crate::run!(config, &mut index_cmd)?;
|
|
|
|
|
+ // SlurmRunner::exec(&mut index_cmd)?;
|
|
|
|
|
|
|
|
info!(" Output: {}", final_bam_path.display());
|
|
info!(" Output: {}", final_bam_path.display());
|
|
|
|
|
|