Skip to content

Commit

Permalink
r259: change an assertion failure to warning
Browse files Browse the repository at this point in the history
When bonus score is too high, the assert doesn't work.
  • Loading branch information
lh3 committed Oct 2, 2024
1 parent 4123356 commit c3d4530
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
15 changes: 7 additions & 8 deletions align.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int32_t mp_align_seq(void *km, const mp_mapopt_t *opt, const ns_opt_t *ns
}
}

static void mp_extra_cal(mp_reg1_t *r, const mp_mapopt_t *opt, const uint8_t *nt, int32_t l_nt, const char *aa, int32_t qlen)
static void mp_extra_cal(mp_reg1_t *r, const mp_mapopt_t *opt, const uint8_t *nt, int32_t l_nt, const char *aa, int32_t qlen, int32_t has_spsc)
{
int32_t k, i, j, l, nl = 0, al = 0, ft, n_intron, has_stop;
int32_t blen0, n_iden0, phase0, qs0, n_fs0, n_stop0, score0;
Expand Down Expand Up @@ -186,13 +186,12 @@ static void mp_extra_cal(mp_reg1_t *r, const mp_mapopt_t *opt, const uint8_t *nt
}
// check errors
if (nl != r->ve - r->vs || al != r->qe - r->qs) {
fprintf(stderr, "BUG! %d == %d? %d == %d? ", nl, (int)(r->ve - r->vs), al, r->qe - r->qs);
for (k = 0; k < e->n_cigar; ++k)
fprintf(stderr, "%d%c", e->cigar[k]>>4, NS_CIGAR_STR[e->cigar[k]&0xf]);
fputc('\n', stderr);
if (mp_verbose >= 2)
fprintf(stderr, "Warning: unknown issue with --spsc (%d!=%d or %d!=%d)\n", nl, (int)(r->ve - r->vs), al, r->qe - r->qs);
free(r->p); free(r->feat);
r->p = 0, r->feat = 0;
}
assert(nl == r->ve - r->vs);
assert(al == r->qe - r->qs);
assert(has_spsc == 1 || (nl == r->ve - r->vs && al == r->qe - r->qs));
}

static void mp_extra_gen(void *km, mp_reg1_t *r, mp_cigar_t *cigar, int32_t score)
Expand Down Expand Up @@ -329,7 +328,7 @@ void mp_align(void *km, const mp_mapopt_t *opt, const mp_idx_t *mi, int32_t len,
mp_extra_gen(km, r, &cigar, score);
r->p->dist_stop = mp_extra_stop(r, nt, as, ae);
r->p->dist_start = mp_extra_start(r, nt, as, ae);
mp_extra_cal(r, opt, &nt[r->vs - as], l_nt - (r->vs - as), &aa[r->qs], len);
mp_extra_cal(r, opt, &nt[r->vs - as], l_nt - (r->vs - as), &aa[r->qs], len, mi->nt->spsc != 0);
if (ss) kfree(km, ss);
kfree(km, nt);
}
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ int main(int argc, char *argv[])
if (set_I && !set_G) mp_mapopt_set_max_intron(&mo, mi->nt->l_seq);
if (mp_verbose >= 3) mp_idx_print_stat(mi, mo.max_occ);
if (fn_idx != 0) mp_idx_dump(fn_idx, mi);
if (fn_spsc != 0) mp_ntseq_read_spsc(mi->nt, fn_spsc);
if (fn_spsc != 0) mp_ntseq_read_spsc(mi->nt, fn_spsc, mo.io - mo.go);
for (i = o.ind + 1; i < argc; ++i) {
int32_t res = mp_map_file(mi, argv[i], &mo, n_threads);
if (res != 0) {
Expand Down
4 changes: 2 additions & 2 deletions miniprot.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <stdint.h>

#define MP_VERSION "0.13-r258-dirty"
#define MP_VERSION "0.13-r259-dirty"

#define MP_F_NO_SPLICE 0x1
#define MP_F_NO_ALIGN 0x2
Expand Down Expand Up @@ -162,7 +162,7 @@ void mp_idx_destroy(mp_idx_t *mi);
int mp_idx_dump(const char *fn, const mp_idx_t *mi);
mp_idx_t *mp_idx_restore(const char *fn);
void mp_idx_print_stat(const mp_idx_t *mi, int32_t max_occ);
int32_t mp_ntseq_read_spsc(mp_ntdb_t *nt, const char *fn);
int32_t mp_ntseq_read_spsc(mp_ntdb_t *nt, const char *fn, int32_t max_sc);

int32_t mp_map_file(const mp_idx_t *idx, const char *fn, const mp_mapopt_t *opt, int n_threads);

Expand Down
6 changes: 2 additions & 4 deletions ntseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ int32_t mp_ntseq_name2id(const mp_ntdb_t *nt, const char *name)
return k == kh_end(h)? -1 : kh_val(h, k);
}

#define MP_MAX_SPSC 30

int32_t mp_ntseq_read_spsc(mp_ntdb_t *nt, const char *fn)
int32_t mp_ntseq_read_spsc(mp_ntdb_t *nt, const char *fn, int32_t max_sc)
{
gzFile fp;
kstring_t str = {0,0,0};
Expand Down Expand Up @@ -274,7 +272,7 @@ int32_t mp_ntseq_read_spsc(mp_ntdb_t *nt, const char *fn)
}
if (i < 4) continue; // not enough fields
if (score <= 0) continue;
if (score > MP_MAX_SPSC) score = MP_MAX_SPSC;
if (score > max_sc) score = max_sc;
cid = mp_ntseq_name2id(nt, name);
if (cid < 0 || type < 0 || strand == 0 || pos < 0) continue; // FIXME: give a warning!
s = &nt->spsc[cid << 1 | (strand > 0? 0 : 1)];
Expand Down

0 comments on commit c3d4530

Please sign in to comment.