From a7dfcd368cda94d5847d3f2b42d4288399d77835 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Fri, 6 Nov 2009 14:06:40 +0000 Subject: [PATCH] * samtools-0.1.6-21 (r508) * fixed a potential bug in the indel caller towards the end of a chromosome --- bam_maqcns.c | 4 ++++ bam_plcmd.c | 2 +- bamtk.c | 2 +- sam_view.c | 7 +++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bam_maqcns.c b/bam_maqcns.c index 7aed741..71c2185 100644 --- a/bam_maqcns.c +++ b/bam_maqcns.c @@ -399,6 +399,10 @@ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, c left = pos > INDEL_WINDOW_SIZE? pos - INDEL_WINDOW_SIZE : 0; right = pos + INDEL_WINDOW_SIZE; if (types[0] < 0) right -= types[0]; + // in case the alignments stand out the reference + for (i = pos; i < right; ++i) + if (ref[i] == 0) break; + right = i; } { // the core part char *ref2, *rs, *inscns = 0; diff --git a/bam_plcmd.c b/bam_plcmd.c index fff42f7..e2601ec 100644 --- a/bam_plcmd.c +++ b/bam_plcmd.c @@ -182,7 +182,7 @@ static int pileup_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *p // call the consensus and indel if (d->format & BAM_PLF_CNS) // call consensus cns = bam_maqcns_call(n, pu, d->c); - if ((d->format & (BAM_PLF_CNS|BAM_PLF_INDEL_ONLY)) && d->ref) { // call indels + if ((d->format & (BAM_PLF_CNS|BAM_PLF_INDEL_ONLY)) && d->ref && pos < d->len) { // call indels if (proposed_indels) // the first element gives the size of the array r = bam_maqindel(n, pos, d->ido, pu, d->ref, proposed_indels[0], proposed_indels+1); else r = bam_maqindel(n, pos, d->ido, pu, d->ref, 0, 0); diff --git a/bamtk.c b/bamtk.c index a6bf524..b4af0ec 100644 --- a/bamtk.c +++ b/bamtk.c @@ -9,7 +9,7 @@ #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.6-19 (r494)" +#define PACKAGE_VERSION "0.1.6-21 (r508)" #endif int bam_taf2baf(int argc, char *argv[]); diff --git a/sam_view.c b/sam_view.c index 7e171b9..06dd01a 100644 --- a/sam_view.c +++ b/sam_view.c @@ -21,8 +21,11 @@ static void sol2sanger(bam1_t *b) if (g_sol2sanger_tbl[l] >= 93) g_sol2sanger_tbl[l] = 93; } } - for (l = 0; l < b->core.l_qseq; ++l) - qual[l] = g_sol2sanger_tbl[qual[l]]; + for (l = 0; l < b->core.l_qseq; ++l) { + int q = qual[l]; + if (q > 127) q = 127; + qual[l] = g_sol2sanger_tbl[q]; + } } static inline int __g_skip_aln(const bam_header_t *h, const bam1_t *b) -- 2.39.2