Skip to content

Commit 5b9262e

Browse files
author
David Jones
committed
Merge branch 'hotfix/2.4.1'
2 parents 9c528be + 5af5f10 commit 5b9262e

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 2.4.1
2+
* Modified reheadSQ to be more robust.
3+
14
### 2.1.0
25
* Adds `xam_coverage_bins.pl` which calculates fraction of targets covered at various depths (BAM/CRAM), using BED/GFF3 as target bait file.
36

c/reheadSQ.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <errno.h>
55
#include <string.h>
66

7-
#define BUF_SIZE 4096
7+
#define BUF_SIZE 8192
88

99
char *dict = NULL;
1010
char **dict_name;
@@ -161,26 +161,34 @@ int main (int argc, char* argv[]){
161161

162162
read_dict_file(dict);
163163

164-
char *line = malloc(BUF_SIZE * sizeof(char));
165-
while(gets(line)){
164+
//Read from stdin and write to stdout
165+
char *line = NULL;
166+
ssize_t read;
167+
size_t linelen = 0;
168+
169+
while((read = getline(&line,&linelen,stdin)) != -1){
166170
if(strncmp(line, "@", 1) == 0){//If we're matching a header
167171
if(strncmp(line, "@SQ" ,3)==0){//Code to replace/append to SQ lines here @SQ
168172
char *nom = get_contig_name_fromSQ_line(line);
169173
char *new = get_dict_sq_line_by_name(nom);
170174
fprintf(stdout,"%s",new);
175+
fflush(stdout);
171176
free(nom);
172177
}else{//Not a SQ header
173-
puts(line);
178+
fprintf(stdout,"%s",line);
174179
}
175180
}else{ // We're no longer matching a header
176-
puts(line);
181+
fprintf(stdout,"%s",line);
177182
break;
178183
}//End of checking for a header
179184
}
180-
while(gets(line)){
181-
puts(line);
185+
//Another loop, this time we know we're past the SQ headers so it goes straight to stdout.
186+
while((read = getline(&line,&linelen,stdin)) != -1){
187+
fprintf(stdout,"%s",line);
182188
}
189+
fflush(stdout);
183190
free(line);
191+
184192
int j=0;
185193
for(j=0;j<dict_entries;j++){
186194
free(dict_name[j]);

lib/PCAP.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use base 'Exporter';
2626
use FindBin qw($Bin);
2727
use File::Which qw(which);
2828

29-
our $VERSION = '2.4.0';
29+
our $VERSION = '2.4.1';
3030
our @EXPORT = qw($VERSION _which);
3131

3232
const my $LICENSE =>

0 commit comments

Comments
 (0)