diff --git a/format.c b/format.c index 8707947..115c362 100644 --- a/format.c +++ b/format.c @@ -56,8 +56,7 @@ static void mm_sprintf_lite(kstring_t *s, const char *fmt, ...) static inline void write_tags(kstring_t *s, const mm_reg1_t *r) { - mm_sprintf_lite(s, "\tcm:i:%d", r->cnt); - if (r->p) mm_sprintf_lite(s, "\ts1:i:%d", r->score); + mm_sprintf_lite(s, "\tcm:i:%d\ts1:i:%d", r->cnt, r->score); if (r->parent == r->id) mm_sprintf_lite(s, "\ts2:i:%d", r->subsc); if (r->split) mm_sprintf_lite(s, "\tzd:i:%d", r->split); if (r->p) mm_sprintf_lite(s, "\tNM:i:%d\tms:i:%d\tAS:i:%d\tnn:i:%d", r->p->n_diff, r->p->dp_max, r->p->dp_score, r->p->n_ambi); @@ -71,7 +70,7 @@ void mm_write_paf(kstring_t *s, const mm_idx_t *mi, const bseq1_t *t, const mm_r else mm_sprintf_lite(s, "%d", r->rid); mm_sprintf_lite(s, "\t%d\t%d\t%d", mi->seq[r->rid].len, r->rs, r->re); if (r->p) mm_sprintf_lite(s, "\t%d\t%d", r->p->blen - r->p->n_ambi - r->p->n_diff, r->p->blen); - else mm_sprintf_lite(s, "\t%d\t%d", r->score, r->re - r->rs > r->qe - r->qs? r->re - r->rs : r->qe - r->qs); + else mm_sprintf_lite(s, "\t%d\t%d", r->fuzzy_mlen, r->fuzzy_blen); mm_sprintf_lite(s, "\t%d", r->mapq); write_tags(s, r); if (r->p) { diff --git a/hit.c b/hit.c index c58ebcd..63b6da5 100644 --- a/hit.c +++ b/hit.c @@ -3,8 +3,23 @@ #include "mmpriv.h" #include "kalloc.h" -static inline void mm_reg_set_coor(mm_reg1_t *r, int32_t qlen, const mm128_t *a) +static inline void mm_cal_fuzzy_len(mm_reg1_t *r, const mm128_t *a) { + int i; + r->fuzzy_mlen = r->fuzzy_blen = 0; + if (r->cnt <= 0) return; + r->fuzzy_mlen = r->fuzzy_blen = a[r->as].y>>32&0xff; + for (i = r->as + 1; i < r->as + r->cnt; ++i) { + int span = a[i].y>>32&0xff; + int tl = (int32_t)a[i].x - (int32_t)a[i-1].x; + int ql = (int32_t)a[i].y - (int32_t)a[i-1].y; + r->fuzzy_blen += tl > ql? tl : ql; + r->fuzzy_mlen += tl > span && ql > span? span : tl < ql? tl : ql; + } +} + +static inline void mm_reg_set_coor(mm_reg1_t *r, int32_t qlen, const mm128_t *a) +{ // NB: r->as and r->cnt MUST BE set correctly for this function to work int32_t k = r->as, q_span = (int32_t)(a[k].y>>32&0xff); r->rev = a[k].x>>63; r->rid = a[k].x<<1>>33; @@ -17,6 +32,7 @@ static inline void mm_reg_set_coor(mm_reg1_t *r, int32_t qlen, const mm128_t *a) r->qs = qlen - ((int32_t)a[k + r->cnt - 1].y + 1); r->qe = qlen - ((int32_t)a[k].y + 1 - q_span); } + mm_cal_fuzzy_len(r, a); } mm_reg1_t *mm_gen_regs(void *km, int qlen, int n_u, uint64_t *u, mm128_t *a) // convert chains to hits diff --git a/main.c b/main.c index 55cab15..d9008f2 100644 --- a/main.c +++ b/main.c @@ -10,7 +10,7 @@ #include "minimap.h" #include "mmpriv.h" -#define MM_VERSION "2.0-r168-pre" +#define MM_VERSION "2.0-r169-pre" void liftrlimit() { @@ -47,6 +47,7 @@ static struct option long_options[] = { { "int-rname", no_argument, 0, 0 }, { "no-kalloc", no_argument, 0, 0 }, { "print-qname", no_argument, 0, 0 }, + { "no-self", no_argument, 0, 0 }, { "version", no_argument, 0, 'V' }, { "min-count", required_argument, 0, 'n' }, { "min-chain-score",required_argument, 0, 'm' }, @@ -99,6 +100,7 @@ int main(int argc, char *argv[]) else if (c == 0 && long_idx == 2) keep_name = 0; // --int-rname else if (c == 0 && long_idx == 3) mm_dbg_flag |= MM_DBG_NO_KALLOC; // --no-kalloc else if (c == 0 && long_idx == 4) mm_dbg_flag |= MM_DBG_PRINT_QNAME; // --print-qname + else if (c == 0 && long_idx == 5) opt.flag |= MM_F_NO_SELF; else if (c == 'V') { puts(MM_VERSION); return 0; diff --git a/minimap.h b/minimap.h index 31051a5..a5ad58d 100644 --- a/minimap.h +++ b/minimap.h @@ -61,6 +61,7 @@ typedef struct { int32_t qs, qe, rs, re; int32_t parent, subsc; int32_t as; + int32_t fuzzy_mlen, fuzzy_blen; uint32_t mapq:8, split:2, sam_pri:1, n_sub:21; // TODO: n_sub is not used for now mm_extra_t *p; } mm_reg1_t;