r479: a bit code cleanup
This commit is contained in:
parent
f266092699
commit
e0baf1ad54
6
Makefile
6
Makefile
|
|
@ -68,7 +68,7 @@ chain.o: minimap.h mmpriv.h bseq.h kalloc.h
|
||||||
example.o: minimap.h kseq.h
|
example.o: minimap.h kseq.h
|
||||||
format.o: kalloc.h mmpriv.h minimap.h bseq.h
|
format.o: kalloc.h mmpriv.h minimap.h bseq.h
|
||||||
getopt.o: getopt.h
|
getopt.o: getopt.h
|
||||||
hit.o: mmpriv.h minimap.h bseq.h kalloc.h
|
hit.o: mmpriv.h minimap.h bseq.h kalloc.h khash.h
|
||||||
index.o: kthread.h bseq.h minimap.h mmpriv.h kvec.h kalloc.h khash.h
|
index.o: kthread.h bseq.h minimap.h mmpriv.h kvec.h kalloc.h khash.h
|
||||||
kalloc.o: kalloc.h
|
kalloc.o: kalloc.h
|
||||||
ksw2_extd2_sse.o: ksw2.h kalloc.h
|
ksw2_extd2_sse.o: ksw2.h kalloc.h
|
||||||
|
|
@ -76,8 +76,8 @@ ksw2_exts2_sse.o: ksw2.h kalloc.h
|
||||||
ksw2_extz2_sse.o: ksw2.h kalloc.h
|
ksw2_extz2_sse.o: ksw2.h kalloc.h
|
||||||
ksw2_ll_sse.o: ksw2.h kalloc.h
|
ksw2_ll_sse.o: ksw2.h kalloc.h
|
||||||
main.o: bseq.h minimap.h mmpriv.h getopt.h
|
main.o: bseq.h minimap.h mmpriv.h getopt.h
|
||||||
map.o: kthread.h kvec.h kalloc.h sdust.h mmpriv.h minimap.h bseq.h
|
map.o: kthread.h kvec.h kalloc.h sdust.h mmpriv.h minimap.h bseq.h khash.h
|
||||||
misc.o: minimap.h ksort.h
|
misc.o: minimap.h ksort.h
|
||||||
pe.o: mmpriv.h minimap.h bseq.h
|
pe.o: mmpriv.h minimap.h bseq.h kvec.h kalloc.h ksort.h
|
||||||
sdust.o: kalloc.h kdq.h kvec.h sdust.h
|
sdust.o: kalloc.h kdq.h kvec.h sdust.h
|
||||||
sketch.o: kvec.h kalloc.h minimap.h
|
sketch.o: kvec.h kalloc.h minimap.h
|
||||||
|
|
|
||||||
8
align.c
8
align.c
|
|
@ -487,9 +487,11 @@ mm_reg1_t *mm_align_skeleton(void *km, const mm_mapopt_t *opt, const mm_idx_t *m
|
||||||
regs[i].p->trans_strand = opt->flag&MM_F_SPLICE_FOR? 1 : 2;
|
regs[i].p->trans_strand = opt->flag&MM_F_SPLICE_FOR? 1 : 2;
|
||||||
}
|
}
|
||||||
if (r2.cnt > 0) regs = mm_insert_reg(&r2, i, &n_regs, regs);
|
if (r2.cnt > 0) regs = mm_insert_reg(&r2, i, &n_regs, regs);
|
||||||
if (i > 0 && mm_align1_inv(km, opt, mi, qlen, qseq0, ®s[i-1], ®s[i], &r2, &ez)) {
|
if (!(opt->flag&MM_F_SPLICE) && !(opt->flag&MM_F_SR) && i > 0) { // don't try inversion alignment for -xsplice or -xsr
|
||||||
regs = mm_insert_reg(&r2, i, &n_regs, regs);
|
if (mm_align1_inv(km, opt, mi, qlen, qseq0, ®s[i-1], ®s[i], &r2, &ez)) {
|
||||||
++i; // skip the inserted INV alignment
|
regs = mm_insert_reg(&r2, i, &n_regs, regs);
|
||||||
|
++i; // skip the inserted INV alignment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*n_regs_ = n_regs;
|
*n_regs_ = n_regs;
|
||||||
|
|
|
||||||
2
format.c
2
format.c
|
|
@ -254,7 +254,7 @@ void mm_write_sam2(kstring_t *s, const mm_idx_t *mi, const mm_bseq1_t *t, int se
|
||||||
{
|
{
|
||||||
int flag, n_regs = n_regss[seg_idx];
|
int flag, n_regs = n_regss[seg_idx];
|
||||||
int this_rid = -1, this_pos = -1, this_rev = 0;
|
int this_rid = -1, this_pos = -1, this_rev = 0;
|
||||||
const mm_reg1_t *regs = regss[seg_idx], *r_prev, *r_next;
|
const mm_reg1_t *regs = regss[seg_idx], *r_prev = NULL, *r_next;
|
||||||
const mm_reg1_t *r = n_regs > 0 && reg_idx < n_regs && reg_idx >= 0? ®s[reg_idx] : NULL;
|
const mm_reg1_t *r = n_regs > 0 && reg_idx < n_regs && reg_idx >= 0? ®s[reg_idx] : NULL;
|
||||||
|
|
||||||
// find the primary of the previous and the next segments, if they are mapped
|
// find the primary of the previous and the next segments, if they are mapped
|
||||||
|
|
|
||||||
2
main.c
2
main.c
|
|
@ -6,7 +6,7 @@
|
||||||
#include "mmpriv.h"
|
#include "mmpriv.h"
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
#define MM_VERSION "2.2-r478-dirty"
|
#define MM_VERSION "2.2-r479-dirty"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
|
||||||
17
map.c
17
map.c
|
|
@ -260,7 +260,7 @@ static mm_reg1_t *align_regs(const mm_mapopt_t *opt, const mm_idx_t *mi, void *k
|
||||||
|
|
||||||
void mm_map_frag(const mm_idx_t *mi, int n_segs, const int *qlens, const char **seqs, int *n_regs, mm_reg1_t **regs, mm_tbuf_t *b, const mm_mapopt_t *opt, const char *qname)
|
void mm_map_frag(const mm_idx_t *mi, int n_segs, const int *qlens, const char **seqs, int *n_regs, mm_reg1_t **regs, mm_tbuf_t *b, const mm_mapopt_t *opt, const char *qname)
|
||||||
{
|
{
|
||||||
int i, j, max_gap_ref, rep_len, qlen_sum, n_regs0, rechain = 0;
|
int i, j, max_gap_ref, rep_len, qlen_sum, n_regs0;
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
int64_t n_a;
|
int64_t n_a;
|
||||||
uint64_t *u;
|
uint64_t *u;
|
||||||
|
|
@ -291,7 +291,8 @@ void mm_map_frag(const mm_idx_t *mi, int n_segs, const int *qlens, const char **
|
||||||
a = mm_chain_dp(max_gap_ref, opt->max_gap, opt->bw, opt->max_chain_skip, opt->min_cnt, opt->min_chain_score, !!(opt->flag&MM_F_SPLICE), n_segs, n_a, a, &n_regs0, &u, b->km);
|
a = mm_chain_dp(max_gap_ref, opt->max_gap, opt->bw, opt->max_chain_skip, opt->min_cnt, opt->min_chain_score, !!(opt->flag&MM_F_SPLICE), n_segs, n_a, a, &n_regs0, &u, b->km);
|
||||||
|
|
||||||
if ((opt->flag & MM_F_SR) && rep_len > 0) {
|
if ((opt->flag & MM_F_SR) && rep_len > 0) {
|
||||||
if (n_regs0 > 0) {
|
int rechain = 0;
|
||||||
|
if (n_regs0 > 0) { // test if the best chain has all the segments
|
||||||
int n_chained_segs = 1, max = 0, max_i = -1, max_off = -1, off = 0;
|
int n_chained_segs = 1, max = 0, max_i = -1, max_off = -1, off = 0;
|
||||||
for (i = 0; i < n_regs0; ++i) { // find the best chain
|
for (i = 0; i < n_regs0; ++i) { // find the best chain
|
||||||
if (max < u[i]>>32) max = u[i]>>32, max_i = i, max_off = off;
|
if (max < u[i]>>32) max = u[i]>>32, max_i = i, max_off = off;
|
||||||
|
|
@ -322,22 +323,22 @@ void mm_map_frag(const mm_idx_t *mi, int n_segs, const int *qlens, const char **
|
||||||
|
|
||||||
chain_post(opt, mi, b->km, qlen_sum, n_segs, qlens, &n_regs0, regs0, a);
|
chain_post(opt, mi, b->km, qlen_sum, n_segs, qlens, &n_regs0, regs0, a);
|
||||||
|
|
||||||
if (n_segs == 1) {
|
if (n_segs == 1) { // uni-segment
|
||||||
regs0 = align_regs(opt, mi, b->km, qlens[0], seqs[0], &n_regs0, regs0, a);
|
regs0 = align_regs(opt, mi, b->km, qlens[0], seqs[0], &n_regs0, regs0, a);
|
||||||
mm_set_mapq(n_regs0, regs0, opt->min_chain_score, opt->a, rep_len);
|
mm_set_mapq(n_regs0, regs0, opt->min_chain_score, opt->a, rep_len);
|
||||||
n_regs[0] = n_regs0, regs[0] = regs0;
|
n_regs[0] = n_regs0, regs[0] = regs0;
|
||||||
} else {
|
} else { // multi-segment
|
||||||
mm_seg_t *seg;
|
mm_seg_t *seg;
|
||||||
seg = mm_seg_gen(b->km, hash, n_segs, qlens, n_regs0, regs0, n_regs, regs, a);
|
seg = mm_seg_gen(b->km, hash, n_segs, qlens, n_regs0, regs0, n_regs, regs, a); // split fragment chain to separate segment chains
|
||||||
free(regs0);
|
free(regs0);
|
||||||
for (i = 0; i < n_segs; ++i) {
|
for (i = 0; i < n_segs; ++i) {
|
||||||
mm_set_parent(b->km, opt->mask_level, n_regs[i], regs[i], opt->a * 2 + opt->b);
|
mm_set_parent(b->km, opt->mask_level, n_regs[i], regs[i], opt->a * 2 + opt->b); // update mm_reg1_t::parent
|
||||||
regs[i] = align_regs(opt, mi, b->km, qlens[i], seqs[i], &n_regs[i], regs[i], seg[i].a);
|
regs[i] = align_regs(opt, mi, b->km, qlens[i], seqs[i], &n_regs[i], regs[i], seg[i].a);
|
||||||
mm_set_mapq(n_regs[i], regs[i], opt->min_chain_score, opt->a, rep_len);
|
mm_set_mapq(n_regs[i], regs[i], opt->min_chain_score, opt->a, rep_len);
|
||||||
}
|
}
|
||||||
mm_seg_free(b->km, n_segs, seg);
|
mm_seg_free(b->km, n_segs, seg);
|
||||||
if (n_segs == 2 && opt->pe_ori >= 0 && (opt->flag&MM_F_CIGAR))
|
if (n_segs == 2 && opt->pe_ori >= 0 && (opt->flag&MM_F_CIGAR))
|
||||||
mm_pair(b->km, max_gap_ref, opt->pe_bonus, opt->a * 2 + opt->b, opt->a, qlens, n_regs, regs);
|
mm_pair(b->km, max_gap_ref, opt->pe_bonus, opt->a * 2 + opt->b, opt->a, qlens, n_regs, regs); // pairing
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(b->km, a);
|
kfree(b->km, a);
|
||||||
|
|
@ -424,7 +425,7 @@ static void *worker_pipeline(void *shared, int step, void *in)
|
||||||
for (i = 0; i < p->n_threads; ++i)
|
for (i = 0; i < p->n_threads; ++i)
|
||||||
s->buf[i] = mm_tbuf_init();
|
s->buf[i] = mm_tbuf_init();
|
||||||
s->n_reg = (int*)calloc(3 * s->n_seq, sizeof(int));
|
s->n_reg = (int*)calloc(3 * s->n_seq, sizeof(int));
|
||||||
s->seg_off = s->n_reg + s->n_seq;
|
s->seg_off = s->n_reg + s->n_seq; // seg_off and n_seg are allocated together with n_reg
|
||||||
s->n_seg = s->seg_off + s->n_seq;
|
s->n_seg = s->seg_off + s->n_seq;
|
||||||
s->reg = (mm_reg1_t**)calloc(s->n_seq, sizeof(mm_reg1_t*));
|
s->reg = (mm_reg1_t**)calloc(s->n_seq, sizeof(mm_reg1_t*));
|
||||||
for (i = 1, j = 0; i <= s->n_seq; ++i)
|
for (i = 1, j = 0; i <= s->n_seq; ++i)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue