Skip to content

Commit

Permalink
fix: bam header read error [#9]
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Feb 12, 2024
1 parent 86919e5 commit fed1ff4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ fn main() -> Result<()> {
println!("Earliest: {}", first_timestamp.format(TIME_FMT)?);
println!("Latest : {}", last_timestamp.format(TIME_FMT)?);
return Ok(());
} else {
info!(
"First and last timestamps in the input are {} and {}",
first_timestamp.format(TIME_FMT)?,
last_timestamp.format(TIME_FMT)?
);
}
info!(
"First and last timestamps in the input are {} and {}",
first_timestamp.format(TIME_FMT)?,
last_timestamp.format(TIME_FMT)?
);

let earliest = match args.earliest {
None => first_timestamp.to_owned(),
Expand Down Expand Up @@ -196,6 +195,9 @@ fn main() -> Result<()> {
.build_from_path(&args.input)?;
let header = bam_reader.read_header()?;
writer.write_header(&header)?;
// need to reopen the bam reader as the header has been read and we need to read it again
let mut bam_reader = noodles_util::alignment::io::reader::Builder::default()
.build_from_path(&args.input)?;
bam_reader.extract_reads_in_timeframe_into(
&reads_to_keep,
nb_reads_to_keep,
Expand Down

0 comments on commit fed1ff4

Please sign in to comment.