Skip to content

Commit bc32fa0

Browse files
committed
Added some syntax sugar & descriptive comments.
No changes to behavior
1 parent 2a40837 commit bc32fa0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,21 @@ fn main() {
494494
let insert = record.insert_size();
495495

496496
// Orient output so that 5' most read is start, 3' read is end
497-
let start = if r1_pos >= r2_pos {r2_pos} else {r1_pos};
498-
let end = start + insert.abs();
497+
let start: i64 = if r1_pos >= r2_pos {r2_pos} else {r1_pos};
498+
let end: i64 = start + insert.abs();
499499
//let start = std::cmp::min(r1_pos, r1_pos + insert);
500500
//let end = std::cmp::max(r1_pos, r1_pos + insert);
501501

502502
// TODO: need to figure out what is correct position, add insert size or use r2_pos??
503+
// Yes, r1_pos + TLEN should give r2_pos (end - start + ), I think the following issue is a special case:
503504
// NOTE: Using current implementation, a small number of reads (~10%) have end positions shifted by ~3 bp relative to bedtools bamtobed -bedpe -i - | cut -f1,2,6
504505
// WHY???
506+
// I think this maybe is related to some CIGAR thing? But in my tests I can't work out why
507+
// I am fairly certain I am correct here and that bedtools is maybe off by 1? But my guess is I'm not accounting for something here.
508+
// bedtools calls bam_cigar_oplen when using bam.GetEndPos, but I can't tell what it's doing. My guess is it's parsing the CIGAR and shifting the coord by any mismatches/etc.
509+
// Not sure though
510+
// For future reference:
511+
// GetEndPosition -> bam_endpos -> bam_cigar_oplen in bedtools
505512
let mut stdout = std::io::stdout();
506513
if let Err(e) = writeln!(stdout, "{}\t{}\t{}", chrname, start, end) {
507514
if e.kind() != std::io::ErrorKind::BrokenPipe {

0 commit comments

Comments
 (0)