]> git.donarmstrong.com Git - samtools.git/commitdiff
sorting also considers strand
authorHeng Li <lh3@me.com>
Mon, 19 Mar 2012 17:37:30 +0000 (13:37 -0400)
committerHeng Li <lh3@me.com>
Mon, 19 Mar 2012 17:37:30 +0000 (13:37 -0400)
Previously, merging considers strand but sorting not. This is a bug and breaks
stability. Now it seems that sorting is stable and it gives the same output no
matter what parameters in use.

bam_sort.c

index bbb8f2dbaf0a48b211c789746cec0c3e836371c8..03196a8bab9892b5022f477044520c769b2ae557 100644 (file)
@@ -321,7 +321,7 @@ static inline int bam1_lt(const bam1_p a, const bam1_p b)
        if (g_is_by_qname) {
                int t = strnum_cmp(bam1_qname(a), bam1_qname(b));
                return (t < 0 || (t == 0 && (((uint64_t)a->core.tid<<32|(a->core.pos+1)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)))));
-       } else return (((uint64_t)a->core.tid<<32|(a->core.pos+1)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)));
+       } else return (((uint64_t)a->core.tid<<32|(a->core.pos+1)<<1|bam1_strand(a)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)<<1|bam1_strand(b)));
 }
 KSORT_INIT(sort, bam1_p, bam1_lt)