upadate man-page and readme

This commit is contained in:
Haoyu Cheng
2020-01-04 11:54:08 +08:00
parent 1e46798bfb
commit d8416873f3
7 changed files with 407 additions and 176 deletions

View File

@@ -1918,10 +1918,10 @@ void generate_overlaps(int last_round)
Output_PAF();
build_string_graph_without_clean(MIN_OVERLAP_COVERAGE, R_INF.paf, R_INF.reverse_paf,
R_INF.total_reads, R_INF.read_length, MIN_OVERLAP_LEN, MAX_HANG_LEN, asm_opt.clean_round,
asm_opt.pop_bubble_size, asm_opt.min_drop_rate, asm_opt.max_drop_rate, asm_opt.output_file_name,
MAX_BUBBLE_DIST, 0, 1);
build_string_graph_without_clean(asm_opt.min_overlap_coverage, R_INF.paf, R_INF.reverse_paf,
R_INF.total_reads, R_INF.read_length, asm_opt.min_overlap_Len, asm_opt.max_hang_Len, asm_opt.clean_round,
asm_opt.gap_fuzz, asm_opt.min_drop_rate, asm_opt.max_drop_rate, asm_opt.output_file_name,
asm_opt.large_pop_bubble_size, 0, 1);
}
@@ -1931,10 +1931,9 @@ void Correct_Reads(int last_round)
if(asm_opt.load_index_from_disk && load_all_data_from_disk(&R_INF.paf, &R_INF.reverse_paf,
asm_opt.output_file_name))
{
build_string_graph_without_clean(MIN_OVERLAP_COVERAGE, R_INF.paf, R_INF.reverse_paf,
R_INF.total_reads, R_INF.read_length, MIN_OVERLAP_LEN, MAX_HANG_LEN, asm_opt.clean_round,
asm_opt.pop_bubble_size, asm_opt.min_drop_rate, asm_opt.max_drop_rate,
asm_opt.output_file_name, MAX_BUBBLE_DIST, 0, 0);
build_string_graph_without_clean(asm_opt.min_overlap_coverage, R_INF.paf, R_INF.reverse_paf,
R_INF.total_reads, R_INF.read_length, asm_opt.min_overlap_Len, asm_opt.max_hang_Len, asm_opt.clean_round,
asm_opt.gap_fuzz, asm_opt.min_drop_rate, asm_opt.max_drop_rate, asm_opt.output_file_name, asm_opt.large_pop_bubble_size, 0, 0);
exit(1);
}
else

View File

