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;
// 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);
#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[]);
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)