mirror of
https://github.com/chhylp123/hifiasm.git
synced 2026-09-26 04:18:12 +08:00
Accelerate overlap merge
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
+164
-1
@@ -415,7 +415,7 @@ void Build_hash_table_multiple_thr()
|
||||
}
|
||||
|
||||
|
||||
void* Overlap_calculate(void* arg)
|
||||
void* Overlap_calculate_version1(void* arg)
|
||||
{
|
||||
|
||||
int thr_ID = *((int*)arg);
|
||||
@@ -517,6 +517,169 @@ void* Overlap_calculate(void* arg)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void debug_merge_result(Candidates_list* x, Candidates_list* y)
|
||||
{
|
||||
uint64_t i;
|
||||
if (x->length != y->length)
|
||||
{
|
||||
fprintf(stderr, "ERROR: different list\n");
|
||||
fprintf(stderr, "x->length: %llu, y->length: %llu\n", x->length, y->length);
|
||||
}
|
||||
|
||||
for (i = 0; i < x->length; i++)
|
||||
{
|
||||
if (x->list[i].offset != y->list[i].offset
|
||||
||
|
||||
x->list[i].readID != y->list[i].readID
|
||||
||
|
||||
x->list[i].self_offset != y->list[i].self_offset
|
||||
||
|
||||
x->list[i].strand != y->list[i].strand
|
||||
)
|
||||
{
|
||||
fprintf(stderr, "ERROR: different pos\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void* Overlap_calculate(void* arg)
|
||||
{
|
||||
|
||||
int thr_ID = *((int*)arg);
|
||||
|
||||
long long i = 0;
|
||||
int avalible_k = 0;
|
||||
|
||||
UC_Read g_read;
|
||||
init_UC_Read(&g_read);
|
||||
HPC_seq HPC_read;
|
||||
Hash_code k_code;
|
||||
uint64_t code;
|
||||
uint64_t end_pos;
|
||||
k_mer_pos* list;
|
||||
uint64_t list_length;
|
||||
uint64_t sub_ID;
|
||||
|
||||
Candidates_list l;
|
||||
//Candidates_list debug_l;
|
||||
|
||||
init_Candidates_list(&l);
|
||||
//init_Candidates_list(&debug_l);
|
||||
|
||||
k_mer_pos_list_alloc array_list;
|
||||
init_k_mer_pos_list_alloc(&array_list);
|
||||
|
||||
for (i = thr_ID; i < R_INF.total_reads; i = i + thread_num)
|
||||
///for (i = thr_ID; i < R_INF.total_reads/50; i = i + thread_num)
|
||||
{
|
||||
/**
|
||||
if (i % 1000 == 0)
|
||||
{
|
||||
fprintf(stderr, "i: %llu\n", i);
|
||||
}
|
||||
**/
|
||||
|
||||
|
||||
|
||||
clear_Candidates_list(&l);
|
||||
///clear_Candidates_list(&debug_l);
|
||||
|
||||
clear_k_mer_pos_list_alloc(&array_list);
|
||||
recover_UC_Read(&g_read, &R_INF, i);
|
||||
|
||||
|
||||
///forward strand
|
||||
init_HPC_seq(&HPC_read, g_read.seq, g_read.length);
|
||||
init_Hash_code(&k_code);
|
||||
avalible_k = 0;
|
||||
|
||||
while ((code = get_HPC_code(&HPC_read, &end_pos)) != 6)
|
||||
{
|
||||
if(code < 4)
|
||||
{
|
||||
k_mer_append(&k_code,code,k_mer_length);
|
||||
avalible_k++;
|
||||
if (avalible_k>=k_mer_length)
|
||||
{
|
||||
list_length = locate_Total_Pos_Table(&PCB, &k_code, &list, k_mer_length, &sub_ID);
|
||||
|
||||
if (list_length != 0)
|
||||
{
|
||||
append_k_mer_pos_list_alloc(&array_list, list, list_length, end_pos, 0);
|
||||
}
|
||||
///merge_Candidates_list(&l, list, list_length, end_pos, 0);
|
||||
///merge_Candidates_list_version(&debug_l, list, list_length, end_pos, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avalible_k = 0;
|
||||
init_Hash_code(&k_code);
|
||||
}
|
||||
|
||||
///HPC_base++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///reverse complement strand
|
||||
reverse_complement(g_read.seq, g_read.length);
|
||||
init_HPC_seq(&HPC_read, g_read.seq, g_read.length);
|
||||
init_Hash_code(&k_code);
|
||||
avalible_k = 0;
|
||||
|
||||
while ((code = get_HPC_code(&HPC_read, &end_pos)) != 6)
|
||||
{
|
||||
if(code < 4)
|
||||
{
|
||||
k_mer_append(&k_code,code,k_mer_length);
|
||||
avalible_k++;
|
||||
if (avalible_k>=k_mer_length)
|
||||
{
|
||||
list_length = locate_Total_Pos_Table(&PCB, &k_code, &list, k_mer_length, &sub_ID);
|
||||
if (list_length != 0)
|
||||
{
|
||||
append_k_mer_pos_list_alloc(&array_list, list, list_length, end_pos, 1);
|
||||
}
|
||||
///merge_Candidates_list(&l, list, list_length, end_pos, 1);
|
||||
///merge_Candidates_list_version(&debug_l, list, list_length, end_pos, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avalible_k = 0;
|
||||
init_Hash_code(&k_code);
|
||||
}
|
||||
|
||||
///HPC_base++;
|
||||
}
|
||||
|
||||
merge_k_mer_pos_list_alloc(&array_list, &l);
|
||||
|
||||
///debug_merge_result(&l, &debug_l);
|
||||
|
||||
}
|
||||
|
||||
destory_Candidates_list(&l);
|
||||
///destory_Candidates_list(&debug_l);
|
||||
|
||||
|
||||
destory_k_mer_pos_list_alloc(&array_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Overlap_calculate_multipe_thr()
|
||||
{
|
||||
double start_time = Get_T();
|
||||
|
||||
+48
-5
@@ -24,17 +24,60 @@ void clear_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list)
|
||||
}
|
||||
|
||||
|
||||
void append_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list, k_mer_pos* n_list, uint64_t n_length)
|
||||
void append_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list, k_mer_pos* n_list, uint64_t n_length,
|
||||
uint64_t n_end_pos, uint8_t n_direction)
|
||||
{
|
||||
list->length++;
|
||||
if (list->length > list->size)
|
||||
|
||||
if (list->length + 1 > list->size)
|
||||
{
|
||||
list->size = list->size * 2;
|
||||
list->list = (k_mer_pos_list*)realloc(list->list, sizeof(k_mer_pos_list)*list->size);
|
||||
}
|
||||
|
||||
list->list[list->length - 1].list = n_list;
|
||||
list->list[list->length - 1].length = n_length;
|
||||
list->list[list->length].list = n_list;
|
||||
list->list[list->length].length = n_length;
|
||||
list->list[list->length].direction = n_direction;
|
||||
list->list[list->length].end_pos = n_end_pos;
|
||||
|
||||
list->length++;
|
||||
}
|
||||
|
||||
int cmp_k_mer_pos_list(const void * a, const void * b)
|
||||
{
|
||||
if ((*(k_mer_pos_list*)a).length > (*(k_mer_pos_list*)b).length)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if ((*(k_mer_pos_list*)a).length < (*(k_mer_pos_list*)b).length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void merge_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list, Candidates_list* candidates)
|
||||
{
|
||||
qsort(list->list, list->length, sizeof(k_mer_pos_list), cmp_k_mer_pos_list);
|
||||
|
||||
uint64_t i;
|
||||
for (i = 0; i < list->length; i++)
|
||||
{
|
||||
/**
|
||||
if (i > 0 && (list->list[i].length < list->list[i-1].length || list->list[i].length == 0 || list->list[i-1].length == 0))
|
||||
{
|
||||
fprintf(stderr, "ERROR\n");
|
||||
}
|
||||
**/
|
||||
|
||||
merge_Candidates_list(candidates, list->list[i].list, list->list[i].length,
|
||||
list->list[i].end_pos, list->list[i].direction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void init_Count_Table(Count_Table** table)
|
||||
|
||||
@@ -41,6 +41,8 @@ typedef struct
|
||||
{
|
||||
k_mer_pos* list;
|
||||
uint64_t length;
|
||||
uint8_t direction;
|
||||
uint64_t end_pos;
|
||||
} k_mer_pos_list;
|
||||
|
||||
typedef struct
|
||||
@@ -339,6 +341,13 @@ void destory_Candidates_list(Candidates_list* l);
|
||||
void merge_Candidates_list(Candidates_list* l, k_mer_pos* n_list, uint64_t n_lengh, uint64_t end_pos, int strand);
|
||||
|
||||
|
||||
void init_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list);
|
||||
void destory_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list);
|
||||
void clear_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list);
|
||||
void append_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list, k_mer_pos* n_list, uint64_t n_length,
|
||||
uint64_t n_end_pos, uint8_t n_direction);
|
||||
void merge_k_mer_pos_list_alloc(k_mer_pos_list_alloc* list, Candidates_list* candidates);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user