Skip to content

Commit 92c31be

Browse files
committed
Fix a consensus bug
which prevented reading fasta files containing empty lines Resolves #2424
1 parent 168d070 commit 92c31be

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

NEWS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
## Release a.b
22

33

4+
Changes affecting the whole of bcftools, or multiple commands:
5+
6+
* The `-i/-e` filtering expressions and `-f` formatting in `query`
7+
8+
- Add a new function `smpl_COUNT()/sCOUNT()` which returns the number of elements (#2423)
9+
410
Changes affecting specific commands:
511

12+
* bcftools consensus
13+
14+
- Fix a bug which prevented reading fasta files containing empty lines in their entirety (#2424)
15+
616
* bcftools gtcheck
717

818
- The program is now able to process gVCF blocks. Newly, monoallelic sites are excluded only

consensus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ static void consensus(args_t *args)
10931093
BGZF *fasta = bgzf_open(args->ref_fname, "r");
10941094
if ( !fasta ) error("Error reading %s\n", args->ref_fname);
10951095
kstring_t str = {0,0,0};
1096-
while ( bgzf_getline(fasta, '\n', &str) > 0 )
1096+
while ( bgzf_getline(fasta, '\n', &str) >= 0 )
10971097
{
10981098
if ( str.s[0]=='>' )
10991099
{

test/consensus.overlaps.2.fa

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
>1
2+
CGGGACAC
3+
4+
>2
5+
CGGGACAC

test/test.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@
940940
run_test(\&test_vcf_convert_tsv2vcf,$opts,in=>'convert.23andme',out=>'convert.23andme.vcf',args=>'-c ID,CHROM,POS,AA -s SAMPLE1',fai=>'23andme');
941941
run_test(\&test_vcf_convert_tsv2vcf,$opts,in=>'convert.tsv',out=>'convert.tsv.vcf',args=>'-c -,CHROM,POS,REF,ALT',fai=>'23andme');
942942
run_test(\&test_vcf_consensus,$opts,in=>'consensus.gvcf-missing.1',out=>'consensus.gvcf-missing.1.out',fa=>'consensus.gvcf-missing.fa',args=>'--missing N');
943+
run_test(\&test_vcf_consensus,$opts,in=>'consensus.overlaps.1',out=>'consensus.overlaps.1.1.out',fa=>'consensus.overlaps.2.fa',args=>'-s A');
943944
run_test(\&test_vcf_consensus,$opts,in=>'consensus.overlaps.1',out=>'consensus.overlaps.1.1.out',fa=>'consensus.overlaps.1.fa',args=>'-s A');
944945
run_test(\&test_vcf_consensus,$opts,in=>'consensus.overlaps.1',out=>'consensus.overlaps.1.2.out',fa=>'consensus.overlaps.1.fa',args=>'-s B');
945946
run_test(\&test_vcf_consensus,$opts,in=>'consensus.overlaps.1',out=>'consensus.overlaps.1.3.out',fa=>'consensus.overlaps.1.fa',args=>'-s A -a N');

0 commit comments

Comments
 (0)