diff --git a/format.c b/format.c index 47c1031..c042528 100644 --- a/format.c +++ b/format.c @@ -277,7 +277,7 @@ static void mp_write_residue(kstring_t *out, const mp_idx_t *mi, const mp_mapopt } } assert(nl == r->ve - r->vs); - if (l_nt == r->ve - r->vs + 3) { // then print one more codon + if (l_nt == r->ve - r->vs + 3 && str[4][w4-1] != '*') { // then print one more codon uint8_t n1 = nt[nl], n2 = nt[nl + 1], n3 = nt[nl + 2], nt_aa, codon; codon = n1<<4 | n2<<2 | n3; nt_aa = n1 > 3 || n2 > 3 || n3 > 3? ns_tab_aa20['X'] : ns_tab_codon[codon]; diff --git a/miniprot.h b/miniprot.h index f97d058..17fe8df 100644 --- a/miniprot.h +++ b/miniprot.h @@ -3,7 +3,7 @@ #include -#define MP_VERSION "0.12-r243-dirty" +#define MP_VERSION "0.12-r244-dirty" #define MP_F_NO_SPLICE 0x1 #define MP_F_NO_ALIGN 0x2 diff --git a/ntseq.c b/ntseq.c index 8eb80c1..b8efc0a 100644 --- a/ntseq.c +++ b/ntseq.c @@ -101,6 +101,8 @@ int64_t mp_ntseq_get(const mp_ntdb_t *db, int32_t cid, int64_t st, int64_t en, i int64_t mp_ntseq_get_by_v(const mp_ntdb_t *nt, int32_t vid, int64_t st, int64_t en, uint8_t *seq) { int64_t ctg_len = nt->ctg[vid>>1].len; + if (st < 0 || en < 0 || st >= ctg_len) return -1; + en = en <= ctg_len? en : ctg_len; return mp_ntseq_get(nt, vid>>1, vid&1? ctg_len - en : st, vid&1? ctg_len - st : en, vid&1, seq); }