Skip to content

Commit

Permalink
Merge branch 'hotfix/1.13.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Jones committed Sep 7, 2018
2 parents 6bba096 + 9669fc5 commit b6b09ca
Show file tree
Hide file tree
Showing 41 changed files with 116 additions and 48 deletions.
9 changes: 8 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# CHANGES

## 1.13.3

* Add gzbuffer call after gzopen to ensure we don't hit the limit where many contigs are printed
* Added unit test for additional methods
* Fixes #77
* Update license dates

## 1.13.2

* Futher fixes for `sentinel` calls.
* * Correct versin of REQUIRED_MIN_LIBZ as we are looking for greater than.
* Correct version of REQUIRED_MIN_LIBZ as we are looking for greater than.

## 1.13.1

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CAVEMAN_VERSION=1.13.2
CAVEMAN_VERSION=1.13.3
TEST_REF?=""
#Compiler
CC?=gcc
Expand Down
2 changes: 1 addition & 1 deletion src/List.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/List.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/List_algos.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/List_algos.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/alg_bean.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/alg_bean.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/algos.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/algos.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/bam_access.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/caveman.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/cn_access.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/cn_access.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/config_file_access.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/config_file_access.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/covs_access.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/covs_access.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
31 changes: 25 additions & 6 deletions src/estep.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down Expand Up @@ -47,6 +47,7 @@
#include <output.h>
#include <fai_access.h>
#include <algos.h>
#include <inttypes.h>
#include <config_file_access.h>

static char tum_bam_file[512];// = NULL;
Expand Down Expand Up @@ -88,6 +89,8 @@ static char *species = NULL;
static char *norm_prot = "WGS";
static char *tum_prot = "WGS";
static int max_copy_number = 10;
static uint32_t default_zbuffer = 1024*1024;
static char *contig_str = "##contig=<ID=,length=,assembly=,species=>\n";
char *valid_protocols[3] = {"WGS","WXS","RNA"};

