From: Heng Li Date: Mon, 19 Mar 2012 17:37:30 +0000 (-0400) Subject: sorting also considers strand X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=64fd9dc2c049f72448ff02f5f5c180dfdfe87c60 sorting also considers strand 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. --- diff --git a/bam_sort.c b/bam_sort.c index bbb8f2d..03196a8 100644 --- a/bam_sort.c +++ b/bam_sort.c @@ -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)