mirror of
https://github.com/chhylp123/hifiasm.git
synced 2026-10-09 18:10:56 +08:00
r176: enabled the minimap2 chaining heuristic
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define HA_VERSION "0.3.0-dirty-r175"
|
#define HA_VERSION "0.3.0-dirty-r176"
|
||||||
|
|
||||||
#define VERBOSE 0
|
#define VERBOSE 0
|
||||||
#define VERBOSE_GFA 0
|
#define VERBOSE_GFA 0
|
||||||
|
|||||||
+29
-45
@@ -356,14 +356,12 @@ void debug_chain(k_mer_hit* a, long long a_n, Chain_Data* dp)
|
|||||||
|
|
||||||
if(indels != dp->indels[i])
|
if(indels != dp->indels[i])
|
||||||
{
|
{
|
||||||
fprintf(stderr, "indels: %lld, dp->indels[i]: %lld\n",
|
fprintf(stderr, "indels: %lld, dp->indels[i]: %ld\n", indels, (long)dp->indels[i]);
|
||||||
indels, dp->indels[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selfLen != dp->self_length[i])
|
if(selfLen != dp->self_length[i])
|
||||||
{
|
{
|
||||||
fprintf(stderr, "selfLen: %lld, dp->self_length[i]: %lld\n",
|
fprintf(stderr, "selfLen: %lld, dp->self_length[i]: %ld\n", selfLen, (long)dp->self_length[i]);
|
||||||
selfLen, dp->self_length[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -418,6 +416,7 @@ void chain_DP(k_mer_hit* a, long long a_n, Chain_Data* dp, overlap_region* resul
|
|||||||
|
|
||||||
resize_Chain_Data(dp, a_n);
|
resize_Chain_Data(dp, a_n);
|
||||||
// fill the score and backtrack arrays
|
// fill the score and backtrack arrays
|
||||||
|
for (i = 0; i < a_n; ++i) dp->tmp[i] = -1;
|
||||||
for (i = 0; i < a_n; ++i)
|
for (i = 0; i < a_n; ++i)
|
||||||
{
|
{
|
||||||
pos = a[i].offset;
|
pos = a[i].offset;
|
||||||
@@ -461,26 +460,18 @@ void chain_DP(k_mer_hit* a, long long a_n, Chain_Data* dp, overlap_region* resul
|
|||||||
|
|
||||||
score += dp->score[j];
|
score += dp->score[j];
|
||||||
|
|
||||||
///find a new max score
|
///find a new max score
|
||||||
if(score > max_score)
|
if (score > max_score) {
|
||||||
{
|
max_score = score;
|
||||||
max_score = score;
|
max_j = j;
|
||||||
max_j = j;
|
max_indels = total_indels;
|
||||||
max_indels = total_indels;
|
max_self_length = total_self_length;
|
||||||
max_self_length = total_self_length;
|
if (n_skip > 0) --n_skip;
|
||||||
/****************************may have bugs********************************/
|
} else if (dp->tmp[j] == i) {
|
||||||
n_skip = 0;
|
if (++n_skip > max_skip)
|
||||||
/****************************may have bugs********************************/
|
break;
|
||||||
}/****************************may have bugs********************************/
|
}
|
||||||
else
|
if (dp->pre[j] >= 0) dp->tmp[dp->pre[j]] = i;
|
||||||
{
|
|
||||||
n_skip++;
|
|
||||||
if(n_skip > max_skip)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/****************************may have bugs********************************/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dp->score[i] = max_score;
|
dp->score[i] = max_score;
|
||||||
@@ -636,14 +627,10 @@ void calculate_overlap_region_by_chaining(Candidates_list* candidates, overlap_r
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
chain_DP(candidates->list + sub_region_beg,
|
chain_DP(candidates->list + sub_region_beg,
|
||||||
sub_region_end - sub_region_beg + 1, &(candidates->chainDP), &tmp_region, band_width_threshold,
|
sub_region_end - sub_region_beg + 1, &(candidates->chainDP), &tmp_region, band_width_threshold,
|
||||||
50, Get_READ_LENGTH((*R_INF), tmp_region.x_id), Get_READ_LENGTH((*R_INF), tmp_region.y_id));
|
25, Get_READ_LENGTH((*R_INF), tmp_region.x_id), Get_READ_LENGTH((*R_INF), tmp_region.y_id));
|
||||||
|
|
||||||
// chain_DP_back(candidates->list + sub_region_beg,
|
|
||||||
// sub_region_end - sub_region_beg + 1, &(candidates->chainDP), &tmp_region, band_width_threshold);
|
|
||||||
|
|
||||||
///自己和自己重叠的要排除
|
|
||||||
///if (tmp_region.x_id != tmp_region.y_id && tmp_region.shared_seed > 1)
|
///if (tmp_region.x_id != tmp_region.y_id && tmp_region.shared_seed > 1)
|
||||||
if (tmp_region.x_id != tmp_region.y_id)
|
if (tmp_region.x_id != tmp_region.y_id)
|
||||||
{
|
{
|
||||||
@@ -720,12 +707,7 @@ void test_single_list(Candidates_list* candidates, k_mer_pos* n_list, uint64_t n
|
|||||||
|
|
||||||
void init_Chain_Data(Chain_Data* x)
|
void init_Chain_Data(Chain_Data* x)
|
||||||
{
|
{
|
||||||
x->length = 0;
|
memset(x, 0, sizeof(Chain_Data));
|
||||||
x->size = 0;
|
|
||||||
x->score = NULL;
|
|
||||||
x->pre = NULL;
|
|
||||||
x->indels = NULL;
|
|
||||||
x->self_length = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_Chain_Data(Chain_Data* x)
|
void clear_Chain_Data(Chain_Data* x)
|
||||||
@@ -739,18 +721,20 @@ void destory_Chain_Data(Chain_Data* x)
|
|||||||
free(x->pre);
|
free(x->pre);
|
||||||
free(x->indels);
|
free(x->indels);
|
||||||
free(x->self_length);
|
free(x->self_length);
|
||||||
|
free(x->tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize_Chain_Data(Chain_Data* x, long long size)
|
void resize_Chain_Data(Chain_Data* x, long long size)
|
||||||
{
|
{
|
||||||
if(size > x->size)
|
if (size > x->size) {
|
||||||
{
|
x->size = size;
|
||||||
x->size = size;
|
kroundup64(x->size);
|
||||||
x->score = (long long*)realloc(x->score, x->size*sizeof(long long));
|
REALLOC(x->score, x->size);
|
||||||
x->pre = (long long*)realloc(x->pre, x->size*sizeof(long long));
|
REALLOC(x->pre, x->size);
|
||||||
x->indels = (long long*)realloc(x->indels, x->size*sizeof(long long));
|
REALLOC(x->indels, x->size);
|
||||||
x->self_length = (long long*)realloc(x->self_length, x->size*sizeof(long long));
|
REALLOC(x->self_length, x->size);
|
||||||
}
|
REALLOC(x->tmp, x->size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_Candidates_list(Candidates_list* l)
|
void init_Candidates_list(Candidates_list* l)
|
||||||
|
|||||||
+9
-10
@@ -113,8 +113,7 @@ typedef struct
|
|||||||
overlap_region* list;
|
overlap_region* list;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
uint64_t length;
|
uint64_t length;
|
||||||
///uint64_t mapped_overlaps_length;
|
int64_t mapped_overlaps_length;
|
||||||
long long mapped_overlaps_length;
|
|
||||||
} overlap_region_alloc;
|
} overlap_region_alloc;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -123,14 +122,14 @@ typedef struct
|
|||||||
uint32_t offset, self_offset;
|
uint32_t offset, self_offset;
|
||||||
} k_mer_hit;
|
} k_mer_hit;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
int32_t *score;
|
||||||
long long* score;
|
int64_t *pre;
|
||||||
long long* pre;
|
int32_t *indels;
|
||||||
long long* indels;
|
int32_t *self_length;
|
||||||
long long* self_length;
|
int64_t *tmp;
|
||||||
long long length;
|
int64_t length;
|
||||||
long long size;
|
int64_t size;
|
||||||
} Chain_Data;
|
} Chain_Data;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
+1
-9
@@ -62,7 +62,7 @@ void ha_get_new_candidates(ha_abuf_t *ab, int64_t rid, UC_Read *ucr, overlap_reg
|
|||||||
}
|
}
|
||||||
if (ab->n_a > ab->m_a) {
|
if (ab->n_a > ab->m_a) {
|
||||||
ab->m_a = ab->n_a;
|
ab->m_a = ab->n_a;
|
||||||
ab->m_a = ab->m_a > 16? ab->m_a + (ab->m_a>>1) : 16;
|
kroundup64(ab->m_a);
|
||||||
REALLOC(ab->a, ab->m_a);
|
REALLOC(ab->a, ab->m_a);
|
||||||
}
|
}
|
||||||
for (i = 0, k = 0; i < ab->mz.n; ++i) {
|
for (i = 0, k = 0; i < ab->mz.n; ++i) {
|
||||||
@@ -104,12 +104,4 @@ void ha_get_new_candidates(ha_abuf_t *ab, int64_t rid, UC_Read *ucr, overlap_reg
|
|||||||
cl->length = ab->n_a;
|
cl->length = ab->n_a;
|
||||||
|
|
||||||
calculate_overlap_region_by_chaining(cl, overlap_list, rid, ucr->length, &R_INF, band_width_threshold, keep_whole_chain);
|
calculate_overlap_region_by_chaining(cl, overlap_list, rid, ucr->length, &R_INF, band_width_threshold, keep_whole_chain);
|
||||||
#if 0
|
|
||||||
fprintf(stderr, "B\t%ld\t%ld\n", (long)overlap_list->length, (long)overlap_list->mapped_overlaps_length);
|
|
||||||
for (int i = 0; i < (int)overlap_list->length; ++i) {
|
|
||||||
overlap_region *r = &overlap_list->list[i];
|
|
||||||
fprintf(stderr, "C\t%d\t%d\t%d\t%c\t%d\t%d\t%d\t%c\t%d\t%d\n", (int)r->x_id, (int)r->x_pos_s, (int)r->x_pos_e, "+-"[r->x_pos_strand],
|
|
||||||
(int)r->y_id, (int)r->y_pos_s, (int)r->y_pos_e, "+-"[r->y_pos_strand], (int)r->shared_seed, r->is_match);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ static inline uint64_t yak_hash_long(uint64_t x[4])
|
|||||||
#define MALLOC(ptr, len) ((ptr) = (__typeof__(ptr))malloc((len) * sizeof(*(ptr))))
|
#define MALLOC(ptr, len) ((ptr) = (__typeof__(ptr))malloc((len) * sizeof(*(ptr))))
|
||||||
#define REALLOC(ptr, len) ((ptr) = (__typeof__(ptr))realloc((ptr), (len) * sizeof(*(ptr))))
|
#define REALLOC(ptr, len) ((ptr) = (__typeof__(ptr))realloc((ptr), (len) * sizeof(*(ptr))))
|
||||||
|
|
||||||
|
#ifndef kroundup64
|
||||||
|
#define kroundup64(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, x|=(x)>>32, ++(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef klib_unused
|
#ifndef klib_unused
|
||||||
#if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3)
|
#if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3)
|
||||||
#define klib_unused __attribute__ ((__unused__))
|
#define klib_unused __attribute__ ((__unused__))
|
||||||
|
|||||||
Reference in New Issue
Block a user