Skip to content

Commit f79d630

Browse files
committed
Merge branch 'develop' of github.com:samtools/bcftools into develop
2 parents 4617432 + f383f46 commit f79d630

File tree

15 files changed

+46
-28
lines changed

15 files changed

+46
-28
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Changes affecting specific commands:
2323

2424
- Fix a bug which prevented reading fasta files containing empty lines in their entirety (#2424)
2525

26+
- Fix a bug which causes `--absent` miss some absent positions
27+
2628
* bcftools csq
2729

2830
- Add support for complex substitutions, such as AC>TAA

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ Please cite this paper when using BCFtools for your publications. http://samtool
4141
eprint = {https://academic.oup.com/gigascience/article-pdf/10/2/giab008/36332246/giab008.pdf},
4242
}
4343
```
44+
45+
### Support
46+
47+
If you have found a bug or would like a new feature, please report the same in the GitHub [BCFtools](https://github.com/samtools/bcftools/issues) issue tracker.
48+
49+
For any security related issue, please send a mail to [[email protected]](mailto:[email protected]) instead of reporting in the GitHub issue tracker.

consensus.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static void flush_fa_buffer(args_t *args, int len)
430430
{
431431
if ( !args->fa_buf.l ) return;
432432
int nwr = 0;
433-
while ( nwr + 60 <= args->fa_buf.l )
433+
while ( nwr + 60 <= args->fa_buf.l && (!len || args->fa_ori_pos + nwr + 60 < args->fa_frz_pos) )
434434
{
435435
if ( fwrite(args->fa_buf.s+nwr,1,60,args->fp_out) != 60 ) error("Could not write: %s\n", args->output_fname);
436436
if ( fwrite("\n",1,1,args->fp_out) != 1 ) error("Could not write: %s\n", args->output_fname);
@@ -462,7 +462,9 @@ static void flush_fa_buffer(args_t *args, int len)
462462
}
463463
static void apply_absent(args_t *args, hts_pos_t pos)
464464
{
465-
if ( !args->fa_buf.l || pos <= args->fa_frz_pos + 1 || pos <= args->fa_ori_pos ) return;
465+
if ( !args->fa_buf.l ) return;
466+
if ( pos <= args->fa_frz_pos + 1 ) return; // if pos==frz+1, then there is no gap, ie=ib, nothing to fill
467+
if ( pos <= args->fa_ori_pos ) return;
466468

467469
int ie = pos && pos - args->fa_ori_pos + args->fa_mod_off < args->fa_buf.l ? pos - args->fa_ori_pos + args->fa_mod_off : args->fa_buf.l;
468470
int ib = args->fa_frz_mod < 0 ? 0 : args->fa_frz_mod;
@@ -585,7 +587,6 @@ static int iupac_set_allele(args_t *args, bcf1_t *rec)
585587
static void apply_variant(args_t *args, bcf1_t *rec)
586588
{
587589
static int warned_haplotype = 0;
588-
589590
if ( args->absent_allele ) apply_absent(args, rec->pos);
590591
if ( rec->n_allele==1 && !args->missing_allele && !args->absent_allele ) { return; }
591592

csq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,9 +3182,9 @@ int test_cds(args_t *args, bcf1_t *rec, vbuf_t *vbuf)
31823182
for (ismpl=0; ismpl<args->smpl->n; ismpl++)
31833183
{
31843184
int32_t *gt = args->gt_arr + args->smpl->idx[ismpl]*ngts;
3185-
if ( gt[0]==bcf_gt_missing ) continue;
3185+
if ( bcf_gt_is_missing(gt[0]) ) continue;
31863186

3187-
if ( ngts>1 && gt[1]!=bcf_gt_missing && gt[1]!=bcf_int32_vector_end && bcf_gt_allele(gt[0])!=bcf_gt_allele(gt[1]) )
3187+
if ( ngts>1 && !bcf_gt_is_missing(gt[1]) && gt[1]!=bcf_int32_vector_end && bcf_gt_allele(gt[0])!=bcf_gt_allele(gt[1]) )
31883188
{
31893189
if ( args->phase==PHASE_MERGE )
31903190
{
@@ -3206,7 +3206,7 @@ int test_cds(args_t *args, bcf1_t *rec, vbuf_t *vbuf)
32063206

32073207
for (ihap=0; ihap<ngts; ihap++)
32083208
{
3209-
if ( gt[ihap]==bcf_gt_missing || gt[ihap]==bcf_int32_vector_end ) continue;
3209+
if ( bcf_gt_is_missing(gt[ihap]) || gt[ihap]==bcf_int32_vector_end ) continue;
32103210

32113211
i = 2*ismpl + ihap;
32123212

@@ -3311,7 +3311,7 @@ void csq_stage(args_t *args, csq_t *csq, bcf1_t *rec)
33113311
int32_t *gt = args->gt_arr + args->smpl->idx[i]*ngt;
33123312
for (j=0; j<ngt; j++)
33133313
{
3314-
if ( gt[j]==bcf_gt_missing || gt[j]==bcf_int32_vector_end ) continue;
3314+
if ( bcf_gt_is_missing(gt[j]) || gt[j]==bcf_int32_vector_end ) continue;
33153315
int ial = bcf_gt_allele(gt[j]);
33163316
if ( !ial || ial!=csq->type.vcf_ial ) continue;
33173317
csq_print_text(args, csq, args->smpl->idx[i],j+1);
@@ -3326,7 +3326,7 @@ void csq_stage(args_t *args, csq_t *csq, bcf1_t *rec)
33263326
int32_t *gt = args->gt_arr + args->smpl->idx[i]*ngt;
33273327
for (j=0; j<ngt; j++)
33283328
{
3329-
if ( gt[j]==bcf_gt_missing || gt[j]==bcf_int32_vector_end ) continue;
3329+
if ( bcf_gt_is_missing(gt[j]) || gt[j]==bcf_int32_vector_end ) continue;
33303330
int ial = bcf_gt_allele(gt[j]);
33313331
if ( !ial || ial!=csq->type.vcf_ial ) continue;
33323332

doc/bcftools.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,17 @@ Add or remove annotations.
356356

357357
*-c, --columns* 'list'::
358358
Comma-separated list of columns or tags to carry over from the annotation file
359-
(see also *-a, --annotations*). If the annotation file is not a VCF/BCF,
359+
(see also *-a, --annotations*).
360+
{nbsp} +
361+
{nbsp} +
362+
*If the annotation file is not a VCF/BCF*,
360363
'list' describes the columns of the annotation file and must include CHROM,
361364
POS (or, alternatively, FROM,TO or BEG,END), and optionally REF and ALT. Unused
362365
columns which should be ignored can be indicated by "-".
363366
{nbsp} +
364367
{nbsp} +
365-
If the annotation file is a VCF/BCF, only the edited columns/tags must be present and their
366-
order does not matter. The columns ID, QUAL, FILTER, INFO and FORMAT
368+
*If the annotation file is a VCF/BCF*, only the edited columns/tags must be present
369+
(i.e. leave out CHROM, POS, REF, ALT) and their order does not matter. The columns ID, QUAL, FILTER, INFO and FORMAT
367370
can be edited, where INFO tags can be written both as "INFO/TAG" or simply "TAG",
368371
and FORMAT tags can be written as "FORMAT/TAG" or "FMT/TAG".
369372
The imported VCF annotations can be renamed as "DST_TAG:=SRC_TAG" or "FMT/DST_TAG:=FMT/SRC_TAG".

filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,6 @@ static void filters_set_alt_string(filter_t *flt, bcf1_t *line, token_t *tok)
13681368
}
13691369
static void filters_set_nmissing(filter_t *flt, bcf1_t *line, token_t *tok)
13701370
{
1371-
if ( !tok->nsamples ) error("The function %s works with FORMAT fields\n", tok->tag);
13721371
assert(tok->usmpl);
13731372

13741373
bcf_unpack(line, BCF_UN_FMT);
@@ -1400,7 +1399,7 @@ static void filters_set_nmissing(filter_t *flt, bcf1_t *line, token_t *tok)
14001399
{ \
14011400
type_t val = convert(&ptr[j * sizeof(type_t)]); \
14021401
if ( val==is_vector_end ) break; \
1403-
if ( val==bcf_gt_missing ) { nmissing++; break; } \
1402+
if ( bcf_gt_is_missing(val) ) { nmissing++; break; } \
14041403
} \
14051404
} \
14061405
}
@@ -1411,7 +1410,8 @@ static void filters_set_nmissing(filter_t *flt, bcf1_t *line, token_t *tok)
14111410
default: fprintf(stderr,"todo: type %d\n", fmt->type); exit(1); break;
14121411
}
14131412
#undef BRANCH
1414-
tok->nvalues = 1;
1413+
tok->nsamples = 0;
1414+
tok->nvalues = 1;
14151415
tok->values[0] = tok->tag[0]=='N' ? nmissing : (nsmpl ? (double)nmissing / nsmpl : 0);
14161416
}
14171417
static int func_npass(filter_t *flt, bcf1_t *line, token_t *rtok, token_t **stack, int nstack)

plugins/check-sparsity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void test_region(args_t *args, char *reg)
206206
int8_t *ptr = (int8_t*) (fmt_gt->p + args->smpl[i]*fmt_gt->size);
207207
int ial = 0;
208208
for (ial=0; ial<fmt_gt->n; ial++)
209-
if ( ptr[ial]==bcf_gt_missing || ptr[ial]==bcf_int8_vector_end ) break;
209+
if ( bcf_gt_is_missing(ptr[ial]) || ptr[ial]==bcf_int8_vector_end ) break;
210210
if ( ial==0 ) continue; // missing
211211
if ( ++args->nsites[i] < args->min_sites ) continue;
212212
if ( i+1<args->nsmpl )

plugins/guess-ploidy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void process_region_guess(args_t *args)
167167
int32_t *ptr = args->arr + ismpl*ngt;
168168
double *tmp = args->tmpf + ismpl*3;
169169

170-
if ( ptr[0]==bcf_gt_missing )
170+
if ( bcf_gt_is_missing(ptr[0]) )
171171
{
172172
tmp[0] = -1;
173173
continue;

plugins/mendelian2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,12 @@ static int parse_gt(int32_t *gt, int ngt, uint64_t *a, uint64_t *b)
566566
{
567567
*a = *b = 0;
568568

569-
if ( gt[0]==bcf_gt_missing || gt[0]==bcf_int32_vector_end ) return 0;
569+
if ( bcf_gt_is_missing(gt[0]) || gt[0]==bcf_int32_vector_end ) return 0;
570570
*a |= 1<<bcf_gt_allele(gt[0]);
571571

572572
if ( ngt==1 || gt[1]==bcf_int32_vector_end ) return 1;
573573

574-
if ( gt[1]==bcf_gt_missing ) return 0;
574+
if ( bcf_gt_is_missing(gt[1]) ) return 0;
575575
*b |= 1<<bcf_gt_allele(gt[1]);
576576

577577
return 2;

plugins/missing2ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bcf1_t *process(bcf1_t *rec)
121121
// replace gts
122122
for (i=0; i<ngts; i++)
123123
{
124-
if ( gts[i]==bcf_gt_missing )
124+
if ( bcf_gt_is_missing(gts[i]) )
125125
{
126126
gts[i] = new_gt;
127127
changed++;

0 commit comments

Comments
 (0)