From e54049ce2270b919edc822cbd4e3b216f55b3016 Mon Sep 17 00:00:00 2001 From: David Jones Date: Thu, 11 Apr 2019 15:16:17 +0100 Subject: [PATCH 1/4] CHANGES updated and version --- CHANGES.md | 4 ++++ Makefile | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 05fcd01..9833e82 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # CHANGES +## 1.13.15 + +* Add checks to sam_hts_iter to ensure result is checked for errors + ## 1.13.14 * Fix array length index, check loop length and error messages related to 1.13.13. diff --git a/Makefile b/Makefile index b40091c..42279aa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CAVEMAN_VERSION=1.13.14 +CAVEMAN_VERSION=1.13.15 TEST_REF?="" #Compiler From 7841ebd178e839aeae6aceb1eaae1281f3c94a07 Mon Sep 17 00:00:00 2001 From: David Jones Date: Thu, 11 Apr 2019 15:19:10 +0100 Subject: [PATCH 2/4] bam_access.c updated with checks for failures in hts_sam_iter --- src/bam_access.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bam_access.c b/src/bam_access.c index 074281c..a306e9a 100644 --- a/src/bam_access.c +++ b/src/bam_access.c @@ -1243,7 +1243,7 @@ List *bam_access_get_sorted_reads_at_this_pos(char *chr_name, uint32_t start, ui } }//End of while iterator to populate pileup - + check(result >= -1, "Error detected (%d) when trying to iterate through region.",result); sam_itr_destroy(iter); bam_plp_push(buf,0); // finalize pileup @@ -1336,6 +1336,10 @@ int bam_access_get_count_with_bam(char *chr_name, uint32_t start, uint32_t stop, counter++; }//End of iteration through reads in this region + if(result < -1){ + sentinel("Error detected (%d) when trying to iterate through region.",result); + } + sam_itr_destroy(iter); bam_destroy1(b); free(region); From 8507c2b133493b10577d1e2304d2e82f833e8161 Mon Sep 17 00:00:00 2001 From: David Jones Date: Thu, 11 Apr 2019 16:44:09 +0100 Subject: [PATCH 3/4] More sam_itr_next status checking in split.c --- CHANGES.md | 2 +- src/split.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 9833e82..8948f7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## 1.13.15 -* Add checks to sam_hts_iter to ensure result is checked for errors +* Add checks to sam_iter_next to ensure result is checked for errors ## 1.13.14 diff --git a/src/split.c b/src/split.c index 4429917..2d91828 100644 --- a/src/split.c +++ b/src/split.c @@ -278,6 +278,7 @@ int split_main(int argc, char *argv[]){ while(curr_n_pos<=curr_t_pos && iter_n_status>=0 && iter_t_status>=0 && rd_count<=max_read_count){ //While the positions aren't equal and tumour has reads left. Normal jumps ahead iter_n_status = sam_itr_next(sf_norm,iter_norm,norm_read); + check(iter_n_status>=-1,"Error detected (%d) when trying to iterate through region.",iter_n_status); curr_n_pos = norm_read->core.pos; if(iter_n_status>=0 && bam_access_check_bam_flags(norm_read) == 1 && ignore_reg_access_get_ign_reg_overlap(curr_n_pos,ignore_regs,ignore_reg_count) == NULL){ rd_count++; @@ -286,6 +287,7 @@ int split_main(int argc, char *argv[]){ while(curr_t_pos<=curr_n_pos && iter_t_status>=0 && iter_n_status>=0){ //While the positions aren't equal and normal has reads left iter_t_status = sam_itr_next(sf_tum,iter_tum,tum_read); + check(iter_t_status>=-1,"Error detected (%d) when trying to iterate through region.",iter_t_status); curr_t_pos = tum_read->core.pos; if(iter_t_status>=0 && bam_access_check_bam_flags(tum_read) == 1 && ignore_reg_access_get_ign_reg_overlap(curr_t_pos,ignore_regs,ignore_reg_count) == NULL){ rd_count++; @@ -296,6 +298,7 @@ int split_main(int argc, char *argv[]){ if(iter_n_status<0 && iter_t_status>=0){ //No more normal reads while(iter_t_status>=0 && rd_count<=max_read_count){ iter_t_status = sam_itr_next(sf_tum,iter_tum,tum_read); + check(iter_t_status>=-1,"Error detected (%d) when trying to iterate through region.",iter_t_status); curr_t_pos = tum_read->core.pos; if(iter_t_status>=0 && bam_access_check_bam_flags(tum_read) == 1 && ignore_reg_access_get_ign_reg_overlap(curr_t_pos,ignore_regs,ignore_reg_count) == NULL){ rd_count++; @@ -306,6 +309,7 @@ int split_main(int argc, char *argv[]){ if(iter_t_status<0 && iter_n_status>=0){ //No more tumour reads while(iter_n_status>=0 && rd_count<=max_read_count){ iter_n_status = sam_itr_next(sf_norm,iter_norm,norm_read); + check(iter_n_status>=-1,"Error detected (%d) when trying to iterate through region.",iter_n_status); curr_n_pos = norm_read->core.pos; if(iter_n_status>=0 && bam_access_check_bam_flags(norm_read) == 1 && ignore_reg_access_get_ign_reg_overlap(curr_n_pos,ignore_regs,ignore_reg_count) == NULL){ rd_count++; From e5e5d807c1397bd2f7edbc0f94ea223dcbb747d9 Mon Sep 17 00:00:00 2001 From: David Jones Date: Fri, 12 Apr 2019 14:16:36 +0100 Subject: [PATCH 4/4] Convert sentinel to check and ensure error thrown where only a print statment was present --- src/bam_access.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/bam_access.c b/src/bam_access.c index a306e9a..759461f 100644 --- a/src/bam_access.c +++ b/src/bam_access.c @@ -408,9 +408,7 @@ file_holder *bam_access_get_by_position_counts_stranded(char *norm_file, char *c check(res==0,"Error running pileup callback"); }//End of while we have pileup reads } - if(result != -1){ - fprintf(stderr,"SAMTOOLS ERROR %d\n",result); - } + check(result >= -1, "Error detected (%d) when trying to iterate through region.",result); bam_plp_push(buf,0); // finalize pileup sam_itr_destroy(iter); //Now for the pileup method @@ -1336,14 +1334,17 @@ int bam_access_get_count_with_bam(char *chr_name, uint32_t start, uint32_t stop, counter++; }//End of iteration through reads in this region - if(result < -1){ - sentinel("Error detected (%d) when trying to iterate through region.",result); - } - + check(result >= -1, "Error detected (%d) when trying to iterate through region.",result); sam_itr_destroy(iter); bam_destroy1(b); free(region); return counter; + +error: + if(iter) sam_itr_destroy(iter); + if(b) bam_destroy1(b); + if(region) free(region); + return -1; } void bam_access_include_sw(int inc){