From: Heng Li Date: Thu, 16 Sep 2010 20:54:48 +0000 (+0000) Subject: * fixed a bug in capQ X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cdfe59776873444748f34af06bed3ade0bd2aee2;hp=2cbbde8535bbb29daa4088db10d0c534fd275aec;p=samtools.git * fixed a bug in capQ * valgrind identifies a use of uninitialised value, but I have not fixed it. --- diff --git a/bam.c b/bam.c index 94b0aa8..41850ba 100644 --- a/bam.c +++ b/bam.c @@ -245,7 +245,11 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of) kputc('\t', &str); } if (c->tid < 0) kputsn("*\t", 2, &str); - else { kputs(header->target_name[c->tid], &str); kputc('\t', &str); } + else { + if (header) kputs(header->target_name[c->tid] , &str); + else kputw(c->tid, &str); + kputc('\t', &str); + } kputw(c->pos + 1, &str); kputc('\t', &str); kputw(c->qual, &str); kputc('\t', &str); if (c->n_cigar == 0) kputc('*', &str); else { @@ -257,7 +261,11 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of) kputc('\t', &str); if (c->mtid < 0) kputsn("*\t", 2, &str); else if (c->mtid == c->tid) kputsn("=\t", 2, &str); - else { kputs(header->target_name[c->mtid], &str); kputc('\t', &str); } + else { + if (header) kputs(header->target_name[c->mtid], &str); + else kputw(c->mtid, &str); + kputc('\t', &str); + } kputw(c->mpos + 1, &str); kputc('\t', &str); kputw(c->isize, &str); kputc('\t', &str); if (c->l_qseq) { for (i = 0; i < c->l_qseq; ++i) kputc(bam_nt16_rev_table[bam1_seqi(s, i)], &str); diff --git a/bam_md.c b/bam_md.c index d2c84dc..f3f7e22 100644 --- a/bam_md.c +++ b/bam_md.c @@ -200,7 +200,7 @@ int bam_realn(bam1_t *b, const char *ref) } else if (op == BAM_CSOFT_CLIP) y += ol; else if (op == BAM_CREF_SKIP) x += ol; } - if (score < 0) return -1; // no high scoring segments + if (q[1] < 0) return -1; // no high scoring segments endx = x - 1; // find the left boundary for (k = c->n_cigar - 1, score = max = 0, x = x-1, y = y-1; k >= 0; --k) { @@ -229,7 +229,7 @@ int bam_realn(bam1_t *b, const char *ref) } else if (op == BAM_CSOFT_CLIP) y -= ol; else if (op == BAM_CREF_SKIP) x -= ol; } - if (q[1] - q[0] < 15) return -1; // the high-scoring segment is too short + if (q[0] < 0 || q[1] - q[0] < 15) return -1; // the high-scoring segment is too short // modify CIGAR n_cigar = 0; cigar = calloc(c->n_cigar + 4, 4); diff --git a/bam_pileup.c b/bam_pileup.c index db170e8..266b966 100644 --- a/bam_pileup.c +++ b/bam_pileup.c @@ -391,7 +391,7 @@ int bam_mplp_auto(bam_mplp_t iter, int *_tid, int *_pos, int *n_plp, const bam_p if (new_min == (uint64_t)-1) return 0; *_tid = new_min>>32; *_pos = (uint32_t)new_min; for (i = 0; i < iter->n; ++i) { - if (iter->pos[i] == iter->min) { + if (iter->pos[i] == iter->min) { // FIXME: valgrind reports "uninitialised value(s) at this line" n_plp[i] = iter->n_plp[i], plp[i] = iter->plp[i]; ++ret; } else n_plp[i] = 0, plp[i] = 0;