From 6db2fd98aae29fcff3dae469c7672c756fc7fff3 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 28 Oct 2014 13:46:40 -0400 Subject: [PATCH] r960: merge changes from the master branch --- bwa-postalt.js | 4 +++- bwamem_pair.c | 14 +++++++------- main.c | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bwa-postalt.js b/bwa-postalt.js index b538552..6cf3dc7 100644 --- a/bwa-postalt.js +++ b/bwa-postalt.js @@ -577,11 +577,12 @@ function bwa_postalt(args) // stage the hits generated from the XA tag var cnt = 0; + var rg = (m = /\t(RG:Z:\S+)/.exec(line)) != null? m[1] : null; for (var i = 0; i < hits.length; ++i) { if (opt.verbose >= 5) print(obj2str(hits[i])); if (hits[i].g != reported_g || i == reported_i) continue; if (!opt.show_pri && idx_alt[hits[i].ctg] == null) continue; - var s = [t[0], 0, hits[i].ctg, hits[i].start+1, mapQ, hits[i].cigar, '*', 0, 0]; + var s = [t[0], 0, hits[i].ctg, hits[i].start+1, mapQ, hits[i].cigar, t[6], t[7], t[8]]; // print sequence/quality and set the rev flag if (hits[i].rev == hits[reported_i].rev) { s.push(t[9], t[10]); @@ -592,6 +593,7 @@ function bwa_postalt(args) } s.push("NM:i:" + hits[i].NM); if (hits[i].lifted_str) s.push("lt:Z:" + hits[i].lifted_str); + if (rg != null) s.push(rg); buf2.push(s); } } diff --git a/bwamem_pair.c b/bwamem_pair.c index 5d4c5c2..e405423 100644 --- a/bwamem_pair.c +++ b/bwamem_pair.c @@ -327,13 +327,13 @@ int mem_sam_pe(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, co // suboptimal hits if (!(opt->flag & MEM_F_ALL)) { for (i = 0; i < 2; ++i) { - int k = a[i].a[z[i]].secondary; - if (k >= 0) { // switch secondary and primary - assert(a[i].a[k].secondary < 0); - for (j = 0; j < n_pri[i]; ++j) - if (a[i].a[j].secondary == k || j == k) - a[i].a[j].secondary = z[i]; - a[i].a[z[i]].secondary = -1; + int k = a[i].a[z[i]].secondary_all; + if (k >= 0 && k < n_pri[i]) { // switch secondary and primary if both of them are non-ALT + assert(a[i].a[k].secondary_all < 0); + for (j = 0; j < a[i].n; ++j) + if (a[i].a[j].secondary_all == k || j == k) + a[i].a[j].secondary_all = z[i]; + a[i].a[z[i]].secondary_all = -1; } XA[i] = mem_gen_alt(opt, bns, pac, &a[i], s[i].l_seq, s[i].seq); } diff --git a/main.c b/main.c index 7591875..f8f6995 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.10-r943-dirty" +#define PACKAGE_VERSION "0.7.10-r960-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);