Skip to content

Commit

Permalink
Merge branch 'hotfix/0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Jones committed Apr 3, 2017
2 parents 789bce0 + ef836f6 commit 7b24543
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.4.1
* Modified parsing of regions to enable names with : in (i.e. GRCh38)

### 0.4.1
* Updated libBigWig to 0.3.1 - fixes issue with overflow in very large zoom levels

Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.1
0.4.2
2 changes: 1 addition & 1 deletion c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ make_BW=../bin/makebw

.NOTPARALLEL: test

all: clean pre make_htslib_tmp $(BAM2BG_TARGET) $(BAM2BW_TARGET) $(BAM2BASES_TARGET) remove_htslib_tmp $(JOIN_TARGET) $(CAT_TARGET) $(BG2BW_TARGET) $(DEXDEPTH_TARGET) test
all: clean pre make_htslib_tmp $(BAM2BG_TARGET) $(BAM2BW_TARGET) $(BAM2BASES_TARGET) $(JOIN_TARGET) $(CAT_TARGET) $(BG2BW_TARGET) $(DEXDEPTH_TARGET) remove_htslib_tmp test
@echo bwcat, bwjoin, bam2bedgraph, bam2bw, detectExtremeDepth and bam2bwbases compiled.

$(CAT_TARGET): $(OBJS)
Expand Down
13 changes: 1 addition & 12 deletions c/bam2bw.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,6 @@ bigWigFile_t *initialise_bw_output(char *out_file, chromList_t *chromList){
return NULL;
}

char *get_contig_from_region(char *region){
int beg = 0;
int end = 0;
const char *q = hts_parse_reg(region, &beg, &end);
char *tmp = (char*)malloc(q - region + 1);
strncpy(tmp, region, q - region);
tmp[q - region] = 0;
return tmp;
}

uint32_t getContigLength(char *contig,chromList_t *chromList){
int i=0;
for(i=0;i<chromList->nKeys;i++){
Expand Down Expand Up @@ -351,8 +341,7 @@ int main(int argc, char *argv[]){
if(include_zeroes == 1){
uint32_t reg_start;
uint32_t reg_stop;
char *contig = malloc(sizeof(char) * 2048);
parseRegionString(our_region_list[i], contig, &reg_start, &reg_stop);
char *contig = parseRegionString(our_region_list[i], &reg_start, &reg_stop);
uint32_t len = getContigLength(contig,chromList);
check(len != -1,"Error fetching length of contig %s.",contig);
//Append end of chromosome if zeroes
Expand Down
5 changes: 3 additions & 2 deletions c/bam2bwbases.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ int main(int argc, char *argv[]){
int chck = 0;
uint32_t sta;
uint32_t sto;
char *contig = malloc(sizeof(char) * 2048);
char *contig;
int i=0;
for(i=0;i<no_of_regions;i++){
parseRegionString(our_region_list[i], contig, &sta, &sto);
contig = parseRegionString(our_region_list[i], &sta, &sto);
int k=0;
for(k=0;k<4;k++){
perbase[k].reg_start = sta;
Expand All @@ -375,6 +375,7 @@ int main(int argc, char *argv[]){
check(chck==0,"Error adding region to bw '%s:%"PRIu32"-%"PRIu32"\t%f'. TID: %d\tErrno: %d",perbase[b].head->target_name[perbase[b].ltid],start,stop,result,perbase[b].ltid,chck);
}
}
free(contig);
bam_hdr_destroy(perbase[0].head);
}

Expand Down
6 changes: 2 additions & 4 deletions c/bam_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ int process_bam_region_bases(char *input_file, bw_func_reg perbase_pileup_func,
uint32_t last_pos = 0;
uint32_t start;
uint32_t stop;
char *contig = malloc(sizeof(char) * 2048);
parseRegionString(region, contig, &start, &stop);
char *contig = parseRegionString(region, &start, &stop);
int x=0;
for(x=0;x<4;x++){
perbase[x].idx = idx;
Expand Down Expand Up @@ -338,8 +337,7 @@ int process_bam_region(char *input_file, bw_func_reg pileup_func, tmpstruct_t *t
uint32_t last_pos = 0;
uint32_t reg_sta;
uint32_t reg_sto;
char *contig = malloc(sizeof(char) * 2048);
parseRegionString(region, contig, &reg_sta, &reg_sto);
char *contig = parseRegionString(region, &reg_sta, &reg_sto);
if(reg_sta>1){
tmp->lstart=reg_sta-1;
tmp->lpos=reg_sta-1;
Expand Down
11 changes: 7 additions & 4 deletions c/catbw.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ int main(int argc, char *argv[]){

if(region!=NULL){
//Check and parse region
char contig[1024]= "";
uint32_t start,stop;
int chk = parseRegionString(region,contig,&start,&stop);
check(chk>0,"Error parsing region string '%s'",region);
uint32_t start = 0;
uint32_t stop = 0;
char *contig = NULL;
contig = parseRegionString(region,&start,&stop);
check(contig!=NULL,"Error parsing region string '%s'",region);
//retrieve region intervals
//intervals = bwGetValues(fp, contig, start, stop, inc_na);
intervals = bwGetOverlappingIntervals(fp, contig, start-1, stop);
Expand All @@ -149,10 +150,12 @@ int main(int argc, char *argv[]){
uint32_t j=0;
for(j=0;j<intervals->l;j++){
//print interval
fprintf(stderr,"***INTERVAL****\t%s:%d-%d\n",contig,(intervals->start)[j],(intervals->end)[j]);
fprintf(out,out_pattern,contig,(intervals->start)[j],(intervals->end)[j],(intervals->value)[j]);
}
bwDestroyOverlappingIntervals(intervals);
}
free(contig);
}else{
//No region so iterate through each contig listed in the header file
//Read in the list of chromosomes
Expand Down
12 changes: 8 additions & 4 deletions c/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <stdlib.h>
#include <alloca.h>
#include <inttypes.h>
#include "htslib/sam.h"
#include "utils.h"


Expand Down Expand Up @@ -98,8 +99,11 @@ int line_count (char *file_path){
return -1;
}

int parseRegionString(char *region, char *contig, uint32_t *start, uint32_t *stop){
int check_parse = sscanf(region,region_format,contig,start,stop);
if(check_parse != 3) return 0;
return check_parse;
int parseRegionString(char *region, uint32_t *start, uint32_t *stop){
const char *q = hts_parse_reg(region, start, stop);
char *contig = (char*)malloc(q - region + 1);
strncpy(contig, region, q - region);
contig[q - region] = 0;
*start = *start+1;
return contig;
}
2 changes: 1 addition & 1 deletion c/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ int check_exist(char *fname);

int parse_file_name( char *dir, char *fname, const char *file);

int parseRegionString(char *region, char *contig, uint32_t *start, uint32_t *stop);
int parseRegionString(char *region, uint32_t *start, uint32_t *stop);

#endif

0 comments on commit 7b24543

Please sign in to comment.