From 8589859ebada80c94ce3880b908a476b6de829b9 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Tue, 12 May 2026 18:02:40 +0100 Subject: [PATCH 1/2] fix(chimeric): create output parent directory before writing The chimeric output writer constructs its path as /Chimeric.out.junction, treating the prefix as a directory regardless of whether it ends in `/`. In two-pass mode the chim writer fires before any other output creates that directory, so the file open fails with "No such file or directory" and the entire run aborts. Call create_dir_all on the parent of the chim output path before opening the file. Without two-pass mode the bug was masked because another output writer happened to create the dir first. Fixes #35 --- src/chimeric/output.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/chimeric/output.rs b/src/chimeric/output.rs index 37f22b2..dea2d41 100644 --- a/src/chimeric/output.rs +++ b/src/chimeric/output.rs @@ -25,6 +25,12 @@ impl ChimericJunctionWriter { let mut path = PathBuf::from(prefix); path.push("Chimeric.out.junction"); + if let Some(parent) = path.parent() + && !parent.as_os_str().is_empty() + { + std::fs::create_dir_all(parent).map_err(|e| Error::io(e, parent))?; + } + let file = File::create(&path).map_err(|e| Error::io(e, &path))?; let writer = BufWriter::new(file); @@ -287,6 +293,30 @@ mod tests { assert!(path.exists()); } + #[test] + fn test_chimeric_junction_writer_creates_missing_parent() { + // Regression test for #35: when --twopassMode Basic is combined with + // --chimSegmentMin > 0 and --outFileNamePrefix doesn't end in `/`, the + // chim writer fires before any other output writer creates the parent + // directory. The writer must create the parent itself. + let dir = tempdir().unwrap(); + let prefix_path = dir.path().join("sample."); + let prefix = prefix_path.to_str().unwrap(); + + assert!(!prefix_path.exists(), "parent dir should not exist yet"); + + let writer = ChimericJunctionWriter::new(prefix); + assert!( + writer.is_ok(), + "writer should create missing parent dir, got: {:?}", + writer.err() + ); + + let mut path = PathBuf::from(prefix); + path.push("Chimeric.out.junction"); + assert!(path.exists(), "chim output file should exist at {:?}", path); + } + #[test] fn test_write_inter_chromosomal() { let dir = tempdir().unwrap(); From 176a94cb978cc1335cf3af4df4a9001651049e04 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Tue, 12 May 2026 18:12:34 +0100 Subject: [PATCH 2/2] chore(chimeric): remove narrative test comment --- src/chimeric/output.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/chimeric/output.rs b/src/chimeric/output.rs index dea2d41..4b2567f 100644 --- a/src/chimeric/output.rs +++ b/src/chimeric/output.rs @@ -295,10 +295,6 @@ mod tests { #[test] fn test_chimeric_junction_writer_creates_missing_parent() { - // Regression test for #35: when --twopassMode Basic is combined with - // --chimSegmentMin > 0 and --outFileNamePrefix doesn't end in `/`, the - // chim writer fires before any other output writer creates the parent - // directory. The writer must create the parent itself. let dir = tempdir().unwrap(); let prefix_path = dir.path().join("sample."); let prefix = prefix_path.to_str().unwrap();