void estep_print_usage (int exit_code){
Expand Down Expand Up @@ -403,9 +406,9 @@ int estep_main(int argc, char *argv[]){

//Load in probability array
prob_arr = covs_access_read_probs_from_file(probs_file,
List_count(alg->read_order),List_count(alg->strand),List_count(alg->lane),
List_count(alg->rd_pos),List_count(alg->map_qual),List_count(alg->base_qual),
List_count(alg->ref_base),List_count(alg->call_base));
List_count(alg->read_order),List_count(alg->strand),List_count(alg->lane),
List_count(alg->rd_pos),List_count(alg->map_qual),List_count(alg->base_qual),
List_count(alg->ref_base),List_count(alg->call_base));

//Set the algorithm modifiers and open the bam files
//Set the min base qual in case it's been changed.
Expand Down Expand Up @@ -510,15 +513,29 @@ int estep_main(int argc, char *argv[]){
check(chk>0,"Error generating debug file location.");

//Open files for output
uint32_t no_contigs = 0;
uint32_t total_contigs_length = 0;
int res_contig_cnt = fai_access_get_count_length_all_contigs(fa_file, &no_contigs, &total_contigs_length);
check(res_contig_cnt==0, "Error establishing contig count and name length.");

uint64_t buf_sz = (no_contigs * (strlen(contig_str) + strlen(assembly) + strlen(species) + 20 )) + total_contigs_length;
if (buf_sz < default_zbuffer){
buf_sz = default_zbuffer;
}

mut_file = gzopen(mut_out,"wb1");
check(mut_file != 0, "Error trying to open mut file for output: %s.",mut_out);
int buf_res = gzbuffer(mut_file, buf_sz);
check(mut_file!=0, "Error trying to open mut file for output: %s.",mut_out);
check(buf_res!=-1, "Error setting gzbuffer for file %s size to (%"PRIu32")", mut_out, buf_sz);
int chk_write = output_vcf_header(mut_file, tum_bam_file, norm_bam_file, fa_file,
assembly, species, norm_prot, tum_prot,
norm_plat, tum_plat);
check(chk_write==0,"Error writing header to muts file.");

snp_file = gzopen(snp_out,"wb1");
check(snp_file != 0, "Error trying to open snp file for output: %s.",snp_out);
buf_res = gzbuffer(snp_file, buf_sz);
check(snp_file!=0, "Error trying to open snp file for output: %s.",snp_out);
check(buf_res!=-1, "Error setting gzbuffer for file %s size to (%"PRIu32")", snp_out, buf_sz);
chk_write = output_vcf_header(snp_file, tum_bam_file, norm_bam_file, fa_file,
assembly, species, norm_prot, tum_prot,
norm_plat, tum_plat);
Expand All @@ -527,7 +544,9 @@ int estep_main(int argc, char *argv[]){

if(debug == 1){
debug_file = gzopen(debug_out,"wb1");
buf_res = gzbuffer(debug_file, buf_sz);
check(debug_file != 0, "Error trying to open snp file for output: %s.",debug_out);
check(buf_res != -1, "Error setting gzbuffer for file %s size to (%"PRIu32")", debug_out, buf_sz);
chk_write = output_vcf_header(debug_file, tum_bam_file, norm_bam_file, fa_file,
assembly, species, norm_prot, tum_prot,
norm_plat, tum_plat);
Expand Down
2 changes: 1 addition & 1 deletion src/estep.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
36 changes: 33 additions & 3 deletions src/fai_access.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down Expand Up @@ -45,8 +45,8 @@ int fai_access_get_name_from_index(int idx, char *index_file_name, char *chr_nam
check(fai != NULL,"Invalid line read\n");
//read each chromosome until we have reached the index.
int i=0;
char rd[200];
while(fgets(rd, 200, fai) != NULL){
char rd[1000];
while(fgets(rd, 1000, fai) != NULL){
check(rd != NULL,"Invalid line read\n");
i++;
if(i == idx){
Expand All @@ -64,6 +64,36 @@ int fai_access_get_name_from_index(int idx, char *index_file_name, char *chr_nam
return -1;
}

int fai_access_get_count_length_all_contigs(char *fa_loc, int *count, int *total_len){
char *chr_name = NULL;
int length = 0;
assert(fa_loc != NULL);
//Open fai file
chr_name = malloc(sizeof(char *));
FILE *fai = fopen(fa_loc, "r");
check(fai != NULL,"Invalid line read\n");
//read each chromosome
*count = 0;
*total_len = 0;
char rd[1000];
while(fgets(rd, 1000, fai) != NULL){
check(rd != NULL,"Invalid line read\n");
*count = *count+1;
fprintf(stderr,"********** %s\n", rd);
int chk = sscanf(rd,"%s\t%d\t%*d\t%*d\t%*d",chr_name,&length);
check(chk == 2,"Wrong number of entries (%d) found in fasta index file line %s",chk,rd);
*total_len += strlen(chr_name);
}
free (chr_name);
//close file
check(fclose(fai)==0,"Error closing fai file.");
return 0;
error:
if(fai) fclose(fai);
if(chr_name) free(chr_name);
return -1;
}

char *fai_access_get_ref_seqeuence_for_pos(char *fa_loc,char *char_nom,int start_one_based,int stop){
assert(char_nom !=NULL);
assert(fa_loc != NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/fai_access.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down Expand Up @@ -37,6 +37,7 @@
#include "htslib/faidx.h"

int fai_access_get_name_from_index(int idx, char *index_file_name, char *chr_name, int *length);
int fai_access_get_count_length_all_contigs(char *fa_loc, int *count, int *total_len);
char *fai_access_get_ref_seqeuence_for_pos(char *fai_loc,char *char_nom,int start_one_based,int stop);

#endif
2 changes: 1 addition & 1 deletion src/file_tests.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/file_tests.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/generateCavemanVCFUnmatchedNormalPanel.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/genotype.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/genotype.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/ignore_reg_access.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/ignore_reg_access.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/merge.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/merge.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/mstep.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/mstep.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/output.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/output.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/setup.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
2 changes: 1 addition & 1 deletion src/setup.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** LICENSE
* Copyright (c) 2014-2015 Genome Research Ltd.
* Copyright (c) 2014-2018 Genome Research Ltd.
*
* Author: Cancer Genome Project [email protected]
*
Expand Down
Loading

0 comments on commit b6b09ca

Please sign in to comment.