From 7b62fbb4ba82eb68edb15d59f3d2c3af0a24e040 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Thu, 2 Oct 2014 15:34:49 -0400 Subject: [PATCH] r880: bug in writing .ann file --- bntseq.c | 2 +- bwa-postalt.js | 31 +++++++++---------------------- main.c | 2 +- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/bntseq.c b/bntseq.c index 93cdba1..75e5813 100644 --- a/bntseq.c +++ b/bntseq.c @@ -226,7 +226,7 @@ static uint8_t *add1(const kseq_t *seq, bntseq_t *bns, uint8_t *pac, int64_t *m_ } p = bns->anns + bns->n_seqs; p->name = strdup((char*)seq->name.s); - p->anno = seq->comment.s? strdup((char*)seq->comment.s) : strdup("(null)"); + p->anno = seq->comment.l > 0? strdup((char*)seq->comment.s) : strdup("(null)"); p->gi = 0; p->len = seq->seq.l; p->offset = (bns->n_seqs == 0)? 0 : (p-1)->offset + (p-1)->len; p->n_ambs = 0; diff --git a/bwa-postalt.js b/bwa-postalt.js index c50ae26..ab29c9e 100644 --- a/bwa-postalt.js +++ b/bwa-postalt.js @@ -289,30 +289,9 @@ function bwa_postalt(args) if (buf2.length && (buf2[0][0] != t[0] || (buf2[0][1]&0xc0) != (t[1]&0xc0))) { for (var i = 0; i < buf2.length; ++i) print(buf2[i].join("\t")); - buf2 = []; + buf2 = []; buf3 = []; } - // test primary and if so whether it overlaps with ALT regions - if (idx_pri[t[2]] != null) { - var start = t[3], end = start; - while ((m = re_cigar.exec(t[5])) != null) - if (m[2] == 'M' || m[2] == 'D' || m[2] == 'N') - end += parseInt(m[1]); - var ovlp = idx_pri[t[2]](start, end); - if (ovlp.length > 0) { - var score = (m = /\tAS:i:(\d+)/.exec(line)) != null? parseInt(m[1]) : 1; - for (var i = 0; i < ovlp.length; ++i) - buf3.push([t[2], start, end, ovlp[i][2]]); - } - } - - // parse the XA tag - if ((m = /\tXA:Z:(\S+)/.exec(line)) == null) { - buf2.push(t); - continue; - } - var XA_strs = m[1].split(";"); - // parse the reported hit var hits = []; var NM = (m = /\tNM:i:(\d+)/.exec(line)) == null? '0' : m[1]; @@ -322,6 +301,13 @@ function bwa_postalt(args) buf2.push(t); continue; } + + // parse the XA tag + if ((m = /\tXA:Z:(\S+)/.exec(line)) == null) { + buf2.push(t); + continue; + } + var XA_strs = m[1].split(";"); hits.push(h); // parse hits in the XA tag @@ -356,6 +342,7 @@ function bwa_postalt(args) } if (i == 0 && n_rpt_lifted == 1) rpt_lifted = lifted[0].slice(0); if (lifted.length) ++n_lifted, hits[i].lifted = lifted; + buf3.push(hits[i]); } if (n_lifted == 0) { buf2.push(t); diff --git a/main.c b/main.c index b162ab0..a680b92 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.10-r878-dirty" +#define PACKAGE_VERSION "0.7.10-r880-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);