diff --git a/gtars/src/uniwig/counting.rs b/gtars/src/uniwig/counting.rs index 7d58ebe..3ba8b61 100644 --- a/gtars/src/uniwig/counting.rs +++ b/gtars/src/uniwig/counting.rs @@ -1207,7 +1207,8 @@ pub fn bam_to_bed_no_counts( let end_site = unwrapped_coord.alignment_end().unwrap().unwrap().get() as i32; - let shifted_pos = get_shifted_pos(&flags, start_site, end_site); + // we must shift the start position by -1 to convert bam/sam 1 based position to bed 0 based pos + let shifted_pos = get_shifted_pos(&flags, start_site-1, end_site); // Relevant comment from original bamSitesToWig.py: // The bed file needs 6 columns (even though some are dummy) @@ -1222,6 +1223,8 @@ pub fn bam_to_bed_no_counts( strand, ); + //eprintln!("here is shifted with smoothing: {} {}", shifted_pos - smoothsize, shifted_pos + smoothsize); + writer.write_all(single_line.as_bytes())?; writer.flush()?; } @@ -1242,7 +1245,7 @@ pub fn variable_shifted_bam_to_bw( records: &mut Box i32 { } } + //eprintln!("Here is read.reference_start {} and read.reference_end {}", start_site, end_site); + //eprintln!("here is shifted_pos -> {shifted_pos}"); + shifted_pos } \ No newline at end of file