@@ -31,7 +31,11 @@ void Print_H(hifiasm_opt_t* asm_opt)
///fprintf(stderr, " -i ignore saved overlaps in *.ovlp*.bin files\n");
fprintf(stderr, " -i ignore saved overlaps in *.ovlp* files\n");
fprintf(stderr, " -z INT length of adapters that should be removed [%d]\n", asm_opt->adapterLen);
fprintf(stderr, " -p INT size of popped bubbles [%lld]\n", asm_opt->pop_bubble_size);
fprintf(stderr, " -m INT size of popped large bubbles for contig graph [%lld]\n",
asm_opt->large_pop_bubble_size);
fprintf(stderr, " -p INT size of popped small bubbles for haplotype-resolved unitig graph [%lld]\n",
asm_opt->small_pop_bubble_size);
fprintf(stderr, " -n INT small removed unitig threshold [%d]\n", asm_opt->max_short_tip);
fprintf(stderr, " -x FLOAT max overlap drop ratio [%.2g]\n", asm_opt->max_drop_rate);
fprintf(stderr, " -y FLOAT min overlap drop ratio [%.2g]\n", asm_opt->min_drop_rate);
fprintf(stderr, " -v show version number\n");
@@ -57,9 +61,16 @@ void init_opt(hifiasm_opt_t* asm_opt)
asm_opt->adapterLen = 0;
asm_opt->clean_round = 4;
asm_opt->complete_threads = 0;
asm_opt->pop_bubble_size = 100000;
asm_opt->small_pop_bubble_size = 100000;
asm_opt->large_pop_bubble_size = 10000000;
asm_opt->min_drop_rate = 0.2;
asm_opt->max_drop_rate = 0.8;
asm_opt->max_hang_Len = 1000;
asm_opt->max_hang_rate = 0.8;
asm_opt->gap_fuzz = 1000;
asm_opt->min_overlap_Len = 50;
asm_opt->min_overlap_coverage = 0;
asm_opt->max_short_tip = 3;
}
void destory_opt(hifiasm_opt_t* asm_opt)
@@ -90,68 +101,110 @@ int check_option(hifiasm_opt_t* asm_opt)
if(asm_opt->output_file_name == NULL)
{
fprintf(stderr, "[ERROR] missing output: please specify the output name\n");
fprintf(stderr, "[ERROR] missing output: please specify the output name (-o)\n");
return 0;
}
if(asm_opt->thread_num < 1)
{
fprintf(stderr, "[ERROR] the number of threads must be > 0\n");
fprintf(stderr, "[ERROR] the number of threads must be > 0 (-t)\n");
return 0;
}
if(asm_opt->number_of_round < 1)
{
fprintf(stderr, "[ERROR] the number of rounds for correction must be > 0\n");
fprintf(stderr, "[ERROR] the number of rounds for correction must be > 0 (-r)\n");
return 0;
}
if(asm_opt->clean_round < 1)
{
fprintf(stderr, "[ERROR] the number of rounds for assembly cleaning must be > 0\n");
fprintf(stderr, "[ERROR] the number of rounds for assembly cleaning must be > 0 (-a)\n");
return 0;
}
if(asm_opt->adapterLen < 0)
{
fprintf(stderr, "[ERROR] the length of removed adapters must be >= 0\n");
fprintf(stderr, "[ERROR] the length of removed adapters must be >= 0 (-z)\n");
return 0;
}
if(asm_opt->k_mer_length >= 64)
{
fprintf(stderr, "[ERROR] the length of k_mer must be < 64\n");
fprintf(stderr, "[ERROR] the length of k_mer must be < 64 (-k)\n");
return 0;
}
if(asm_opt->max_drop_rate < 0 || asm_opt->max_drop_rate >= 1 )
{
fprintf(stderr, "[ERROR] max overlap drop ratio must be [0.0, 1.0)\n");
fprintf(stderr, "[ERROR] max overlap drop ratio must be [0.0, 1.0) (-x)\n");
return 0;
}
if(asm_opt->min_drop_rate < 0 || asm_opt->min_drop_rate >= 1)
{
fprintf(stderr, "[ERROR] min overlap drop ratio must be [0.0, 1.0)\n");
fprintf(stderr, "[ERROR] min overlap drop ratio must be [0.0, 1.0) (-y)\n");
return 0;
}
if(asm_opt->max_drop_rate <= asm_opt->min_drop_rate)
{
fprintf(stderr, "[ERROR] min overlap drop ratio must be less than max overlap drop ratio\n");
fprintf(stderr, "[ERROR] min overlap drop ratio must be less than max overlap drop ratio (-x/-y)\n");
return 0;
}
if(asm_opt->pop_bubble_size < 0)
if(asm_opt->small_pop_bubble_size < 0)
{
fprintf(stderr, "[ERROR] the size of popped bubbles must be >= 0\n");
fprintf(stderr, "[ERROR] the size of popped small bubbles must be >= 0 (-p)\n");
return 0;
}
if(asm_opt->large_pop_bubble_size < 0)
{
fprintf(stderr, "[ERROR] the size of popped large bubbles must be >= 0 (-m)\n");
return 0;
}
if(asm_opt->max_hang_Len < 0)
{
fprintf(stderr, "[ERROR] max_hang_Len must be >= 0\n");
return 0;
}
if(asm_opt->max_hang_rate < 0)
{
fprintf(stderr, "[ERROR] max_hang_rate must be >= 0\n");
return 0;
}
if(asm_opt->gap_fuzz < 0)
{
fprintf(stderr, "[ERROR] gap_fuzz must be >= 0\n");
return 0;
}
if(asm_opt->min_overlap_Len < 0)
{
fprintf(stderr, "[ERROR] min_overlap_Len must be >= 0\n");
return 0;
}
if(asm_opt->min_overlap_coverage < 0)
{
fprintf(stderr, "[ERROR] min_overlap_coverage must be >= 0\n");
return 0;
}
if(asm_opt->max_short_tip < 0)
{
fprintf(stderr, "[ERROR] the length of removal tips must be >= 0 (-n)\n");
return 0;
}
// fprintf(stderr, "input file num: %d\n", asm_opt->num_reads);
// fprintf(stderr, "output file: %s\n", asm_opt->output_file_name);
@@ -162,7 +215,9 @@ int check_option(hifiasm_opt_t* asm_opt)
// fprintf(stderr, "length of k_mer: %d\n", asm_opt->k_mer_length);
// fprintf(stderr, "min overlap drop ratio: %.2g\n", asm_opt->min_drop_rate);
// fprintf(stderr, "max overlap drop ratio: %.2g\n", asm_opt->max_drop_rate);
// fprintf(stderr, "size of popped bubbles: %lld\n", asm_opt->pop_bubble_size);
// fprintf(stderr, "size of popped small bubbles: %lld\n", asm_opt->small_pop_bubble_size);
// fprintf(stderr, "size of popped large bubbles: %lld\n", asm_opt->large_pop_bubble_size);
// fprintf(stderr, "small removed unitig threshold: %d\n", asm_opt->max_short_tip);
return 1;
}
@@ -213,8 +268,6 @@ int CommandLine_process(int argc, char *argv[], hifiasm_opt_t* asm_opt)
}
else if (c == 't') asm_opt->thread_num = atoi(opt.arg);
else if (c == 'o') asm_opt->output_file_name = opt.arg;
else if (c == 'n') asm_opt->k_mer_min_freq = atoi(opt.arg);
else if (c == 'm') asm_opt->k_mer_max_freq = atoi(opt.arg);
else if (c == 'r') asm_opt->number_of_round = atoi(opt.arg);
else if (c == 'k') asm_opt->k_mer_length = atoi(opt.arg);
else if (c == 'i') asm_opt->load_index_from_disk = 0;
@@ -225,7 +278,9 @@ int CommandLine_process(int argc, char *argv[], hifiasm_opt_t* asm_opt)
else if (c == 'b') asm_opt->required_read_name = opt.arg;
else if (c == 'x') asm_opt->max_drop_rate = atof(opt.arg);
else if (c == 'y') asm_opt->min_drop_rate = atof(opt.arg);
else if (c == 'p') asm_opt->pop_bubble_size = atoll(opt.arg);
else if (c == 'p') asm_opt->small_pop_bubble_size = atoll(opt.arg);
else if (c == 'm') asm_opt->large_pop_bubble_size = atoll(opt.arg);
else if (c == 'n') asm_opt->max_short_tip = atoll(opt.arg);
else if (c == ':')
{
fprintf(stderr, "[ERROR] missing option argument in \"%s\"\n", argv[opt.i - 1]);

View File

@@ -21,10 +21,18 @@ typedef struct {
int clean_round;
int complete_threads;
int roundID;
int max_hang_Len;
int gap_fuzz;
int min_overlap_Len;
int min_overlap_coverage;
int max_short_tip;
float max_hang_rate;
float min_drop_rate;
float max_drop_rate;
long long pop_bubble_size;
long long small_pop_bubble_size;
long long large_pop_bubble_size;
long long num_bases;
long long num_corrected_bases;
long long num_recorrected_bases;

View File

@@ -25,8 +25,8 @@ KRADIX_SORT_INIT(arch64, uint64_t, generic_key, 8)
KSORT_INIT_GENERIC(uint32_t)
///actually min_thres = MAX_SHORT_TIPS + 1 there are MAX_SHORT_TIPS reads
long long min_thres = MAX_SHORT_TIPS + 1;
///this value has been updated at the first line of build_string_graph_without_clean
long long min_thres;
void ma_hit_sort_tn(ma_hit_t *a, long long n)
{
@@ -530,7 +530,7 @@ void ma_hit_contained(ma_hit_t_alloc* sources, long long n_read, ma_sub_t *cover
//check the corresponding two reads
ma_sub_t *sq = &(coverage_cut[Get_qn(*h)]);
ma_sub_t *st = &(coverage_cut[Get_tn(*h)]);
r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, MAX_HANG_PRE, min_ovlp, &t);
r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, asm_opt.max_hang_rate, min_ovlp, &t);
///r could not be MA_HT_SHORT_OVLP or MA_HT_INT
if (r == MA_HT_QCONT)
{
@@ -598,9 +598,10 @@ void ma_hit_flt(ma_hit_t_alloc* sources, long long n_read, ma_sub_t *coverage_cu
/**note!!! h->qn and h->qs have been normalized by sq->s
* h->ts and h->tn have been normalized by sq->e
**/
///here the max_hang = 1000, MAX_HANG_PRE = 0.8, min_ovlp = 500
///here the max_hang = 1000, asm_opt.max_hang_rate = 0.8, min_ovlp = 50
///for me, there should not have any overhang..so r cannot be equal to MA_HT_INT
r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, MAX_HANG_PRE, min_ovlp, &t);
///sq->e - sq->s = the length of query; st->e - st->s = the length od target
r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, asm_opt.max_hang_rate, min_ovlp, &t);
///for me, there should not have any overhang..so r cannot be equal to MA_HT_INT
@@ -1138,7 +1139,7 @@ long long n_read, uint64_t* readLen, ma_sub_t* coverage_cut, float shift_rate)
void ma_hit_cut(int min_dp, ma_hit_t_alloc* sources, long long n_read, uint64_t* readLen,
void ma_hit_cut(ma_hit_t_alloc* sources, long long n_read, uint64_t* readLen,
long long mini_overlap_length, ma_sub_t** coverage_cut)
{
double startTime = Get_T();
@@ -1491,7 +1492,7 @@ int max_hang, int min_ovlp)
int ql = coverage_cut[Get_qn(*h)].e - coverage_cut[Get_qn(*h)].s;
//high coverage region [sub[qn].e, sub[qn].s) in target
int tl = coverage_cut[Get_tn(*h)].e - coverage_cut[Get_tn(*h)].s;
r = ma_hit2arc(h, ql, tl, max_hang, MAX_HANG_PRE, min_ovlp, &t);
r = ma_hit2arc(h, ql, tl, max_hang, asm_opt.max_hang_rate, min_ovlp, &t);
/**
#define MA_HT_INT (-1)
#define MA_HT_QCONT (-2)
@@ -6139,7 +6140,6 @@ int asg_arc_del_tri_link(asg_t *g, int max_dist)
}
else if(f1)
{
if(l1 <= min_thres)
{
continue;
@@ -6148,7 +6148,6 @@ int asg_arc_del_tri_link(asg_t *g, int max_dist)
}
else if(f2)
{
if(l2 <= min_thres)
{
continue;
@@ -8724,35 +8723,6 @@ long long asg_arc_del_self_circle_untig(asg_t *g, long long circleLen, int is_dr
void output_unitig_graph_without_small_bubbles(asg_t *sg, ma_sub_t* coverage_cut,
char* output_file_name, long long n_read, long long bubble_dist, long long tipsLen)
{
asg_cut_tip(sg, tipsLen);
asg_pop_bubble(sg, bubble_dist);
asg_cut_tip(sg, tipsLen);
ma_ug_t *ug = NULL;
ug = ma_ug_gen(sg);
ma_ug_seq(ug, &R_INF, coverage_cut, n_read);
fprintf(stderr, "Writing unitig GFA to disk... \n");
char* gfa_name = (char*)malloc(strlen(output_file_name)+35);
sprintf(gfa_name, "%s.no_s_bub.gfa", output_file_name);
FILE* output_file = fopen(gfa_name, "w");
ma_ug_print(ug, &R_INF, coverage_cut, output_file);
fclose(output_file);
sprintf(gfa_name, "%s.simple.no_s_bub.gfa", output_file_name);
output_file = fopen(gfa_name, "w");
ma_ug_print_simple(ug, &R_INF, coverage_cut, output_file);
fclose(output_file);
free(gfa_name);
ma_ug_destroy(ug);
}
void output_unitig_graph_without_small_bubbles_primary(asg_t *sg, ma_sub_t* coverage_cut,
char* output_file_name, long long n_read, long long bubble_dist, long long tipsLen)
{
@@ -8782,57 +8752,6 @@ char* output_file_name, long long n_read, long long bubble_dist, long long tipsL
void output_contig_graph(asg_t *sg, ma_sub_t* coverage_cut, char* output_file_name, long long n_read, long long bubble_dist, long long tipsLen, float tip_drop_ratio, long long circleLen,
ma_hit_t_alloc* reverse_sources, long long miniedgeLen)
{
asg_cut_tip(sg, tipsLen);
// asg_pop_bubble(sg, bubble_dist);
// asg_arc_del_self_circle_untig(sg, circleLen);
long long n_ac = 1;
long long pre_cons = sg->n_seq + sg->n_arc;
long long cur_cons = 0;
///while(n_ac > 0)
while(pre_cons != cur_cons)
{
pre_cons = sg->n_seq + sg->n_arc;
n_ac = 0;
n_ac += asg_pop_bubble(sg, bubble_dist);
n_ac += asg_arc_del_self_circle_untig(sg, circleLen, 0);
n_ac += asg_arc_cut_long_tip(sg, tip_drop_ratio);
n_ac += asg_arc_cut_long_equal_tips(sg, reverse_sources, 2);
cur_cons = sg->n_seq + sg->n_arc;
}
asg_arc_identify_simple_bubbles_multi(sg, 1);
asg_arc_del_short_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, MAX_SHORT_TIPS);
///asg_arc_del_self_circle_untig(sg, circleLen);
ma_ug_t *ug = NULL;
ug = ma_ug_gen(sg);
ma_ug_seq(ug, &R_INF, coverage_cut, n_read);
fprintf(stderr, "Writing unitig GFA to disk... \n");
char* gfa_name = (char*)malloc(strlen(output_file_name)+35);
sprintf(gfa_name, "%s.contig.gfa", output_file_name);
FILE* output_file = fopen(gfa_name, "w");
ma_ug_print(ug, &R_INF, coverage_cut, output_file);
fclose(output_file);
sprintf(gfa_name, "%s.simple.contig.gfa", output_file_name);
output_file = fopen(gfa_name, "w");
ma_ug_print_simple(ug, &R_INF, coverage_cut, output_file);
fclose(output_file);
free(gfa_name);
ma_ug_destroy(ug);
}
long long get_graph_statistic(asg_t *g)
{
long long num_arc = 0;
@@ -8848,7 +8767,7 @@ long long get_graph_statistic(asg_t *g)
}
void output_contig_graph_primary(asg_t *sg, ma_sub_t* coverage_cut, char* output_file_name, long long n_read, long long bubble_dist, long long tipsLen, float tip_drop_ratio, long long circleLen,
ma_hit_t_alloc* reverse_sources, long long miniedgeLen)
ma_hit_t_alloc* reverse_sources)
{
asg_cut_tip_primary(sg, tipsLen);
long long n_ac = 1;
@@ -8870,7 +8789,7 @@ ma_hit_t_alloc* reverse_sources, long long miniedgeLen)
asg_arc_identify_simple_bubbles_multi(sg, 1);
///we don't need a special function here since it just removes edges instead of nodes
asg_arc_del_short_false_link_primary(sg, 0.6, 0.85, bubble_dist, reverse_sources, MAX_SHORT_TIPS);
asg_arc_del_short_false_link_primary(sg, 0.6, 0.85, bubble_dist, reverse_sources, asm_opt.max_short_tip);
ma_ug_t *ug = NULL;
@@ -9221,10 +9140,13 @@ long long rescue_threshold)
void build_string_graph_without_clean(
int min_dp, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources,
long long n_read, uint64_t* readLen, long long mini_overlap_length,
long long max_hang_length, long long clean_round, long long pop_bubble_size,
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)
{
///actually min_thres = asm_opt.max_short_tip + 1 there are asm_opt.max_short_tip reads
min_thres = asm_opt.max_short_tip + 1;
if (asm_opt.write_index_to_disk && write)
{
write_all_data_to_disk(sources, reverse_sources,
@@ -9242,13 +9164,13 @@ long long bubble_dist, int read_graph, int write)
ma_hit_sub(min_dp, sources, n_read, readLen, mini_overlap_length, &coverage_cut);
detect_chimeric_reads(sources, reverse_sources, n_read, readLen, coverage_cut,
FINAL_OVERLAP_ERROR_RATE*2);
ma_hit_cut(min_dp, sources, n_read, readLen, mini_overlap_length, &coverage_cut);
ma_hit_cut(sources, n_read, readLen, mini_overlap_length, &coverage_cut);
///it seems we do not need ma_hit_flt
ma_hit_flt(sources, n_read, coverage_cut, max_hang_length, mini_overlap_length);
ma_hit_contained(sources, n_read, coverage_cut, max_hang_length, mini_overlap_length);
asg_t *sg = NULL;
sg = ma_sg_gen(sources, n_read, coverage_cut, max_hang_length, mini_overlap_length);
asg_arc_del_trans(sg, GAP_FUZZ);
asg_arc_del_trans(sg, gap_fuzz);
if(VERBOSE >= 1)
@@ -9261,14 +9183,14 @@ long long bubble_dist, int read_graph, int write)
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_cut_tip(sg, asm_opt.max_short_tip);
// debug_info_of_specfic_node("m64016_190918_162737/72220752/ccs", sg, "cut_tip");
///asg_arc_del_short_diploid_unclean(sg, corase_ovlp_drop_ratio, sources, reverse_sources);
// asg_arc_del_single_node_bubble(sg, bubble_dist);
// asg_cut_tip(sg, MAX_SHORT_TIPS);
///asg_cut_tip(sg, MAX_SHORT_TIPS);
// asg_cut_tip(sg, asm_opt.max_short_tip);
///asg_cut_tip(sg, asm_opt.max_short_tip);
if(clean_round > 0)
{
@@ -9303,11 +9225,11 @@ long long bubble_dist, int read_graph, int write)
int tri_flag = 0;
tri_flag += asg_arc_del_self_circle_contig(sg);
///asg_arc_del_single_node_bubble(sg, bubble_dist);
tri_flag += asg_arc_del_single_node_directly(sg, MAX_SHORT_TIPS, sources);
tri_flag += asg_arc_del_single_node_directly(sg, asm_opt.max_short_tip, sources);
tri_flag += asg_arc_del_triangular_advance(sg, bubble_dist);
tri_flag += asg_arc_del_cross_bubble(sg, bubble_dist);
///asg_arc_del_single_node_bubble(sg, bubble_dist);
tri_flag += asg_arc_del_single_node_directly(sg, MAX_SHORT_TIPS, sources);
tri_flag += asg_arc_del_single_node_directly(sg, asm_opt.max_short_tip, sources);
if(tri_flag == 0)
{
break;
@@ -9315,37 +9237,38 @@ long long bubble_dist, int read_graph, int write)
}
///asg_arc_del_orthology(sg, reverse_sources, drop_ratio, MAX_SHORT_TIPS);
// asg_arc_del_orthology_multiple_way(sg, reverse_sources, drop_ratio, MAX_SHORT_TIPS);
// asg_cut_tip(sg, MAX_SHORT_TIPS);
///asg_arc_del_orthology(sg, reverse_sources, drop_ratio, asm_opt.max_short_tip);
// asg_arc_del_orthology_multiple_way(sg, reverse_sources, drop_ratio, asm_opt.max_short_tip);
// asg_cut_tip(sg, asm_opt.max_short_tip);
/****************************may have bugs********************************/
asg_arc_identify_simple_bubbles_multi(sg, 1);
//reomve edge between two chromesomes
asg_arc_del_false_node(sg, MAX_SHORT_TIPS);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_false_node(sg, asm_opt.max_short_tip);
asg_cut_tip(sg, asm_opt.max_short_tip);
/****************************may have bugs********************************/
/****************************may have bugs********************************/
///asg_arc_identify_simple_bubbles_multi(sg, 1);
asg_arc_identify_simple_bubbles_multi(sg, 0);
///asg_arc_del_short_diploid_unclean_exact(sg, drop_ratio, sources);
asg_arc_del_short_diploid_by_exact(sg, MAX_SHORT_TIPS, sources);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_short_diploid_by_exact(sg, asm_opt.max_short_tip, sources);
asg_cut_tip(sg, asm_opt.max_short_tip);
/****************************may have bugs********************************/
asg_arc_identify_simple_bubbles_multi(sg, 1);
asg_arc_del_short_diploid_by_length(sg, drop_ratio, MAX_SHORT_TIPS, reverse_sources, MAX_SHORT_TIPS);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_short_diploid_by_length(sg, drop_ratio, asm_opt.max_short_tip, reverse_sources,
asm_opt.max_short_tip);
asg_cut_tip(sg, asm_opt.max_short_tip);
asg_arc_identify_simple_bubbles_multi(sg, 1);
asg_arc_del_short_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, MAX_SHORT_TIPS);
asg_arc_del_short_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, asm_opt.max_short_tip);
asg_arc_identify_simple_bubbles_multi(sg, 1);
asg_arc_del_complex_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, MAX_SHORT_TIPS);
asg_arc_del_complex_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, asm_opt.max_short_tip);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_cut_tip(sg, asm_opt.max_short_tip);
}
}
@@ -9358,10 +9281,10 @@ long long bubble_dist, int read_graph, int write)
{
int tri_flag = 0;
tri_flag += asg_arc_del_self_circle_contig(sg);
tri_flag += asg_arc_del_single_node_directly(sg, MAX_SHORT_TIPS, sources);
tri_flag += asg_arc_del_single_node_directly(sg, asm_opt.max_short_tip, sources);
tri_flag += asg_arc_del_triangular_advance(sg, bubble_dist);
tri_flag += asg_arc_del_cross_bubble(sg, bubble_dist);
tri_flag += asg_arc_del_single_node_directly(sg, MAX_SHORT_TIPS, sources);
tri_flag += asg_arc_del_single_node_directly(sg, asm_opt.max_short_tip, sources);
if(tri_flag == 0)
{
@@ -9371,32 +9294,32 @@ long long bubble_dist, int read_graph, int write)
asg_arc_del_short_diploi_by_suspect_edge(sg, MAX_SHORT_TIPS, sources);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_triangular_directly(sg, MAX_SHORT_TIPS, reverse_sources);
asg_arc_del_short_diploi_by_suspect_edge(sg, asm_opt.max_short_tip, sources);
asg_cut_tip(sg, asm_opt.max_short_tip);
asg_arc_del_triangular_directly(sg, asm_opt.max_short_tip, reverse_sources);
///asg_arc_identify_simple_bubbles_multi(sg, 0);
// asg_arc_del_chimeric_read(sg, MAX_SHORT_TIPS*2);
// asg_cut_tip(sg, MAX_SHORT_TIPS);
// asg_arc_del_chimeric_read(sg, asm_opt.max_short_tip*2);
// asg_cut_tip(sg, asm_opt.max_short_tip);
asg_arc_identify_simple_bubbles_multi(sg, 0);
asg_arc_del_orthology_multiple_way(sg, reverse_sources, 0.4, MAX_SHORT_TIPS);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_orthology_multiple_way(sg, reverse_sources, 0.4, asm_opt.max_short_tip);
asg_cut_tip(sg, asm_opt.max_short_tip);
asg_arc_identify_simple_bubbles_multi(sg, 0);
asg_arc_del_too_short_overlaps(sg, 2000, min_ovlp_drop_ratio, reverse_sources, MAX_SHORT_TIPS);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_too_short_overlaps(sg, 2000, min_ovlp_drop_ratio, reverse_sources, asm_opt.max_short_tip);
asg_cut_tip(sg, asm_opt.max_short_tip);
/**
asg_arc_identify_simple_bubbles_multi(sg, 1);
asg_arc_del_short_false_link_advance(sg, 0.6, 0.85, bubble_dist, reverse_sources, MAX_SHORT_TIPS);
asg_arc_del_short_false_link_advance(sg, 0.6, 0.85, bubble_dist, reverse_sources, asm_opt.max_short_tip);
**/
@@ -9435,7 +9358,7 @@ long long bubble_dist, int read_graph, int write)
asg_arc_identify_simple_bubbles_multi(sg, 0);
c_tips += asg_arc_del_complex_false_link(sg, 0.7, bubble_dist);
if(c_tips) asg_cut_tip(sg, MAX_SHORT_TIPS);
if(c_tips) asg_cut_tip(sg, asm_opt.max_short_tip);
i++;
}
**/
@@ -9444,15 +9367,13 @@ long long bubble_dist, int read_graph, int write)
/**
memset(sg->seq_vis, 0, sg->n_seq*2*sizeof(uint8_t));
asg_arc_del_short_diploid_by_exact(sg, MAX_SHORT_TIPS, sources);
asg_cut_tip(sg, MAX_SHORT_TIPS);
asg_arc_del_short_diploid_by_exact(sg, asm_opt.max_short_tip, sources);
asg_cut_tip(sg, asm_opt.max_short_tip);
**/
// debug_info_of_specfic_node("m64016_190918_162737/141297762/ccs", sg);
///out:
///output_tips(sg, &R_INF);
///check_node_lable(sg);
output_unitig_graph(sg, coverage_cut, output_file_name, n_read);
@@ -9463,9 +9384,9 @@ long long bubble_dist, int read_graph, int write)
}
output_unitig_graph_without_small_bubbles_primary(sg, coverage_cut, output_file_name, n_read,
pop_bubble_size, MAX_SHORT_TIPS);
output_contig_graph_primary(sg, coverage_cut, output_file_name, n_read, 10000000, MAX_SHORT_TIPS, 0.1, 20,
reverse_sources, MAX_SHORT_TIPS);
asm_opt.small_pop_bubble_size, asm_opt.max_short_tip);
output_contig_graph_primary(sg, coverage_cut, output_file_name, n_read, bubble_dist,
asm_opt.max_short_tip, 0.1, 20, reverse_sources);
output_contig_graph_alternative(sg, coverage_cut, output_file_name, n_read);

