8000 minigraph/format.c at master · wangzhennan14/minigraph · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
224 lines (219 loc) · 7.81 KB

format.c

File metadata and controls

224 lines (219 loc) · 7.81 KB
if (t->soff + t->len == st)
st = t->soff, cont = 1;
}
}
if (cont == 0) {
if (last_pnid >= 0) compact = 0;
if (last_pnid >= 0) mg_sprintf_lite(s, "%c%s:%d-%d", "><"[rev], g->sseq[last_pnid].name, st, en);
last_pnid = t->snid, rev = q->v&1, st = t->soff, en = st + t->len;
}
}
}
if (last_pnid >= 0) {
if (g->sseq[last_pnid].rank != 0 || g->sseq[last_pnid].min != 0)
compact = 0;
if (!compact) mg_sprintf_lite(s, "%c%s:%d-%d", "><"[rev], g->sseq[last_pnid].name, st, en);
} else compact = 0;
}
if (compact) {
int32_t rev = gs->lc[p->off].v&1;
const gfa_seg_t *t = &g->seg[gs->lc[rev? p->off + p->cnt - 1 : p->off].v>>1];
const gfa_sseq_t *ps = &g->sseq[t->snid];
mg_sprintf_lite(s, "%s\t%d\t", ps->name, ps->max);
if (rev) {
s->s[sign_pos] = '-';
mg_sprintf_lite(s, "%d\t%d", t->soff + (p->plen - p->pe), t->soff + (p->plen - p->ps));
} else {
mg_sprintf_lite(s, "%d\t%d", t->soff + p->ps, t->soff + p->pe);
}
} else mg_sprintf_lite(s, "\t%d\t%d\t%d", p->plen, p->ps, p->pe);
mg_sprintf_lite(s, "\t%d\t%d\t%d", p->mlen, p->blen, p->mapq);
mg_sprintf_lite(s, "\ttp:A:%c\tcm:i:%d\ts1:i:%d\ts2:i:%d", p->id == p->parent? 'P' : 'S', p->n_anchor, p->score, p->subsc);
if (p->div >= 0.0f && p->div <= 1.0f) {
char buf[16];
if (p->div == 0.0f) buf[0] = '0', buf[1] = 0;
else snprintf(buf, 16, "%.4f", p->div);
mg_sprintf_lite(s, "\tdv:f:%s", buf);
}
if (n_seg > 1) {
mg_sprintf_lite(s, "\tql:B:i");
for (j = 0; j < n_seg; ++j) mg_sprintf_lite(s, ",%d", qlens[j]);
}
mg_sprintf_lite(s, "\n");
if ((mg_dbg_flag & MG_DBG_LCHAIN) || (flag & MG_M_WRITE_LCHAIN)) {
char buf[16];
for (j = 0; j < p->cnt; ++j) {
const mg_llchain_t *lc = &gs->lc[p->off + j];
mg_sprintf_lite(s, "*\t%c%s\t%d\t%d", "><"[lc->v&1], g->seg[lc->v>>1].name, g->seg[lc->v>>1].len, lc->cnt);
if (lc->cnt > 0) {
double div;
int32_t q_span = (int32_t)(gs->a[lc->off].y>>32&0xff);
int32_t n = (int32_t)(gs->a[lc->off + lc->cnt - 1].x>>32) - (int32_t)(gs->a[lc->off].x>>32) + 1;
div = n == lc->cnt? 0.0 : (n > lc->cnt? log((double)n / lc->cnt) : log((double)lc->cnt / n)) / q_span;
if (div == 0.0) buf[0] = '0', buf[1] = 0;
else snprintf(buf, 16, "%.4f", div);
mg_sprintf_lite(s, "\t%s", buf);
mg_sprintf_lite(s, "\t%d\t%d", (int32_t)gs->a[lc->off].x + 1 - q_span, (int32_t)gs->a[lc->off + lc->cnt - 1].x + 1);
mg_sprintf_lite(s, "\t%d\t%d", (int32_t)gs->a[lc->off].y + 1 - q_span, (int32_t)gs->a[lc->off + lc->cnt - 1].y + 1);
if (flag & MG_M_WRITE_MZ) {
int32_t i, last;
last = (int32_t)gs->a[lc->off].x + 1 - q_span;
mg_sprintf_lite(s, "\t%d\t", q_span);
for (i = 1; i < lc->cnt; ++i) {
int32_t x = (int32_t)gs->a[lc->off + i].x + 1 - q_span;
if (i > 1) mg_sprintf_lite(s, ",");
mg_sprintf_lite(s, "%d", x - last);
last = x;
}
last = (int32_t)gs->a[lc->off].y + 1 - q_span;
mg_sprintf_lite(s, "\t");
for (i = 1; i < lc->cnt; ++i) {
int32_t x = (int32_t)gs->a[lc->off + i].y + 1 - q_span;
if (i > 1) mg_sprintf_lite(s, ",");
mg_sprintf_lite(s, "%d", x - last);
last = x;
}
}
}
mg_sprintf_lite(s, "\n");
}
}
}
}
0