mirror of
https://github.com/chhylp123/hifiasm.git
synced 2026-10-02 00:48:12 +08:00
fix memory bug/logic bug
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define HA_VERSION "0.16.2-r385"
|
||||
#define HA_VERSION "0.16.4-r390"
|
||||
|
||||
#define VERBOSE 0
|
||||
|
||||
|
||||
+172
-12
@@ -929,6 +929,70 @@ void normalize_ma_hit_t_single_side_advance(ma_hit_t_alloc* sources, long long n
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
kvec_t_u64_warp *buf;
|
||||
ma_hit_t_alloc* src;
|
||||
int64_t n_thread;
|
||||
} ma_hit_t_aux;
|
||||
|
||||
static void update_ma_hit_t_norm(void *data, long i, int tid) // callback for kt_for()
|
||||
{
|
||||
ma_hit_t_aux *sl = (ma_hit_t_aux *)data;
|
||||
ma_hit_t_alloc* src = sl->src;
|
||||
uint64_t z, qn, tn, is_del = 0;
|
||||
int64_t idx, qLen_0, qLen_1;
|
||||
|
||||
for (z = 0; z < src[i].length; z++) {
|
||||
qn = Get_qn(src[i].buffer[z]);
|
||||
tn = Get_tn(src[i].buffer[z]);
|
||||
is_del = 0; idx = get_specific_overlap(&(src[tn]), tn, qn);
|
||||
|
||||
if(idx != -1 && qn <= tn) { ///qn must be not equal to tn
|
||||
if(src[i].buffer[z].del || src[tn].buffer[idx].del) is_del = 1;
|
||||
qLen_0 = Get_qe(src[i].buffer[z]) - Get_qs(src[i].buffer[z]);
|
||||
qLen_1 = Get_qe(src[tn].buffer[idx]) - Get_qs(src[tn].buffer[idx]);
|
||||
|
||||
if(qLen_0 == qLen_1) {
|
||||
///qn must be not equal to tn
|
||||
///make sources[qn] = sources[tn] if qn > tn
|
||||
set_reverse_overlap(&(src[tn].buffer[idx]), &(src[i].buffer[z]));
|
||||
}
|
||||
else if(qLen_0 > qLen_1) {
|
||||
set_reverse_overlap(&(src[tn].buffer[idx]), &(src[i].buffer[z]));
|
||||
} else {
|
||||
set_reverse_overlap(&(src[i].buffer[z]), &(src[tn].buffer[idx]));
|
||||
}
|
||||
|
||||
src[i].buffer[z].del = is_del; src[tn].buffer[idx].del = is_del;
|
||||
}
|
||||
else ///means this edge just occurs in one direction
|
||||
{
|
||||
tn = i; tn <<= 32; tn |= z;
|
||||
kv_push(uint64_t, sl->buf[tid].a, tn);
|
||||
src[i].buffer[z].del = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void normalize_ma_hit_t_single_side_advance_mult(ma_hit_t_alloc* src, int64_t n_src, int64_t n_thread)
|
||||
{
|
||||
ma_hit_t_aux aux; int64_t k; uint64_t z; ma_hit_t e;
|
||||
aux.n_thread = n_thread; aux.src = src; CALLOC(aux.buf, aux.n_thread);
|
||||
|
||||
kt_for(aux.n_thread, update_ma_hit_t_norm, &aux, n_src);
|
||||
|
||||
for (k = 0; k < aux.n_thread; k++) {
|
||||
for (z = 0; z < aux.buf[k].a.n; z++) {
|
||||
set_reverse_overlap(&e, &(src[aux.buf[k].a.a[z]>>32].buffer[(uint32_t)(aux.buf[k].a.a[z])]));
|
||||
src[aux.buf[k].a.a[z]>>32].buffer[(uint32_t)(aux.buf[k].a.a[z])].del = e.del = 1;
|
||||
add_ma_hit_t_alloc(&(src[Get_qn(e)]), &e);
|
||||
}
|
||||
free(aux.buf[k].a.a);
|
||||
}
|
||||
free(aux.buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void get_end_match_length(ma_hit_t* edge, UC_Read* query, UC_Read* target,
|
||||
uint32_t* left, uint32_t* right)
|
||||
@@ -2520,7 +2584,7 @@ static inline int asg_is_single_edge(const asg_t *g, uint32_t v, uint32_t start_
|
||||
return nv;
|
||||
}
|
||||
|
||||
void debug_info_of_specfic_node(char* name, asg_t *g, R_to_U* ruIndex, char* command)
|
||||
void debug_info_of_specfic_node(const char* name, asg_t *g, R_to_U* ruIndex, const char* command)
|
||||
{
|
||||
fprintf(stderr, "\n\n\n");
|
||||
uint32_t v, n_vtx = g->n_seq * 2, queryLen = strlen(name), flag = 0, contain_rId, is_Unitig;
|
||||
@@ -8180,6 +8244,48 @@ int asg_arc_del_false_node(asg_t *g, ma_hit_t_alloc* sources, int max_ext)
|
||||
return n_cut;
|
||||
}
|
||||
|
||||
void update_ug_ou(ma_ug_t *ug, asg_t *sg)
|
||||
{
|
||||
uint32_t k, i, uv, uw, rv, rw, nv; asg_arc_t *ue, *av;
|
||||
for (k = 0; k < ug->g->n_arc; k++) {
|
||||
ue = &(ug->g->arc[k]); ue->ou = 0;
|
||||
uv = ue->ul>>32; uw = ue->v;
|
||||
if(uv&1) rv = ug->u.a[uv>>1].start^1;
|
||||
else rv = ug->u.a[uv>>1].end^1;
|
||||
|
||||
if(uw&1) rw = ug->u.a[uw>>1].end;
|
||||
else rw = ug->u.a[uw>>1].start;
|
||||
|
||||
av = asg_arc_a(sg, rv);
|
||||
nv = asg_arc_n(sg, rv);
|
||||
for (i = 0; i < nv; i++) {
|
||||
if(av[i].v == rw) break;
|
||||
}
|
||||
ue->ou = av[i].ou;
|
||||
}
|
||||
|
||||
// asg_arc_t *e; uint32_t v, w;
|
||||
// for (k = 0; k < sg->n_arc; k++) {
|
||||
// e = &(sg->arc[k]);
|
||||
// v = e->v^1; w = (e->ul>>32)^1;
|
||||
// av = asg_arc_a(sg, v); nv = asg_arc_n(sg, v);
|
||||
// for (i = 0; i < nv; i++) {
|
||||
// if(av[i].v == w) break;
|
||||
// }
|
||||
// if(i >= nv || av[i].ou != e->ou) fprintf(stderr, "[M::%s::asymmetry]\n", __func__);
|
||||
// }
|
||||
|
||||
// for (k = 0; k < ug->g->n_arc; k++) {
|
||||
// e = &(ug->g->arc[k]);
|
||||
// v = e->v^1; w = (e->ul>>32)^1;
|
||||
// av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
|
||||
// for (i = 0; i < nv; i++) {
|
||||
// if(av[i].v == w) break;
|
||||
// }
|
||||
// if(i >= nv || av[i].ou != e->ou) fprintf(stderr, "[M::%s::asymmetry]\n", __func__);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
#define arc_cnt(g, v) ((uint32_t)(g)->idx[(v)])
|
||||
#define arc_first(g, v) ((g)->arc[(g)->idx[(v)]>>32])
|
||||
@@ -8302,7 +8408,7 @@ add_unitig:
|
||||
q = asg_arc_pushp(ug->g);
|
||||
q->ol = p->ol, q->del = 0;
|
||||
q->ul = (uint64_t)u<<32 | l;
|
||||
q->v = mark[p->v];
|
||||
q->v = mark[p->v]; q->ou = 0;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < ug->u.n; ++i)
|
||||
@@ -9340,6 +9446,52 @@ UC_Read* r_read, UC_Read* q_read, int max_hang, int min_ovlp, kvec_asg_arc_t_war
|
||||
}
|
||||
|
||||
|
||||
ma_ug_t *gen_polished_ug(const ug_opt_t *uopt, asg_t *sg)
|
||||
{
|
||||
kvec_asg_arc_t_warp e, d;
|
||||
uint32_t i, k; ma_utg_t *u;
|
||||
kv_init(e.a); kv_init(d.a);
|
||||
ma_ug_t *ug = ma_ug_gen(sg);
|
||||
UC_Read g_read, tmp;
|
||||
init_UC_Read(&g_read); init_UC_Read(&tmp);
|
||||
|
||||
for (i = e.a.n = d.a.n = 0; i < ug->u.n; ++i) {
|
||||
u = &ug->u.a[i];
|
||||
if(u->m == 0) continue;
|
||||
polish_unitig(u, sg, uopt->sources, uopt->coverage_cut, &e, uopt->max_hang, uopt->min_ovlp, &d);
|
||||
polish_unitig_advance(u, sg, &R_INF, uopt->sources, uopt->coverage_cut, &e, &g_read, &tmp, uopt->max_hang, uopt->min_ovlp, &d);
|
||||
ug->g->seq[i].len = u->len;
|
||||
}
|
||||
|
||||
destory_UC_Read(&g_read); destory_UC_Read(&tmp);
|
||||
|
||||
uint32_t n_vtx = ug->g->n_seq*2, v, nv, vLen = 0;
|
||||
asg_arc_t* av = NULL, *p = NULL;
|
||||
for (v = 0; v < n_vtx; ++v) {
|
||||
if (ug->g->seq[v>>1].del) continue;
|
||||
av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
|
||||
for (i = 0; i < nv; i++) {
|
||||
if(av[i].del) continue;
|
||||
vLen = ug->g->seq[(av[i].ul>>33)].len - av[i].ol;
|
||||
av[i].ul = (av[i].ul>>32)<<32;
|
||||
av[i].ul = av[i].ul | vLen;
|
||||
}
|
||||
}
|
||||
|
||||
if(d.a.n > 0) {
|
||||
for (k = 0; k < d.a.n; k++) {
|
||||
p = asg_arc_pushp(sg);
|
||||
*p = d.a.a[k];
|
||||
}
|
||||
free(sg->idx); sg->idx = 0; sg->is_srt = 0;
|
||||
asg_cleanup(sg);
|
||||
}
|
||||
|
||||
kv_destroy(e.a); kv_destroy(d.a);
|
||||
return ug;
|
||||
}
|
||||
|
||||
|
||||
// generate unitig sequences
|
||||
int ma_ug_seq(ma_ug_t *g, asg_t *read_g, ma_sub_t *coverage_cut, ma_hit_t_alloc* sources,
|
||||
kvec_asg_arc_t_warp* edge, int max_hang, int min_ovlp, kvec_asg_arc_t_warp *E, uint32_t is_polish)
|
||||
@@ -9834,9 +9986,9 @@ ma_hit_t_alloc* sources, R_to_U* ruIndex, int print_seq, const char* prefix, FIL
|
||||
{
|
||||
if(au[j].del) continue;
|
||||
v = au[j].v;
|
||||
fprintf(fp, "L\t%s%.6d%c\t%c\t%s%.6d%c\t%c\t%dM\tL1:i:%d\n",
|
||||
fprintf(fp, "L\t%s%.6d%c\t%c\t%s%.6d%c\t%c\t%dM\tL1:i:%d\tL2:i:%u\n",
|
||||
prefix, (u>>1)+1, "lc"[ug->u.a[u>>1].circ], "+-"[u&1],
|
||||
prefix, (v>>1)+1, "lc"[ug->u.a[v>>1].circ], "+-"[v&1], au[j].ol, asg_arc_len(au[j]));
|
||||
prefix, (v>>1)+1, "lc"[ug->u.a[v>>1].circ], "+-"[v&1], au[j].ol, asg_arc_len(au[j]), au[j].ou);
|
||||
}
|
||||
|
||||
|
||||
@@ -9847,9 +9999,9 @@ ma_hit_t_alloc* sources, R_to_U* ruIndex, int print_seq, const char* prefix, FIL
|
||||
{
|
||||
if(au[j].del) continue;
|
||||
v = au[j].v;
|
||||
fprintf(fp, "L\t%s%.6d%c\t%c\t%s%.6d%c\t%c\t%dM\tL1:i:%d\n",
|
||||
fprintf(fp, "L\t%s%.6d%c\t%c\t%s%.6d%c\t%c\t%dM\tL1:i:%d\tL2:i:%u\n",
|
||||
prefix, (u>>1)+1, "lc"[ug->u.a[u>>1].circ], "+-"[u&1],
|
||||
prefix, (v>>1)+1, "lc"[ug->u.a[v>>1].circ], "+-"[v&1], au[j].ol, asg_arc_len(au[j]));
|
||||
prefix, (v>>1)+1, "lc"[ug->u.a[v>>1].circ], "+-"[v&1], au[j].ol, asg_arc_len(au[j]), au[j].ou);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9919,6 +10071,7 @@ void clean_weak_ma_hit_t(ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_source
|
||||
{
|
||||
sources[i].buffer[j].bl |= ((uint32_t)0x40000000);
|
||||
index = get_specific_overlap(&(sources[tn]), tn, qn);
|
||||
// if(index < 0 || index >= sources[tn].length) fprintf(stderr, "sb, tn: %u, qn: %u, index: %ld, length: %u\n", tn, qn, index, sources[tn].length);
|
||||
sources[tn].buffer[index].bl |= ((uint32_t)0x40000000);
|
||||
}
|
||||
}
|
||||
@@ -14678,7 +14831,8 @@ ma_hit_t_alloc* sources, R_to_U* ruIndex, int max_hang, int min_ovlp)
|
||||
}
|
||||
}
|
||||
|
||||
ma_ug_seq(ug, read_g, coverage_cut, sources, &new_rtg_edges, max_hang, min_ovlp, 0, 1);
|
||||
update_ug_ou(ug, read_g);
|
||||
ma_ug_seq(ug, read_g, coverage_cut, sources, &new_rtg_edges, max_hang, min_ovlp, 0, 0);
|
||||
|
||||
fprintf(stderr, "Writing raw unitig GFA to disk... \n");
|
||||
char* gfa_name = (char*)malloc(strlen(output_file_name)+25);
|
||||
@@ -31177,9 +31331,6 @@ ma_sub_t **coverage_cut_ptr, int debug_g)
|
||||
asg_t *sg = *sg_ptr;
|
||||
bub_label_t b_mask_t;
|
||||
ug_opt_t uopt;
|
||||
if(asm_opt.ar) {
|
||||
gen_ug_opt_t(&uopt, sources, reverse_sources, max_hang_length, mini_overlap_length, gap_fuzz, min_dp, readLen, coverage_cut, ruIndex);
|
||||
}
|
||||
|
||||
if(debug_g)
|
||||
{
|
||||
@@ -31188,10 +31339,15 @@ ma_sub_t **coverage_cut_ptr, int debug_g)
|
||||
}
|
||||
///just for debug
|
||||
renew_graph_init(sources, reverse_sources, sg, coverage_cut, ruIndex, n_read);
|
||||
|
||||
///it's hard to say which function is better
|
||||
///normalize_ma_hit_t_single_side(sources, n_read);
|
||||
|
||||
normalize_ma_hit_t_single_side_advance(sources, n_read);
|
||||
// normalize_ma_hit_t_single_side_advance_mult(sources, n_read, asm_opt.thread_num);
|
||||
normalize_ma_hit_t_single_side_advance(reverse_sources, n_read);
|
||||
// normalize_ma_hit_t_single_side_advance_mult(reverse_sources, n_read, asm_opt.thread_num);
|
||||
|
||||
if (ha_opt_triobin(&asm_opt))
|
||||
{
|
||||
drop_edges_by_trio(sources, n_read);
|
||||
@@ -31233,8 +31389,10 @@ ma_sub_t **coverage_cut_ptr, int debug_g)
|
||||
output_read_graph(sg, coverage_cut, unlean_name, n_read);
|
||||
free(unlean_name);
|
||||
}
|
||||
|
||||
gen_ug_opt_t(&uopt, sources, reverse_sources, max_hang_length, mini_overlap_length, gap_fuzz, min_dp, readLen, coverage_cut, ruIndex);
|
||||
ul_clean_gfa(&uopt, sg, sources, reverse_sources, ruIndex, clean_round, min_ovlp_drop_ratio, max_ovlp_drop_ratio,
|
||||
0.6, asm_opt.max_short_tip, &b_mask_t, !!asm_opt.ar, ha_opt_triobin(&asm_opt), UL_COV_THRES);
|
||||
0.6, asm_opt.max_short_tip, &b_mask_t, !!asm_opt.ar, ha_opt_triobin(&asm_opt), UL_COV_THRES, o_file);
|
||||
print_debug_gfa(sg, NULL, coverage_cut, "UL.debug", sources, ruIndex, max_hang_length, mini_overlap_length);
|
||||
/**
|
||||
asg_cut_tip(sg, asm_opt.max_short_tip);
|
||||
@@ -31340,7 +31498,7 @@ ma_sub_t **coverage_cut_ptr, int debug_g)
|
||||
asg_cut_tip(sg, asm_opt.max_short_tip);
|
||||
|
||||
asg_arc_del_simple_circle_untig(sources, coverage_cut, sg, 100, 0);
|
||||
**/
|
||||
|
||||
///note: don't apply asg_arc_del_too_short_overlaps() after this function!!!!
|
||||
rescue_contained_reads_aggressive(NULL, sg, sources, coverage_cut, ruIndex, max_hang_length,
|
||||
mini_overlap_length, 10, 1, 0, NULL, NULL, &b_mask_t);
|
||||
@@ -31359,10 +31517,12 @@ ma_sub_t **coverage_cut_ptr, int debug_g)
|
||||
|
||||
rescue_bubble_by_chain(sg, coverage_cut, sources, reverse_sources, (asm_opt.max_short_tip*2), 0.15, 3,
|
||||
ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, 10, gap_fuzz, &b_mask_t);
|
||||
|
||||
|
||||
output_unitig_graph(sg, coverage_cut, o_file, sources, ruIndex, max_hang_length, mini_overlap_length);
|
||||
// flat_bubbles(sg, ruIndex->is_het); free(ruIndex->is_het); ruIndex->is_het = NULL;
|
||||
flat_soma_v(sg, sources, ruIndex);
|
||||
**/
|
||||
|
||||
output_contig_graph_primary_pre(sg, coverage_cut, o_file, sources, reverse_sources,
|
||||
asm_opt.small_pop_bubble_size, asm_opt.max_short_tip, ruIndex, max_hang_length, mini_overlap_length);
|
||||
|
||||
+14
-1
@@ -5,6 +5,7 @@
|
||||
#include "kvec.h"
|
||||
#include "kdq.h"
|
||||
#include "ksort.h"
|
||||
#include "CommandLines.h"
|
||||
|
||||
///#define MIN_OVERLAP_LEN 2000
|
||||
///#define MIN_OVERLAP_LEN 500
|
||||
@@ -538,7 +539,7 @@ long long max_hang_length, long long clean_round, long long gap_fuzz,
|
||||
float min_ovlp_drop_ratio, float max_ovlp_drop_ratio, char* output_file_name,
|
||||
long long bubble_dist, int read_graph, int write);
|
||||
|
||||
void debug_info_of_specfic_read(char* name, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, int id, char* command);
|
||||
void debug_info_of_specfic_read(const char* name, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, int id, const char* command);
|
||||
void collect_abnormal_edges(ma_hit_t_alloc* paf, ma_hit_t_alloc* rev_paf, long long readNum);
|
||||
void add_overlaps(ma_hit_t_alloc* source_paf, ma_hit_t_alloc* dest_paf, uint64_t* source_index, long long listLen);
|
||||
void remove_overlaps(ma_hit_t_alloc* source_paf, uint64_t* source_index, long long listLen);
|
||||
@@ -823,6 +824,12 @@ uint32_t get_edge_from_source(ma_hit_t_alloc* sources, ma_sub_t *coverage_cut,
|
||||
R_to_U* ruIndex, int max_hang, int min_ovlp, uint32_t query, uint32_t target, asg_arc_t* t);
|
||||
int unitig_arc_del_short_diploid_by_length(asg_t *g, float drop_ratio);
|
||||
void asg_bub_backtrack_primary(asg_t *g, uint32_t v0, buf_t *b);
|
||||
void set_hom_global_coverage(hifiasm_opt_t *opt, asg_t *sg, ma_sub_t* coverage_cut,
|
||||
ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex, int max_hang, int min_ovlp);
|
||||
void rescue_bubble_by_chain(asg_t *sg, ma_sub_t *coverage_cut, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources,
|
||||
long long tipsLen, float tip_drop_ratio, long long stops_threshold, R_to_U* ruIndex,
|
||||
float chimeric_rate, float drop_ratio, int max_hang, int min_ovlp, uint32_t chainLenThres, long long gap_fuzz,
|
||||
bub_label_t* b_mask_t);
|
||||
|
||||
typedef struct{
|
||||
double weight;
|
||||
@@ -1073,6 +1080,12 @@ ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex);
|
||||
int asg_arc_del_short_diploid_by_exact(asg_t *g, int max_ext, ma_hit_t_alloc* sources);
|
||||
uint32_t print_debug_gfa(asg_t *read_g, ma_ug_t *ug, ma_sub_t* coverage_cut, const char* output_file_name,
|
||||
ma_hit_t_alloc* sources, R_to_U* ruIndex, int max_hang, int min_ovlp);
|
||||
void debug_info_of_specfic_node(const char* name, asg_t *g, R_to_U* ruIndex, const char* command);
|
||||
ma_ug_t *gen_polished_ug(const ug_opt_t *uopt, asg_t *sg);
|
||||
void output_unitig_graph(asg_t *sg, ma_sub_t* coverage_cut, char* output_file_name,
|
||||
ma_hit_t_alloc* sources, R_to_U* ruIndex, int max_hang, int min_ovlp);
|
||||
void flat_soma_v(asg_t *sg, ma_hit_t_alloc* sources, R_to_U* ruIndex);
|
||||
void hic_clean(asg_t* read_g);
|
||||
|
||||
#define JUNK_COV 5
|
||||
#define DISCARD_RATE 0.8
|
||||
|
||||
+13
-10
@@ -1078,7 +1078,7 @@ void determine_chain_distance(ul_ov_t *o, int64_t on, ul_vec_t *p, ma_hit_t_allo
|
||||
{
|
||||
int64_t k, i, m, l = 0, r, last_i, last_dis; ul_ov_t *z = NULL;
|
||||
uint32_t li_v, lj_v, t, qn, tn; ma_hit_t_alloc *x = NULL; asg_arc_t te;
|
||||
|
||||
|
||||
for (k = on-1; k >= 0; --k) {
|
||||
z = &(o[k]);
|
||||
if((!z->el) || (z->sec == SEC_MODE)) continue;
|
||||
@@ -1118,12 +1118,13 @@ void determine_chain_distance(ul_ov_t *o, int64_t on, ul_vec_t *p, ma_hit_t_allo
|
||||
if(!(o[i].el)) continue;
|
||||
assert(last_i>=0);
|
||||
p->bb.a[last_i].pidx = o[i].qn;
|
||||
p->bb.a[last_i].pdis = l - last_dis;
|
||||
p->bb.a[last_i].pdis = l - last_dis;///TODO: enable pdis
|
||||
p->bb.a[p->bb.a[last_i].pidx].aidx = last_i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str, int64_t str_l, ul_ov_t *o, int64_t on, float p_chain_rate, const ug_opt_t *uopt) {
|
||||
void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str, int64_t str_l, ul_ov_t *o, int64_t on, float p_chain_rate, const ug_opt_t *uopt, uint32_t save_bases) {
|
||||
int64_t i, mine, maxs, ovlp, st, et, bl = 0, pc = 0, en = 0;
|
||||
uint32_t o_l, o_r;
|
||||
ul_vec_t *p = NULL;
|
||||
@@ -1162,13 +1163,13 @@ void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str,
|
||||
mine = MIN(et, ((int64_t)z->qe)); maxs = MAX(st, ((int64_t)z->qs));
|
||||
ovlp = mine - maxs;
|
||||
|
||||
if(ovlp < 0) {///push original bases
|
||||
if(save_bases && ovlp < 0) {///push original bases
|
||||
kv_pushp(uc_block_t, p->bb, &b);
|
||||
b->hid = 0/**x->mm**/; b->rev = 0; b->base = 1; b->pchain = 0; b->el = 0;
|
||||
b->qe = maxs; b->qs = b->qe + ovlp; bl += (b->qe-b->qs);
|
||||
o_l = (b->qs >= UL_FLANK?UL_FLANK:b->qs);
|
||||
o_r = ((str_l-b->qe)>=UL_FLANK?UL_FLANK:(str_l-b->qe));
|
||||
b->pidx = b->pdis = (uint32_t)-1;
|
||||
b->pidx = b->pdis = b->aidx = (uint32_t)-1;
|
||||
b->hid |= (o_l<<15); b->hid |= o_r;
|
||||
b->qs -= o_l; b->qe += o_r;
|
||||
b->ts = p->r_base.n; b->te = b->ts + B4L(b->qe-b->qs);
|
||||
@@ -1187,18 +1188,18 @@ void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str,
|
||||
b->qs = z->qs; b->qe = z->qe;
|
||||
b->ts = z->ts; b->te = z->te;
|
||||
if(b->pchain) pc++;
|
||||
b->pdis = (uint32_t)-1; b->pidx = i;
|
||||
b->pidx = i; b->pdis = b->aidx = (uint32_t)-1;
|
||||
en++; z->qn = p->bb.n - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(st > 0) {///push original bases
|
||||
if(save_bases && st > 0) {///push original bases
|
||||
kv_pushp(uc_block_t, p->bb, &b);
|
||||
b->hid = 0/**x->mm**/; b->rev = 0; b->base = 1; b->pchain = 0; b->el = 0;
|
||||
b->qe = st; b->qs = 0; bl += (b->qe-b->qs);
|
||||
o_l = (b->qs >= UL_FLANK?UL_FLANK:b->qs);
|
||||
o_r = ((str_l-b->qe)>=UL_FLANK?UL_FLANK:(str_l-b->qe));
|
||||
b->pidx = b->pdis = (uint32_t)-1;
|
||||
b->pidx = b->pdis = b->aidx = (uint32_t)-1;
|
||||
b->hid |= (o_l<<15); b->hid |= o_r;
|
||||
b->qs -= o_l; b->qe += o_r;
|
||||
b->ts = p->r_base.n; b->te = b->ts + B4L(b->qe-b->qs);
|
||||
@@ -1235,13 +1236,15 @@ void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str,
|
||||
p->bb.a[p->bb.n-i-1].pidx = (uint32_t)-1;
|
||||
}
|
||||
}
|
||||
if(((uint32_t)p->bb.n)&1) {
|
||||
o[p->bb.a[i].pidx].qn = p->bb.n-o[p->bb.a[i].pidx].qn-1;
|
||||
p->bb.a[i].pidx = (uint32_t)-1;
|
||||
}
|
||||
|
||||
determine_chain_distance(o, on, p, uopt->sources, uopt->max_hang, uopt->min_ovlp, *rid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void retrieve_ul_t(UC_Read* i_r, char *i_s, all_ul_t *ref, uint64_t ID, uint8_t strand, int64_t s, int64_t l) {
|
||||
ul_vec_t *p = &(ref->a[ID]);
|
||||
if(l < 0) l = p->rlen;
|
||||
|
||||
+2
-2
@@ -160,7 +160,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
uint32_t hid;
|
||||
uint32_t qs, qe, ts, te; uint32_t pidx, pdis;
|
||||
uint32_t qs, qe, ts, te; uint32_t pidx, pdis, aidx;///TODO: enable pdis
|
||||
uint8_t pchain:5, rev:1, base:1, el:1;
|
||||
} uc_block_t;
|
||||
|
||||
@@ -224,7 +224,7 @@ void recover_UC_sub_Read(UC_Read* i_r, long long start_pos, long long length, ui
|
||||
|
||||
void init_all_ul_t(all_ul_t *x, All_reads *hR);
|
||||
void destory_all_ul_t(all_ul_t *x);
|
||||
void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str, int64_t str_l, ul_ov_t *o, int64_t on, float p_chain_rate, const ug_opt_t *uopt);
|
||||
void append_ul_t(all_ul_t *x, uint64_t *rid, char* id, int64_t id_l, char* str, int64_t str_l, ul_ov_t *o, int64_t on, float p_chain_rate, const ug_opt_t *uopt, uint32_t save_bases);
|
||||
void retrieve_ul_t(UC_Read* i_r, char *i_s, all_ul_t *ref, uint64_t ID, uint8_t strand, int64_t s, int64_t l);
|
||||
void retrieve_u_seq(UC_Read* i_r, char* i_s, ma_utg_t *u, uint8_t strand, int64_t s, int64_t l, void *km);
|
||||
void debug_retrieve_rc_sub(const ug_opt_t *uopt, all_ul_t *ref, const All_reads *R_INF, ul_idx_t *ul, uint32_t n_step);
|
||||
|
||||
+5
-4
@@ -204,11 +204,12 @@ void ha_get_new_candidates(ha_abuf_t *ab, int64_t rid, UC_Read *ucr, overlap_reg
|
||||
}
|
||||
|
||||
void ha_get_new_ul_candidates(ha_abufl_t *ab, int64_t rid, char* rs, int64_t rl, uint64_t mz_w, uint64_t mz_k, const ul_idx_t *uref, overlap_region_alloc *overlap_list, Candidates_list *cl, double bw_thres, int max_n_chain, int keep_whole_chain,
|
||||
kvec_t_u8_warp* k_flag, kvec_t_u64_warp* chain_idx, void *ha_flt_tab, ha_pt_t *ha_idx, overlap_region* f_cigar, kvec_t_u64_warp* dbg_ct, st_mt_t *sp, void *km)
|
||||
kvec_t_u8_warp* k_flag, kvec_t_u64_warp* chain_idx, void *ha_flt_tab, ha_pt_t *ha_idx, overlap_region* f_cigar, kvec_t_u64_warp* dbg_ct, st_mt_t *sp, uint32_t high_occ, void *km)
|
||||
{
|
||||
uint32_t i;
|
||||
uint64_t k, l;
|
||||
uint32_t high_occ = asm_opt.hom_cov >= 1?asm_opt.hom_cov:1;
|
||||
if(high_occ < 1) high_occ = 1;
|
||||
// uint32_t high_occ = asm_opt.hom_cov >= 1?asm_opt.hom_cov:1;
|
||||
|
||||
// prepare
|
||||
clear_Candidates_list(cl);
|
||||
@@ -760,12 +761,12 @@ void ha_get_candidates_interface(ha_abuf_t *ab, int64_t rid, UC_Read *ucr, overl
|
||||
|
||||
|
||||
void ha_get_ul_candidates_interface(ha_abufl_t *ab, int64_t rid, char* rs, uint64_t rl, uint64_t mz_w, uint64_t mz_k, const ul_idx_t *uref, overlap_region_alloc *overlap_list, overlap_region_alloc *overlap_list_hp, Candidates_list *cl, double bw_thres,
|
||||
int max_n_chain, int keep_whole_chain, kvec_t_u8_warp* k_flag, kvec_t_u64_warp* chain_idx, overlap_region* f_cigar, kvec_t_u64_warp* dbg_ct, st_mt_t *sp, void *km)
|
||||
int max_n_chain, int keep_whole_chain, kvec_t_u8_warp* k_flag, kvec_t_u64_warp* chain_idx, overlap_region* f_cigar, kvec_t_u64_warp* dbg_ct, st_mt_t *sp, uint32_t high_occ, void *km)
|
||||
{
|
||||
extern void *ha_flt_tab;
|
||||
extern ha_pt_t *ha_idx;
|
||||
|
||||
ha_get_new_ul_candidates(ab, rid, rs, rl, mz_w, mz_k, uref, overlap_list, cl, bw_thres, max_n_chain, keep_whole_chain, k_flag, chain_idx, ha_flt_tab, ha_idx, f_cigar, dbg_ct, sp, km);
|
||||
ha_get_new_ul_candidates(ab, rid, rs, rl, mz_w, mz_k, uref, overlap_list, cl, bw_thres, max_n_chain, keep_whole_chain, k_flag, chain_idx, ha_flt_tab, ha_idx, f_cigar, dbg_ct, sp, high_occ, km);
|
||||
if(km) {
|
||||
ha_abufl_free_buf(km, ab, 1);
|
||||
destory_Candidates_list_buf(km, cl, 1);
|
||||
|
||||
+46
-2
@@ -8,6 +8,7 @@
|
||||
#include "CommandLines.h"
|
||||
#include "Correct.h"
|
||||
#include "inter.h"
|
||||
#include "Overlaps.h"
|
||||
|
||||
#define generic_key(x) (x)
|
||||
KRADIX_SORT_INIT(srt64, uint64_t, generic_key, 8)
|
||||
@@ -283,6 +284,17 @@ void update_sg_uo(asg_t *g, ma_hit_t_alloc *src)
|
||||
}
|
||||
|
||||
fprintf(stderr, "[M::%s::] ==> # gfa reads:%u, # covered gfa reads:%u\n", __func__, occ_n, occ_a);
|
||||
|
||||
// asg_arc_t *e; uint32_t v, w;
|
||||
// for (k = 0; k < g->n_arc; k++) {
|
||||
// e = &(g->arc[k]);
|
||||
// v = e->v^1; w = (e->ul>>32)^1;
|
||||
// av = asg_arc_a(g, v); nv = asg_arc_n(g, v);
|
||||
// for (z = 0; z < nv; z++) {
|
||||
// if(av[z].v == w) break;
|
||||
// }
|
||||
// if(z >= nv || av[z].ou != e->ou) fprintf(stderr, "[M::%s::asymmetry]\n", __func__);
|
||||
// }
|
||||
}
|
||||
|
||||
int32_t if_sup_chimeric(ma_hit_t_alloc* src, uint64_t rLen, asg64_v *b, int if_exact)
|
||||
@@ -1311,8 +1323,13 @@ void print_vw_edge(asg_t *sg, uint32_t v, uint32_t w, const char *cmd)
|
||||
if(i >= nv) fprintf(stderr, "[%s]\tno edges\n", cmd);
|
||||
}
|
||||
|
||||
void fill_containment_by_ul(asg_t *g, ma_hit_t_alloc *src)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ul_clean_gfa(ug_opt_t *uopt, asg_t *sg, ma_hit_t_alloc *src, ma_hit_t_alloc *rev, R_to_U* rI, int64_t clean_round, double min_ovlp_drop_ratio, double max_ovlp_drop_ratio,
|
||||
double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int32_t is_trio, uint32_t ou_thres)
|
||||
double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int32_t is_trio, uint32_t ou_thres, char *o_file)
|
||||
{
|
||||
#define HARD_OU_DROP 0.75
|
||||
#define HARD_OL_DROP 0.6
|
||||
@@ -1324,6 +1341,9 @@ double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int3
|
||||
int64_t i; asg64_v bu = {0,0,0}; uint32_t l_drop = 2000;
|
||||
if(is_ou) update_sg_uo(sg, src);
|
||||
|
||||
// debug_info_of_specfic_node("m64012_190921_234837/111673711/ccs", sg, rI, "beg");
|
||||
// debug_info_of_specfic_node("m64011_190830_220126/95028102/ccs", sg, rI, "beg");
|
||||
|
||||
asg_arc_cut_tips(sg, max_tip, &bu, is_ou);
|
||||
for (i = 0; i < clean_round; i++, drop += step) {
|
||||
if(drop > max_ovlp_drop_ratio) drop = max_ovlp_drop_ratio;
|
||||
@@ -1351,7 +1371,13 @@ double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int3
|
||||
asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 1);
|
||||
asg_arc_cut_complex_bub_links(sg, &bu, HARD_OL_DROP, HARD_OU_DROP, is_ou, b_mask_t);
|
||||
asg_arc_cut_tips(sg, max_tip, &bu, is_ou);
|
||||
|
||||
if(is_ou) {
|
||||
if(ul_refine_alignment(uopt, sg)) update_sg_uo(sg, src);
|
||||
}
|
||||
}
|
||||
// debug_info_of_specfic_node("m64012_190921_234837/111673711/ccs", sg, rI, "end");
|
||||
// debug_info_of_specfic_node("m64011_190830_220126/95028102/ccs", sg, rI, "end");
|
||||
|
||||
if(!is_ou) asg_iterative_semi_circ(sg, src, &bu, max_tip, 1);
|
||||
|
||||
@@ -1370,8 +1396,26 @@ double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int3
|
||||
|
||||
if(!is_ou) asg_cut_semi_circ(sg, LIM_LEN, 1);
|
||||
|
||||
if(is_ou) ul_refine_alignment(uopt, sg);
|
||||
|
||||
rescue_contained_reads_aggressive(NULL, sg, src, uopt->coverage_cut, rI, uopt->max_hang, uopt->min_ovlp, 10, 1, 0, NULL, NULL, b_mask_t);
|
||||
rescue_missing_overlaps_aggressive(NULL, sg, src, uopt->coverage_cut, rI, uopt->max_hang, uopt->min_ovlp, 1, 0, NULL, b_mask_t);
|
||||
rescue_missing_overlaps_backward(NULL, sg, src, uopt->coverage_cut, rI, uopt->max_hang, uopt->min_ovlp, 10, 1, 0, b_mask_t);
|
||||
// rescue_wrong_overlaps_to_unitigs(NULL, sg, sources, reverse_sources, coverage_cut, ruIndex,
|
||||
// max_hang_length, mini_overlap_length, bubble_dist, NULL);
|
||||
// rescue_no_coverage_aggressive(sg, sources, reverse_sources, &coverage_cut, ruIndex, max_hang_length,
|
||||
// mini_overlap_length, bubble_dist, 10);
|
||||
set_hom_global_coverage(&asm_opt, sg, uopt->coverage_cut, src, rev, rI, uopt->max_hang, uopt->min_ovlp);
|
||||
rescue_bubble_by_chain(sg, uopt->coverage_cut, src, rev, (asm_opt.max_short_tip*2), 0.15, 3, rI, 0.05, 0.9, uopt->max_hang, uopt->min_ovlp, 10, uopt->gap_fuzz, b_mask_t);
|
||||
|
||||
output_unitig_graph(sg, uopt->coverage_cut, o_file, src, rI, uopt->max_hang, uopt->min_ovlp);
|
||||
// flat_bubbles(sg, ruIndex->is_het); free(ruIndex->is_het); ruIndex->is_het = NULL;
|
||||
flat_soma_v(sg, src, rI);
|
||||
|
||||
if(is_ou) {
|
||||
// hic_clean(sg);
|
||||
// ul_realignment(uopt, sg);
|
||||
// if(ul_refine_alignment(uopt, sg)) update_sg_uo(sg, src);
|
||||
}
|
||||
// print_node(sg, 17078); //print_node(sg, 8311); print_node(sg, 8294);
|
||||
|
||||
free(bu.a);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Overlaps.h"
|
||||
|
||||
void ul_clean_gfa(ug_opt_t *uopt, asg_t *sg, ma_hit_t_alloc *src, ma_hit_t_alloc *rev, R_to_U* rI, int64_t clean_round, double min_ovlp_drop_ratio, double max_ovlp_drop_ratio,
|
||||
double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int32_t is_trio, uint32_t ou_thres);
|
||||
double ou_drop_rate, int64_t max_tip, bub_label_t *b_mask_t, int32_t is_ou, int32_t is_trio, uint32_t ou_thres, char *o_file);
|
||||
uint32_t asg_arc_cut_tips(asg_t *g, uint32_t max_ext, asg64_v *in, uint32_t is_ou);
|
||||
void asg_iterative_semi_circ(asg_t *g, ma_hit_t_alloc* src, asg64_v *in, uint32_t normal_len, uint32_t pop_chimer, asg64_v *dbg);
|
||||
void asg_arc_cut_chimeric(asg_t *g, ma_hit_t_alloc* src, asg64_v *in, uint32_t ou_thres);
|
||||
|
||||
@@ -1075,6 +1075,7 @@ void *ha_ft_ul_gen(const hifiasm_opt_t *asm_opt, ma_utg_v *us, int k, int w, int
|
||||
|
||||
// cutoff = (int)(asm_opt->hom_cov * asm_opt->high_factor);
|
||||
if (cutoff > YAK_MAX_COUNT - 1) cutoff = YAK_MAX_COUNT - 1;
|
||||
// fprintf(stderr, "[M::%s::] cutoff->%d\n\n", __func__, cutoff);
|
||||
ha_ct_shrink(h, cutoff, YAK_MAX_COUNT, asm_opt->thread_num);
|
||||
flt_tab = gen_hh(h, asm_opt->max_kmer_cnt);
|
||||
ha_ct_destroy(h);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
void ul_resolve(ma_ug_t *ug, const asg_t *rg, const ug_opt_t *uopt, int hap_n);
|
||||
void ul_load(const ug_opt_t *uopt);
|
||||
uint64_t* get_hifi2ul_list(all_ul_t *x, uint64_t hid, uint64_t* a_n);
|
||||
void ul_refine_alignment(const ug_opt_t *uopt, asg_t *sg);
|
||||
uint64_t ul_refine_alignment(const ug_opt_t *uopt, asg_t *sg);
|
||||
ma_ug_t *ul_realignment(const ug_opt_t *uopt, asg_t *sg);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user