Skip to content

Commit

Permalink
fix: split bams no working as intended
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhys Newell committed May 3, 2023
1 parent ad89c5e commit 2bf7cdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/processing/bams/index_bams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ fn split_bams_to_references<R: NamedBamReader>(
let mut record: bam::Record = bam::Record::new();

while bam_generator.read(&mut record).is_some() {
let record_tid = record.tid() as usize;
let record_tid = record.tid();
if record_tid < 0 {
continue;
}
let ref_name = std::str::from_utf8(bam_generator.header().tid2name(record_tid as u32)).expect("Cannot read reference name from bam file").split('~').next().unwrap();

let writer = bam_writer_map.get_mut(ref_name).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/reference/reference_reader_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ impl ReferenceReaderUtils {
}

pub fn generate_faidx(reference_path: &str) -> IndexedReader<File> {
external_command_checker::check_for_samtools();
// debug!("Generating reference index");
let cmd_string = format!(
"set -e -o pipefail; \
samtools faidx {}",
samtools faidx {}",
reference_path
);
// debug!("Queuing cmd_string: {}", cmd_string);
Expand All @@ -216,7 +215,8 @@ impl ReferenceReaderUtils {
// debug!("Found existing index file at {}", fai_path);
return IndexedReader::from_file(&reference_path).expect("Unable to generate index");
}


external_command_checker::check_for_samtools();
std::process::Command::new("bash")
.arg("-c")
.arg(&cmd_string)
Expand Down

0 comments on commit 2bf7cdb

Please sign in to comment.