Skip to content

Commit

Permalink
do not subtract softclipped fragments with --ubam
Browse files Browse the repository at this point in the history
  • Loading branch information
wdecoster committed Oct 31, 2023
1 parent ae65f64 commit 570d403
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/extract_from_bam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub fn extract(args: &crate::Cli) -> Data {
.inspect(|_| all_counts += 1)
.filter(|read| filter_closure(read))
{
lengths.push(
read.seq_len() as u128
- read.cigar().leading_softclips() as u128
- read.cigar().trailing_softclips() as u128,
);
if args.ubam {
lengths.push(read.seq_len() as u128);
} else {
lengths.push(read.seq_len() as u128 - softclipped_bases(&read));
}
if args.karyotype || args.phased {
tids.push(read.tid());
}
Expand Down Expand Up @@ -190,3 +190,7 @@ fn get_exon_number(record: &bam::Record) -> usize {

exon_count
}

fn softclipped_bases(read: &bam::Record) -> u128 {
(read.cigar().leading_softclips() + read.cigar().trailing_softclips()) as u128
}

0 comments on commit 570d403

Please sign in to comment.