mirror of
https://github.com/lh3/minimap2.git
synced 2026-10-03 20:28:12 +08:00
read score from BED
This commit is contained in:
@@ -292,7 +292,8 @@ static void mm_update_cigar_eqx(mm_reg1_t *r, const uint8_t *qseq, const uint8_t
|
|||||||
r->p = p;
|
r->p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mm_align_pair(void *km, const mm_mapopt_t *opt, int qlen, const uint8_t *qseq, int tlen, const uint8_t *tseq, const int8_t *ob, const int8_t *mat, int w, int end_bonus, int zdrop, int flag, ksw_extz_t *ez)
|
static void mm_align_pair(void *km, const mm_mapopt_t *opt, int qlen, const uint8_t *qseq, int tlen, const uint8_t *tseq, const int8_t *ob, const int8_t *mat,
|
||||||
|
int w, int end_bonus, int zdrop, int flag, ksw_extz_t *ez)
|
||||||
{
|
{
|
||||||
if (mm_dbg_flag & MM_DBG_PRINT_ALN_SEQ) {
|
if (mm_dbg_flag & MM_DBG_PRINT_ALN_SEQ) {
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ int mm_idx_getseq2(const mm_idx_t *mi, uint32_t rid, uint32_t st, uint32_t en, u
|
|||||||
if (rr != rid || rs >= en) break;
|
if (rr != rid || rs >= en) break;
|
||||||
assert(rs >= st);
|
assert(rs >= st);
|
||||||
for (j = rs; j < re; ++j)
|
for (j = rs; j < re; ++j)
|
||||||
b[j - st] = 1;
|
b[j - st] = mi->R[i].score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return en - st;
|
return en - st;
|
||||||
@@ -625,20 +625,24 @@ mm_idx_bed_t *mm_idx_bed_read_list(const mm_idx_t *mi, const char *fn, uint32_t
|
|||||||
while (ks_getuntil(ks, KS_SEP_LINE, &str, 0) >= 0) {
|
while (ks_getuntil(ks, KS_SEP_LINE, &str, 0) >= 0) {
|
||||||
mm_idx_bed_t t;
|
mm_idx_bed_t t;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int i, id = -1, st = -1, en = -1;
|
int i, id = -1, st = -1, en = -1, sc = -1;
|
||||||
for (p = q = str.s, i = 0;; ++p) {
|
for (p = q = str.s, i = 0;; ++p) {
|
||||||
if (*p == 0 || isspace(*p)) {
|
if (*p == 0 || isspace(*p)) {
|
||||||
int32_t c = *p;
|
int32_t c = *p;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
if (i == 0) {
|
if (i == 0) { // chr
|
||||||
id = mm_idx_name2id(mi, q);
|
id = mm_idx_name2id(mi, q);
|
||||||
if (id < 0) break; // unknown name; TODO: throw a warning
|
if (id < 0) break; // unknown name; TODO: throw a warning
|
||||||
} else if (i == 1) {
|
} else if (i == 1) { // start
|
||||||
st = atoi(q);
|
st = atoi(q);
|
||||||
if (st < 0) break;
|
if (st < 0) break;
|
||||||
} else if (i == 2) {
|
} else if (i == 2) { // end
|
||||||
en = atoi(q);
|
en = atoi(q);
|
||||||
if (en < 0) break;
|
if (en < 0) break;
|
||||||
|
} else if (i == 3) { // name; do nothing
|
||||||
|
} else if (i == 4) { // BED score
|
||||||
|
sc = atoi(q);
|
||||||
|
assert(sc >= 0 && sc <= 127);
|
||||||
} else break;
|
} else break;
|
||||||
if (c == 0) break;
|
if (c == 0) break;
|
||||||
++i, q = p + 1;
|
++i, q = p + 1;
|
||||||
@@ -647,7 +651,7 @@ mm_idx_bed_t *mm_idx_bed_read_list(const mm_idx_t *mi, const char *fn, uint32_t
|
|||||||
if (en < 0) en = st + 1;
|
if (en < 0) en = st + 1;
|
||||||
if (st < 0 || st >= en) continue;
|
if (st < 0 || st >= en) continue;
|
||||||
if (m == n) EXPAND(r, m);
|
if (m == n) EXPAND(r, m);
|
||||||
t.x = (uint64_t)id << 32 | st, t.end = en, t.idx = -1;
|
t.x = (uint64_t)id << 32 | st, t.end = en, t.score = sc >= 0? sc : 0, t.idx = -1;
|
||||||
r[n++] = t;
|
r[n++] = t;
|
||||||
}
|
}
|
||||||
ks_destroy(ks);
|
ks_destroy(ks);
|
||||||
|
|||||||
Reference in New Issue
Block a user