View File

@@ -7,14 +7,14 @@
///#define MIN_OVERLAP_LEN 2000
///#define MIN_OVERLAP_LEN 500
///#define MIN_OVERLAP_LEN 50
#define MIN_OVERLAP_LEN 50
///#define MIN_OVERLAP_LEN 50
///#define MIN_OVERLAP_COVERAGE 1
#define MIN_OVERLAP_COVERAGE 0
#define MAX_HANG_LEN 1000
#define MAX_HANG_PRE 0.8
#define GAP_FUZZ 1000
#define MAX_SHORT_TIPS 3
#define MAX_BUBBLE_DIST 10000000
///#define MIN_OVERLAP_COVERAGE 0
///#define MAX_HANG_LEN 1000
///#define MAX_HANG_PRE 0.8
///#define GAP_FUZZ 1000
///#define MAX_SHORT_TIPS 3
///#define MAX_BUBBLE_DIST 10000000
#define SMALL_BUBBLE_SIZE (uint32_t)-1
//#define SMALL_BUBBLE_SIZE 1000
@@ -77,7 +77,7 @@ typedef struct {
void ma_hit_sub(int min_dp, ma_hit_t_alloc* sources, long long n_read, uint64_t* readLen,
long long mini_overlap_length, ma_sub_t** coverage_cut);
void ma_hit_cut(int min_dp, ma_hit_t_alloc* sources, long long n_read, uint64_t* readLen,
void ma_hit_cut(ma_hit_t_alloc* sources, long long n_read, uint64_t* readLen,
long long mini_overlap_length, ma_sub_t** coverage_cut);
void ma_hit_flt(ma_hit_t_alloc* sources, long long n_read, const ma_sub_t *coverage_cut,
int max_hang, int min_ovlp);
@@ -116,7 +116,7 @@ typedef struct { size_t n, m; uint64_t *a; } asg64_v;
#define MA_HT_TCONT (-3)
#define MA_HT_SHORT_OVLP (-4)
///in default, max_hang = 1000, int_frac = 0.05, min_ovlp = 2000
///in default, max_hang = 1000, int_frac = 0.8, min_ovlp = 50
static inline int ma_hit2arc(const ma_hit_t *h, int ql, int tl, int max_hang, float int_frac, int min_ovlp, asg_arc_t *p)
{
int32_t tl5, tl3, ext5, ext3, qs = (int32_t)h->qns;
@@ -135,6 +135,7 @@ static inline int ma_hit2arc(const ma_hit_t *h, int ql, int tl, int max_hang, fl
if (ext5 > max_hang || ext3 > max_hang || h->qe - qs < (h->qe - qs + ext5 + ext3) * int_frac)
return MA_HT_INT;
**/
///ext3 and ext5 should be always 0
if (ext5 > max_hang || ext3 > max_hang
|| h->qe - qs < (h->qe - qs + ext5 + ext3) * int_frac
|| h->te - h->ts < (h->te - h->ts + ext5 + ext3) * int_frac)
@@ -326,7 +327,7 @@ static inline int count_out_without_del(const asg_t *g, uint32_t v)
void build_string_graph_without_clean(
int min_dp, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources,
long long n_read, uint64_t* readLen, long long mini_overlap_length,
long long max_hang_length, long long clean_round, long long pop_bubble_size,
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);

View File

@@ -17,25 +17,24 @@ The input of hifiasm is the PacBio Hifi reads in fasta/fastq format, and its
outputs consist of:
1. Haplotype-resolved raw [unitig][unitig] graph in [GFA][gfa] format
(hifiasm.asm.r\_utg.gfa by default).
(hifiasm.asm.r\_utg.gfa by default). This graph keeps all haplotype information
2. Haplotype-resolved processed [unitig][unitig] graph in [GFA][gfa] format
without small bubbles (hifiasm.asm.p\_utg.gfa by default). Small bubbles
might be caused by somatic mutations, which are useless for some
applications.
without small bubbles (hifiasm.asm.p\_utg.gfa by default). Small bubbles might be
caused by somatic mutations or noise in data, which are not the real haplotype information.
3. Primary assembly [contig][unitig] graph in [GFA][gfa] format
(hifiasm.asm.p\_ctg.gfa by default).
4. Alternate assembly [contig][unitig] graph in [GFA][gfa] format
(hifiasm.asm.a\_ctg.gfa by default).
5. Haplotype-aware error corrected reads in fasta format (hifiasm.asm.ec.fa by
default).
6. All-to-all overlaps in [paf][paf] format (hifiasm.asm.paf).
6. All-to-all overlaps in [paf][paf] format (hifiasm.asm.ovlp.paf).
So far hifiasm is still in early development stage, it will output phased
chromosome-level high-quality assembly in the near future. In addition, hifiasm
also outputs three binary files that save all overlap inforamtion
(hifiasm.asm.ovlp, hifiasm.asm.ovlp.source, hifiasm.asm.ovlp.reverse in default). With these files, hifiasm can avoid the time-consuming all-to-all overlap calculation step, and do the assembly
directly and quickly. This might be helpful when you want to get an optimized
assembly by multiple round of experiments with different parameters.
assembly by multiple rounds of experiments with different parameters.
Hifiasm is a standalone and lightweight assembler, which does not need external
libraries (except zlib). For large genomes, it can generate high-quality
@@ -52,6 +51,18 @@ assembly in a few hours. Hifiasm has been tested on the following datasets:
[2] CHM13 is a homozygous sample, so that unitig N50 makes no sense.
[3] Butterfly has high heterozygous rate, so that most chromosomes have been fully separated into two haplotypes. In this case, contig N50 makes no sense.<sub>
Note that different species need different assembly graphs. For homozygous genomes,
the primary assembly contig graph is the best choice.
For species with high heterozygous rate, different haplotypes can be fully separated.
It is important to remove small bubbles from the haplotype-resolved unitig graph. The
reason is that there are some somatic mutations or noise in data, which are not
the real haplotype information. In this case, haplotype-resolved processed unitig graph
without small bubbles should be better.
For ordinary human genome, different haplotypes cannot be fully separated due to the low
heterozygous rate. There are many small bubbles including haplotype information,
which cannot be simply removed. Thus, it is necessary to use the haplotype-resolved raw
unitig graph. **Hifiasm will generate a universal haplotype contig graph for all species in the near future.**
## Usage
For Hifi reads assembly, a typical command line looks like:
@@ -92,8 +103,11 @@ have further questions, please raise an issue at the issue page.
1. For genome with low heterozygous rate, hifiasm only outputs
haplotype-resolved assembly graph, instead of the phased chromosome-level
assembly (will support such output in the near future).
assembly (**will support such output in the near future**).
2. The running time and memory usage should be further reduced.
2. For different species, hifiasm outputs different assembly graphs, which are not easy to use.
**Hifiasm will generate a universal haplotype contig graph for all species in the near future.**
3. The N50 should be further improved.
3. The running time and memory usage should be further reduced.
4. The N50 should be further improved.

233
hifiasm.1 Normal file
View File

@@ -0,0 +1,233 @@
.TH hifiasm 1 "3 Jan 2020" "hifiasm-0.1.0" "Bioinformatics tools"
.SH NAME
.PP
hifiasm - haplotype-resolved de novo assembler for PacBio Hifi reads.
.SH SYNOPSIS
.PP
hifiasm
.RB [ -o
.IR outPrefix ]
.RB [ -t
.IR numThres ]
.RB [ -r
.IR roundCorrection ]
.RB [ -a
.IR roundGraphClean ]
.RB [ -k
.IR kmerLen ]
.RB [ -z
.IR adapterLen ]
.RB [ -m
.IR maxLargeBubbles ]
.RB [ -p
.IR maxSmallBubbles ]
.RB [ -n
.IR maxSmallUnitig ]
.RB [ -x
.IR maxDropRatio ]
.RB [ -y
.IR minDropRatio ]
.RB [ -i ]
.RB [ -v ]
.RB [ -h ]
.I <in_1.fq> <in_2.fq> <...>
.SH DESCRIPTION
.PP
Hifiasm is an ultrafast haplotype-resolved de novo assembler for PacBio
Hifi reads. Unlike most existing assemblers, hifiasm starts from uncollapsed
genome. Thus, it is able to keep the haplotype information as much as possible.
The input of hifiasm is the PacBio Hifi reads in fasta/fastq format, and its
outputs consist of multiple types of assembly graph in GFA format.
.SH OPTIONS
.SS General options
.TP 10
.BI -o \ FILE
Prefix of output files [hifiasm.asm]. The outputs of hifiasm include error corrected
reads in fasta format, all-to-all overlaps in paf format, and four types of assembly
graph in GFA format. For detailed description of all assembly graphs, please see
.I 'Outputs'
section of this man-page.
.TP 10
.BI -t \ INT
Number of CPU threads used by hifiasm [1].
.TP 10
.BI -v
Show version number.
.TP 10
.BI -h
Show help information.
.SS Error correction options
.TP 10
.BI -k \ INT
K-mer length [40]. This option must be less than 64.
.TP 10
.BI -r \ INT
Rounds of haplotype-aware error corrections [2]. This option affects all outputs of hifiasm.
.SS Assembly options
.TP 10
.BI -a \ INT
Rounds of assembly graph cleaning [4]. This option is used with
.I [-x maxDropRatio]
and
.I [-y minDropRatio].
Note that unlike
.I [-r],
this option does not affect error corrected reads and all-to-all overlaps.
.TP 10
.BI -z \ INT
Length of adapters that should be removed [0]. This option remove
.I INT
bases from both ends of each read.
Some old Hifi reads may consist of
short adapters (e.g., 20bp adapter at one end). For such data, trimming short adapters would
significantly improve the assembly quality.
.TP 10
.BI -m \ INT
Maximal probing distance for bubble popping when generating primary/alternate assembly
contig graphs [10000000]. Bubbles longer than
.I INT
bases will not be popped. For detailed description of these graphs, please see
.I 'Outputs'
section of this man-page.
.TP 10
.BI -p \ INT
Maximal probing distance for bubble popping when generating haplotype-resolved processed unitig graph
without small bubbles [100000]. Bubbles longer than
.I INT
bases will not be popped. Small bubbles might be caused by somatic mutations or noise in data, which
are not the real haplotype information. For detailed description of this graph, please see
.I 'Outputs'
section of this man-page.
.TP 10
.BI -n \ INT
A unitig is considered small if it is composed of less than
.I INT
reads [3]. Hifiasm may try to remove small unitigs at various steps.
.TP 10
.BI -x \ FLOAT, -y \ FLOAT
Max and min overlap drop ratio [0.8, 0.2]. This option is used with
.I [-r roundCorrection].
Given a node
.I N
in the assembly graph, let max(N)
be the length of the largest overlap of
.I N.
Hifiasm iteratively drops overlaps of
.I N
if their length / max(N)
are below a threshold controlled by
.I [-x maxDropRatio]
and
.I [-y minDropRatio].
Hifiasm applies
.I [-r roundCorrection]
rounds of short overlap removal with an increasing threshold between
.I [-x maxDropRatio]
and
.I [-y minDropRatio].
.TP 10
.BI -i
Ignore saved overlaps in [*.ovlp*] files.
Apart from assembly graphs, hifiasm also outputs three binary files
that save all overlap information during assembly step.
With these files, hifiasm can avoid the time-consuming all-to-all overlap calculation step,
and do the assembly directly and quickly.
This might be helpful when users want to get an optimized assembly by multiple rounds of experiments
with different parameters.
.SH EXAMPLES
.TP
.BR ./hifiasm " " \-o " " NA12878.asm " " \-t " " 32 " " NA12878_1.fq.gz " " NA12878_2.fq.gz
In this example, hifiasm will be run with 32 CPU threads. The input read files are [NA12878_1.fq.gz]
and [NA12878_2.fq.gz],
while all output files can be found at [NA12878.asm.*].
.TP
.BR ./hifiasm " " \-o " " butterfly.asm " " \-t " " 32 " " \-z " " 20 " " butterfly.fq.gz
In this example, hifiasm will be run with 32 CPU threads. The input read file is [butterfly.fq.gz],
while all output files can be found at [butterfly.asm.*].
With
.I [-z 20],
hifiasm will remove 20 bases from both ends of each read.
.SH OUTPUTS
.PP
Consider the prefix of output files has been specified by
.I [-o outPrefix].
During the error correction step, hifiasm outputs the following two files:
.IP
1. Haplotype-aware error corrected reads in fasta format [outPrefix.ec.fa].
2. All-to-all overlaps in paf format [outPrefix.ovlp.paf].
.PP
During the assembly step, hifiasm outputs the following four assembly graphs in GFA format:
.IP
1. Haplotype-resolved raw unitig graph [outPrefix.r_utg.gfa].
This graph keeps all haplotype information.
2. Haplotype-resolved processed unitig graph without small bubbles [outPrefix.p_utg.gfa].
Small bubbles might be caused by somatic mutations or noise in data, which are not the real haplotype information.
The size of popped small bubbles should be specified by
.I [-p maxSmallBubbles].
3. Primary assembly contig graph [outPrefix.p_ctg.gfa].
This graph collapses different haplotypes.
4. Alternate assembly contig graph [outPrefix.a_ctg.gfa].
This graph consists of all assemblies that are discarded in primary assembly contig graph.
.PP
For each graph, hifiasm also outputs a simplified version without sequences. These simplified
graphs can be easily visualized.
.PP
Note that different species need different assembly graphs. For homozygous genomes,
the primary assembly contig graph is the best choice.
For species with high heterozygous rate, different haplotypes can be fully separated.
It is important to remove small bubbles from the haplotype-resolved unitig graph. The
reason is that there are some somatic mutations or noise in data, which are not
the real haplotype information. In this case, haplotype-resolved processed unitig graph
without small bubbles should be better.
For ordinary human genome, different haplotypes cannot be fully separated due to the low
heterozygous rate. There are many small bubbles including haplotype information,
which cannot be simply removed. Thus, it is necessary to use the haplotype-resolved raw
unitig graph.