diff --git a/CHANGES.md b/CHANGES.md index 4a2bef3..662834d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # CHANGES +## 1.13.2 + +* Futher fixes for `sentinel` calls. +* * Correct versin of REQUIRED_MIN_LIBZ as we are looking for greater than. + ## 1.13.1 * Ensure all `sentinel` calls return non-zero exit code. diff --git a/Makefile b/Makefile index c7d9246..e140662 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CAVEMAN_VERSION=1.13.1 +CAVEMAN_VERSION=1.13.2 TEST_REF?="" #Compiler CC?=gcc diff --git a/setup.sh b/setup.sh index a859363..1b81a0e 100755 --- a/setup.sh +++ b/setup.sh @@ -23,7 +23,7 @@ SOURCE_HTSLIB="https://github.com/samtools/htslib/releases/download/1.3.2/htslib-1.3.2.tar.bz2" -REQUIRED_MIN_LIBZ="1.2.3.5" +REQUIRED_MIN_LIBZ="1.2.3.4" function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } diff --git a/src/alg_bean.c b/src/alg_bean.c index 30d78e9..736e549 100644 --- a/src/alg_bean.c +++ b/src/alg_bean.c @@ -93,7 +93,7 @@ alg_bean_t *alg_bean_read_file(FILE *file){ bean->lane = lanes_list; bean->lane_size = List_count(lanes_list); }else{ - sentinel("Unrecognised id passed: %s.",text_id,1); + sentinel("Unrecognised id passed: %s.",text_id); } } diff --git a/src/algos.c b/src/algos.c index 015ca36..dd167b7 100644 --- a/src/algos.c +++ b/src/algos.c @@ -708,22 +708,24 @@ int algos_estep_read_position(alg_bean_t *alg,long double ********prob_arr, char } //read_pos_t struct has copy number and ref base is a usable base. if(pos->ref_base_idx >= 0 && pos->norm_cn > 0 && pos->tum_cn > 0){ + int chk = 0; //Adding to the counts at this position. if(pos_t->normal == 1){ if(pos_t->strand == 1){ - genotype_add_base_to_count(pos->norm_rev_cvg,toupper(seq_nt16_str[pos_t->called_base])); + chk = genotype_add_base_to_count(pos->norm_rev_cvg,toupper(seq_nt16_str[pos_t->called_base])); }else{ - genotype_add_base_to_count(pos->norm_fwd_cvg,toupper(seq_nt16_str[pos_t->called_base])); + chk = genotype_add_base_to_count(pos->norm_fwd_cvg,toupper(seq_nt16_str[pos_t->called_base])); } pos->total_cvg_norm++; }else if(pos_t->normal == 0){ if(pos_t->strand == 1){ - genotype_add_base_to_count(pos->tum_rev_cvg,toupper(seq_nt16_str[pos_t->called_base])); + chk = genotype_add_base_to_count(pos->tum_rev_cvg,toupper(seq_nt16_str[pos_t->called_base])); }else{ - genotype_add_base_to_count(pos->tum_fwd_cvg,toupper(seq_nt16_str[pos_t->called_base])); + chk = genotype_add_base_to_count(pos->tum_fwd_cvg,toupper(seq_nt16_str[pos_t->called_base])); } pos->total_cvg_tum++; } + check(chk==0,"Error adding genotype to base count."); //Get the index for things we'll use during analysis int rpos_i,mq_i,bq_i,callbase_i; int ok = algos_get_read_specific_indices(alg,pos_t,&rpos_i,&mq_i,&bq_i,&callbase_i); diff --git a/src/cn_access.c b/src/cn_access.c index 4d5a727..99124de 100644 --- a/src/cn_access.c +++ b/src/cn_access.c @@ -142,7 +142,7 @@ int8_t cn_access_get_copy_number_for_location(char *file_loc,char *chr,uint32_t } } }else{ - sentinel("Somehow copy number for location %s:%d was not available.",chr,pos,1); + sentinel("Somehow copy number for location %s:%d was not available.",chr,pos); } return cn; error: diff --git a/src/config_file_access.c b/src/config_file_access.c index a202a98..0f5d819 100644 --- a/src/config_file_access.c +++ b/src/config_file_access.c @@ -76,8 +76,7 @@ int config_file_access_read_config_file(FILE *file, char *tum_bam_file, char *no char *chk = getcwd(cur_wd,size); check(chk!=NULL,"Error retrieving CWD when reading config file."); if(strcmp(cur_wd,value)!=0){ - sentinel("Your current working directory '%s' is not the same as the directory you setup CaVEMan: '%s'. Please change to that directory and try again.", - cur_wd,value,1); + sentinel("Your current working directory '%s' is not the same as the directory you setup CaVEMan: '%s'. Please change to that directory and try again.",cur_wd,value); } }else if(strcmp(MUT_TUM,key)==0){ strcpy(tum_bam_file,value); @@ -118,7 +117,7 @@ int config_file_access_read_config_file(FILE *file, char *tum_bam_file, char *no }else if(strcmp(TUM_CN_KEY,key)==0){ strcpy(tum_cn,value); }else{ - sentinel("Unrecognised key in config file '%s'.",key,1); + sentinel("Unrecognised key in config file '%s'.",key); } } diff --git a/src/estep.c b/src/estep.c index 293642c..a58a807 100644 --- a/src/estep.c +++ b/src/estep.c @@ -122,7 +122,7 @@ void estep_print_usage (int exit_code){ exit(exit_code); } -void estep_setup_options(int argc, char *argv[]){ +int estep_setup_options(int argc, char *argv[]){ const struct option long_opts[] = { {"config-file", required_argument, 0, 'f'}, @@ -200,7 +200,7 @@ void estep_setup_options(int argc, char *argv[]){ case 'M': if(sscanf(optarg, "%i", &cn) != 1){ - sentinel("Error parsing -M argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -M argument '%s'. Should be an integer > 0",optarg); } cn_access_set_max_cn(cn); break; @@ -215,79 +215,79 @@ void estep_setup_options(int argc, char *argv[]){ case 'n': if(sscanf(optarg, "%i", &normal_copy_number) != 1){ - sentinel("Error parsing -n argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -n argument '%s'. Should be an integer > 0",optarg); } break; case 't': if(sscanf(optarg, "%i", &tumour_copy_number) != 1){ - sentinel("Error parsing -t argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -t argument '%s'. Should be an integer > 0",optarg); } break; case 'i': if(sscanf(optarg, "%i", &idx) != 1){ - sentinel("Error parsing -i argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -i argument '%s'. Should be an integer > 0",optarg); } break; case 'm': if(sscanf(optarg, "%i", &min_bq) != 1){ - sentinel("Error parsing -m argument '%s'. Should be an integer >= 0",optarg,1); + sentinel("Error parsing -m argument '%s'. Should be an integer >= 0",optarg); } break; case 'k': if(sscanf(optarg, "%f", &norm_contam) != 1){ - sentinel("Error parsing -k argument '%s'. Should be a float >= 0.0.",optarg,1); + sentinel("Error parsing -k argument '%s'. Should be a float >= 0.0.",optarg); } break; case 'd': if(sscanf(optarg, "%f", &prior_snp_prob) != 1){ - sentinel("Error parsing -d argument '%s'. Should be a float > 0.0.",optarg,1); + sentinel("Error parsing -d argument '%s'. Should be a float > 0.0.",optarg); } break; case 'c': if(sscanf(optarg, "%f", &prior_mut_prob) != 1){ - sentinel("Error parsing -c argument '%s'. Should be a float > 0.0.",optarg,1); + sentinel("Error parsing -c argument '%s'. Should be a float > 0.0.",optarg); } break; case 'b': if(sscanf(optarg, "%f", &ref_bias) != 1){ - sentinel("Error parsing -b argument '%s'. Should be a float >= 0.0.",optarg,1); + sentinel("Error parsing -b argument '%s'. Should be a float >= 0.0.",optarg); } break; case 'p': if(sscanf(optarg, "%f", &min_mut_prob) != 1){ - sentinel("Error parsing -p argument '%s'. Should be a float >= 0.0.",optarg,1); + sentinel("Error parsing -p argument '%s'. Should be a float >= 0.0.",optarg); } break; case 'q': if(sscanf(optarg, "%f", &min_snp_prob) != 1){ - sentinel("Error parsing -q argument '%s'. Should be a float >= 0.0.",optarg,1); + sentinel("Error parsing -q argument '%s'. Should be a float >= 0.0.",optarg); } break; case 'x': if(sscanf(optarg, "%i", &min_tum_cvg) != 1){ - sentinel("Error parsing -x argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -x argument '%s'. Should be an integer > 0",optarg); } break; case 'y': if(sscanf(optarg, "%i", &min_norm_cvg) != 1){ - sentinel("Error parsing -y argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -y argument '%s'. Should be an integer > 0",optarg); } break; case 'a': if(sscanf(optarg, "%i", &split_size) != 1){ - sentinel("Error parsing -a argument '%s'. Should be an integer >= 0",optarg,1); + sentinel("Error parsing -a argument '%s'. Should be an integer >= 0",optarg); } break; @@ -341,15 +341,16 @@ void estep_setup_options(int argc, char *argv[]){ set_max_tum_cvg(estep_max_tumour_coverage); - return; + return 0; error: estep_print_usage (1); - return; + return -1; } int estep_main(int argc, char *argv[]){ - estep_setup_options(argc, argv); + int is_err = estep_setup_options(argc, argv); + check(is_err==0, "Error parsing options"); long double ********prob_arr = NULL; alg_bean_t *alg = NULL; diff --git a/src/generateCavemanVCFUnmatchedNormalPanel.c b/src/generateCavemanVCFUnmatchedNormalPanel.c index 440b810..db95fe0 100644 --- a/src/generateCavemanVCFUnmatchedNormalPanel.c +++ b/src/generateCavemanVCFUnmatchedNormalPanel.c @@ -321,7 +321,7 @@ List *gen_panel_get_list_of_samples_and_locs(){ bamchar = strtok(bam_file_locs,","); LIST_FOREACH(samples, first, next, cur){ if(bamchar == NULL){ - sentinel("List of sample names and bam locations are not equal in length.",1); + sentinel("List of sample names and bam locations are not equal in length."); } ((sample_bam *)cur->value)->bam_file = malloc(sizeof(char) * (strlen(bamchar) + 1)); check_mem(((sample_bam *)cur->value)->bam_file); diff --git a/src/genotype.c b/src/genotype.c index ea60393..6bede85 100644 --- a/src/genotype.c +++ b/src/genotype.c @@ -50,7 +50,7 @@ List *genotype_hard_copy_genotype_t_list(List *new_list, List *old){ return new_list; } -void genotype_add_base_to_count(genotype_t *geno, const char base){ +int genotype_add_base_to_count(genotype_t *geno, const char base){ assert(geno != NULL); switch(base){ case 'A': @@ -70,12 +70,12 @@ void genotype_add_base_to_count(genotype_t *geno, const char base){ break; default: - sentinel("Incorrect base passed to add: %c",base,1); + sentinel("Incorrect base passed to add: %c",base); break; }; - return; + return 0; error: - return; + return -1; } void genotype_set_base_count(genotype_t *geno, const char base, int count){ @@ -226,14 +226,16 @@ List *genotype_calculate_genotypes(int copy_num, char *ref_base){ //Create 2 copies, one will be reference, the next will be mutant base. genotype_t *gen1 = genotype_copy_genotype(gen); genotype_t *gen2 = genotype_copy_genotype(gen1); - genotype_add_base_to_count(gen2,ref_base[0]); + int chk = genotype_add_base_to_count(gen2,ref_base[0]); + check(chk==0,"Error adding base to genotype count."); List_push(tmp,gen2); int j=0; for(j=0; j<4; j++){ int base_count = genotype_get_base_count(gen1,bases[j]); check(base_count >= 0, "Error fetching base count for base: %c with genotype: %s.",bases[j],genotype_get_genotype_t_as_string(gen1)); if(base_count>=1 && ref_base[0] != bases[j]){ - genotype_add_base_to_count(gen1,bases[j]); + chk = genotype_add_base_to_count(gen1,bases[j]); + check(chk==0,"Error adding base to genotype count."); List_push(tmp,gen1); } } @@ -247,7 +249,8 @@ List *genotype_calculate_genotypes(int copy_num, char *ref_base){ for(j=0; j<4; j++){ genotype_t *gen = genotype_init_genotype(); check(gen != NULL, "Error generating genotype."); - genotype_add_base_to_count(gen,bases[j]); + int chk = genotype_add_base_to_count(gen,bases[j]); + check(chk==0,"Error adding base to genotype count."); List_push(genos,gen); } } diff --git a/src/genotype.h b/src/genotype.h index 4b5473e..aefbcf7 100644 --- a/src/genotype.h +++ b/src/genotype.h @@ -78,7 +78,7 @@ List *genotype_calculate_genotypes(int copy_num, char *ref_base); char *genotype_get_genotype_t_as_string(genotype_t *geno); long double genotype_get_var_base_proportion(genotype_t *gen, char ref_base, int copy_num); char genotype_get_var_base(genotype_t *geno, char ref_base); -void genotype_add_base_to_count(genotype_t *geno, char base); +int genotype_add_base_to_count(genotype_t *geno, char base); int genotype_get_base_count(genotype_t *geno, char base); void genotype_set_base_count(genotype_t *geno, char base, int count); int genotype_get_total_base_count(genotype_t *geno); diff --git a/src/ignore_reg_access.c b/src/ignore_reg_access.c index 5bb61a6..4d7e9fb 100644 --- a/src/ignore_reg_access.c +++ b/src/ignore_reg_access.c @@ -127,7 +127,7 @@ int ignore_reg_access_get_ign_reg_for_chr(char *ign_file,char *chr, int entry_co } }else{ free(chr_nom); - sentinel("Incorrect line read from ignore file %s.",rd,1); + sentinel("Incorrect line read from ignore file %s.",rd); } free(chr_nom); } diff --git a/src/mstep.c b/src/mstep.c index f09c063..91d3555 100644 --- a/src/mstep.c +++ b/src/mstep.c @@ -78,7 +78,7 @@ void mstep_print_usage (int exit_code){ exit(exit_code); } -void mstep_setup_options(int argc, char *argv[]){ +int mstep_setup_options(int argc, char *argv[]){ const struct option long_opts[] = { {"config-file", required_argument, 0, 'f'}, @@ -106,19 +106,19 @@ void mstep_setup_options(int argc, char *argv[]){ case 'i': if(sscanf(optarg, "%i", &idx) != 1){ - sentinel("Error parsing -i argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -i argument '%s'. Should be an integer > 0",optarg); } break; case 'm': if(sscanf(optarg, "%i", &min_bq) != 1){ - sentinel("Error parsing -m argument '%s'. Should be an integer >= 0",optarg,1); + sentinel("Error parsing -m argument '%s'. Should be an integer >= 0",optarg); } break; case 'a': if(sscanf(optarg, "%i", &split_size) != 1){ - sentinel("Error parsing -a argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -a argument '%s'. Should be an integer > 0",optarg); } break; @@ -144,15 +144,16 @@ void mstep_setup_options(int argc, char *argv[]){ mstep_print_usage(1); } - return; + return 0; error: mstep_print_usage (1); - return; + return -1; } int mstep_main(int argc, char *argv[]){ - mstep_setup_options(argc,argv); + int is_err = mstep_setup_options(argc,argv); + check(is_err==0, "Error parsing options."); char *fa_file = NULL; uint64_t ********arr_check = NULL; diff --git a/src/split.c b/src/split.c index 1f8c5f0..4429917 100644 --- a/src/split.c +++ b/src/split.c @@ -73,7 +73,7 @@ void split_print_usage (int exit_code){ exit(exit_code); } -void split_setup_options(int argc, char *argv[]){ +int split_setup_options(int argc, char *argv[]){ const struct option long_opts[] = { {"config-file", required_argument, 0, 'f'}, @@ -102,13 +102,13 @@ void split_setup_options(int argc, char *argv[]){ case 'i': if(sscanf(optarg, "%i", &idx) != 1){ - sentinel("Error parsing -i argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -i argument '%s'. Should be an integer > 0",optarg); } break; case 'e': if(sscanf(optarg, "%i", &max_read_count) != 1){ - sentinel("Error parsing -e argument '%s'. Should be an integer > 0",optarg,1); + sentinel("Error parsing -e argument '%s'. Should be an integer > 0",optarg); } break; @@ -133,11 +133,11 @@ void split_setup_options(int argc, char *argv[]){ split_print_usage(1); } - return; + return 0; error: split_print_usage(1); - return; + return -1; } int round_divide_integer(int dividend, int divisor){ @@ -169,7 +169,8 @@ int split_main(int argc, char *argv[]){ seq_region_t **ignore_regs = NULL; int ignore_reg_count = 0; - split_setup_options(argc,argv); + int is_err = split_setup_options(argc,argv); + check(is_err==0,"Error parsing options"); char *chr_name = malloc(sizeof(char *)); //Open the config file and do relevant things diff --git a/tests/genotype_tests.c b/tests/genotype_tests.c index 02500c2..159e0f3 100644 --- a/tests/genotype_tests.c +++ b/tests/genotype_tests.c @@ -70,12 +70,16 @@ char *test_genotype_hard_copy_genotype_t_list(){ } char *test_genotype_add_base_to_count(){ + int chk = 0; genotype_t *geno = genotype_init_genotype(); - genotype_add_base_to_count(geno,'C'); + chk = genotype_add_base_to_count(geno,'C'); + mu_assert(chk==0, "Error adding base to genotype count."); mu_assert(geno->c_count == 1, "Incorrect count of C after first add."); - genotype_add_base_to_count(geno,'C'); + chk = genotype_add_base_to_count(geno,'C'); + mu_assert(chk==0, "Error adding base to genotype count."); mu_assert(geno->c_count == 2, "Incorrect count of C after second add."); - genotype_add_base_to_count(geno,'T'); + chk = genotype_add_base_to_count(geno,'T'); + mu_assert(chk==0, "Error adding base to genotype count."); mu_assert(geno->t_count == 1, "Incorrect count of T after third add."); mu_assert(geno->c_count == 2, "Incorrect count of C after third add."); mu_assert(geno->a_count == 0, "Incorrect count of A after third add.");