From bbce71d7fb06922f511d08f588a66ca99a7c5196 Mon Sep 17 00:00:00 2001 From: blake-bowen Date: Thu, 18 Jun 2026 14:16:35 +1000 Subject: [PATCH 1/2] bug fix for read duplication that occurs for reads spanning chunk boundaries when running sinto with --nproc > 1 --- sinto/filterbarcodes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sinto/filterbarcodes.py b/sinto/filterbarcodes.py index 3309b06..d23e63a 100644 --- a/sinto/filterbarcodes.py +++ b/sinto/filterbarcodes.py @@ -33,6 +33,9 @@ def _iterate_reads( bamlist = [pysam.AlignmentFile(x, filemode, header=newhead) for x in filelist] for i in intervals: for r in inputBam.fetch(i[0], i[1], i[2]): + # skip reads owned by the previous chunk (fetch returns overlaps), skips unmapped reads (r.reference_start < 0) + if 0 <= r.reference_start < i[1]: + continue if readname_barcode is not None: re_match = readname_barcode.search(r.qname) cell_barcode = re_match.group() From 85733b12a0fb6a926820b96c426405ffaad49d01 Mon Sep 17 00:00:00 2001 From: blake-bowen Date: Thu, 18 Jun 2026 14:29:18 +1000 Subject: [PATCH 2/2] bug fix for read duplication - use `and` instead of chained comparison --- sinto/filterbarcodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sinto/filterbarcodes.py b/sinto/filterbarcodes.py index d23e63a..df31ba7 100644 --- a/sinto/filterbarcodes.py +++ b/sinto/filterbarcodes.py @@ -33,8 +33,8 @@ def _iterate_reads( bamlist = [pysam.AlignmentFile(x, filemode, header=newhead) for x in filelist] for i in intervals: for r in inputBam.fetch(i[0], i[1], i[2]): - # skip reads owned by the previous chunk (fetch returns overlaps), skips unmapped reads (r.reference_start < 0) - if 0 <= r.reference_start < i[1]: + # skip reads owned by the previous chunk (fetch returns overlaps); unmapped reads have reference_start < 0 + if r.reference_start >= 0 and r.reference_start < i[1]: continue if readname_barcode is not None: re_match = readname_barcode.search(r.qname)