|
|
@@ -262,6 +262,8 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
}
|
|
|
|
|
|
let mut tmp_split_dir: Option<PathBuf> = None;
|
|
|
+ let mut _temp_guards: Vec<TempDirGuard> = Vec::new();
|
|
|
+
|
|
|
|
|
|
if !pod5s_to_basecall.is_empty() {
|
|
|
info!(
|
|
|
@@ -271,7 +273,8 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
|
|
|
// Create temporary directory containing only the POD5s that need basecalling
|
|
|
let local_pod5_dir = tmp_dir.join(format!("pod5s_{}", Uuid::new_v4()));
|
|
|
- let _pod5_guard = TempDirGuard::new(local_pod5_dir.clone());
|
|
|
+ _temp_guards.push(TempDirGuard::new(local_pod5_dir.clone()));
|
|
|
+
|
|
|
fs::create_dir_all(&local_pod5_dir).context(format!(
|
|
|
"Failed to create temporary POD5 directory: {}",
|
|
|
local_pod5_dir.display()
|
|
|
@@ -283,13 +286,13 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
.file_name()
|
|
|
.ok_or_else(|| anyhow::anyhow!("Invalid POD5 filename: {}", src.display()))?;
|
|
|
let dst = local_pod5_dir.join(file_name);
|
|
|
- std::os::unix::fs::symlink(src, &dst).with_context(|| {
|
|
|
- format!(
|
|
|
- "Failed to symlink POD5 '{}' to '{}'",
|
|
|
- src.display(),
|
|
|
- dst.display()
|
|
|
- )
|
|
|
- })?;
|
|
|
+ #[cfg(unix)]
|
|
|
+ std::os::unix::fs::symlink(src, &dst)
|
|
|
+ .with_context(|| format!("Failed to symlink {} → {}", src.display(), dst.display()))?;
|
|
|
+
|
|
|
+ #[cfg(not(unix))]
|
|
|
+ fs::copy(src, &dst)
|
|
|
+ .with_context(|| format!("Failed to copy {} → {}", src.display(), dst.display()))?;
|
|
|
}
|
|
|
|
|
|
let tmp_basecalled_bam = tmp_dir.join(format!("{}.bam", Uuid::new_v4()));
|
|
|
@@ -576,7 +579,6 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
SlurmRunner::run(&mut index_cmd)?;
|
|
|
|
|
|
// Merge into existing final BAM.
|
|
|
- // SamtoolsMerge::clean_up() will remove the source BAM.
|
|
|
let mut merge_cmd =
|
|
|
SamtoolsMerge::from_config(config, &case_merged_bam, &final_bam_path);
|
|
|
SlurmRunner::run(&mut merge_cmd)?;
|
|
|
@@ -589,14 +591,6 @@ pub fn import_run(run: &Pod5sRun, config: &Config) -> anyhow::Result<()> {
|
|
|
|
|
|
// First per-case BAM becomes the base final BAM.
|
|
|
fs::rename(&case_merged_bam, &final_bam_path)?;
|
|
|
-
|
|
|
- // Index the new final BAM.
|
|
|
- let mut index_cmd = SamtoolsIndex {
|
|
|
- bin: config.align.samtools_bin.clone(),
|
|
|
- threads: config.align.samtools_view_threads,
|
|
|
- bam: final_bam_path.to_string_lossy().to_string(),
|
|
|
- };
|
|
|
- SlurmRunner::run(&mut index_cmd)?;
|
|
|
}
|
|
|
|
|
|
// -----------------------------------------------------------------
|