r179: replace one qsort() with ks_introsort()

This commit is contained in:
Heng Li
2020-04-02 10:34:43 -04:00
parent 7776dee103
commit 483ceb852c
5 changed files with 20 additions and 91 deletions

View File

@@ -3,7 +3,7 @@
#include <pthread.h>
#define HA_VERSION "0.3.0-dirty-r178"
#define HA_VERSION "0.3.0-dirty-r179"
#define VERBOSE 0
#define VERBOSE_GFA 0

View File

@@ -1173,4 +1173,4 @@ long long* max_t_pos, long long* max_q_pos, long long* score, long long* droped)
#define GAP_EXT_KSW 2
#define Z_DROP_KSW 400
#define BAND_KSW 50
#endif
#endif

View File

@@ -12,6 +12,9 @@ pthread_mutex_t output_mutex;
#define overlap_region_key(a) ((a).y_id)
KRADIX_SORT_INIT(overlap_region_sort, overlap_region, overlap_region_key, member_size(overlap_region, y_id))
#define oreg_xs_lt(a, b) (((uint64_t)(a).x_pos_s<<32|(a).x_pos_e) < ((uint64_t)(b).x_pos_s<<32|(b).x_pos_e))
KSORT_INIT(or_xs, overlap_region, oreg_xs_lt)
void overlap_region_sort_y_id(overlap_region *a, long long n)
{
radix_sort_overlap_region_sort(a, a + n);
@@ -30,6 +33,7 @@ void init_overlap_region_alloc(overlap_region_alloc* list)
init_window_list_alloc(&(list->list[i].boundary_cigars));
}
}
void clear_overlap_region_alloc(overlap_region_alloc* list)
{
list->length = 0;
@@ -58,7 +62,6 @@ void destory_overlap_region_alloc(overlap_region_alloc* list)
free(list->list);
}
int get_fake_gap_pos(Fake_Cigar* x, int index)
{
return (x->buffer[index]>>32);
@@ -269,64 +272,6 @@ void append_overlap_region_alloc_debug(overlap_region_alloc* list, overlap_regio
list->length++;
}
int cmp_by_x_pos_s(const void * a, const void * b)
{
if ((*(overlap_region*)a).x_pos_s > (*(overlap_region*)b).x_pos_s)
{
return 1;
}
else if ((*(overlap_region*)a).x_pos_s < (*(overlap_region*)b).x_pos_s)
{
return -1;
}
else
{
if ((*(overlap_region*)a).x_pos_e > (*(overlap_region*)b).x_pos_e)
{
return 1;
}
else if ((*(overlap_region*)a).x_pos_e < (*(overlap_region*)b).x_pos_e)
{
return -1;
}
else
{
return 0;
}
}
}
int cmp_by_x_pos_e(const void * a, const void * b)
{
if ((*(overlap_region*)a).x_pos_e > (*(overlap_region*)b).x_pos_e)
{
return 1;
}
else if ((*(overlap_region*)a).x_pos_e < (*(overlap_region*)b).x_pos_e)
{
return -1;
}
else
{
if ((*(overlap_region*)a).x_pos_s > (*(overlap_region*)b).x_pos_s)
{
return 1;
}
else if ((*(overlap_region*)a).x_pos_s < (*(overlap_region*)b).x_pos_s)
{
return -1;
}
else
{
return 0;
}
}
}
void debug_chain(k_mer_hit* a, long long a_n, Chain_Data* dp)
{
long long i, j, current_j;
@@ -709,7 +654,7 @@ void calculate_overlap_region_by_chaining(Candidates_list* candidates, overlap_r
destory_fake_cigar(&(tmp_region.f_cigar));
qsort(overlap_list->list, overlap_list->length, sizeof(overlap_region), cmp_by_x_pos_s);
ks_introsort_or_xs(overlap_list->length, overlap_list->list);
}
void append_window_list(overlap_region* region, uint64_t x_start, uint64_t x_end, int y_start, int y_end, int error,

View File

@@ -80,24 +80,23 @@ typedef struct
typedef struct
{
uint64_t x_id;
uint32_t x_id;
///the begining and end of the whole overlap
uint64_t x_pos_s;
uint64_t x_pos_e;
uint64_t x_pos_strand;
uint32_t x_pos_s;
uint32_t x_pos_e;
uint32_t x_pos_strand;
uint64_t y_id;
uint64_t y_pos_s;
uint64_t y_pos_e;
uint64_t y_pos_strand;
uint32_t y_id;
uint32_t y_pos_s;
uint32_t y_pos_e;
uint32_t y_pos_strand;
uint64_t overlapLen;
uint64_t shared_seed;
uint64_t align_length;
///uint64_t total_errors;
uint32_t overlapLen;
uint32_t shared_seed;
uint32_t align_length;
uint8_t is_match;
uint8_t without_large_indel;
uint64_t non_homopolymer_errors;
uint32_t non_homopolymer_errors;
window_list* w_list;
uint64_t w_list_size;
@@ -163,7 +162,7 @@ void resize_fake_cigar(Fake_Cigar* x, uint64_t size);
int get_fake_gap_pos(Fake_Cigar* x, int index);
int get_fake_gap_shift(Fake_Cigar* x, int index);
inline long long y_start_offset(long long x_start, Fake_Cigar* o)
static inline long long y_start_offset(long long x_start, Fake_Cigar* o)
{
if(x_start == get_fake_gap_pos(o, o->length - 1))
{
@@ -189,18 +188,6 @@ inline long long y_start_offset(long long x_start, Fake_Cigar* o)
return get_fake_gap_shift(o, i - 1);
}
inline void print_fake_gap(Fake_Cigar* o)
{
long long i;
for (i = 0; i < (long long)o->length; i++)
{
fprintf(stderr, "**i: %lld, gap_pos_in_x: %d, gap_shift: %d\n",
i, get_fake_gap_pos(o, i),
get_fake_gap_shift(o, i));
}
}
void resize_Chain_Data(Chain_Data* x, long long size);
void init_window_list_alloc(window_list_alloc* x);
void clear_window_list_alloc(window_list_alloc* x);

View File

@@ -24,8 +24,6 @@
#define Get_NAME(R_INF, ID) ((R_INF).name + (R_INF).name_index[(ID)])
extern uint8_t seq_nt6_table[256];
extern char bit_t_seq_table[256][4];
extern char bit_t_seq_table_rc[256][4];
@@ -33,7 +31,6 @@ extern char s_H[5];
extern char rc_Table[5];
#define RC_CHAR(x) rc_Table[seq_nt6_table[(uint8_t)x]]
void init_aux_table();