Skip to content

Commit 17b6563

Browse files
committed
Do not require -s - when there were no samples in the VCF
Also, print a notice to indicate whether what's being applied is the GTs or REF,ALT Resolves #2260
1 parent 8d62697 commit 17b6563

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Changes affecting specific commands:
3737
- Allow to apply a reference allele which overlaps a previous deletion, there is no
3838
need to complain about overlapping alleles in such case
3939

40+
- Fix a bug which required `-s -` to be present even when there were no samples in the VCF
41+
(#2260)
42+
4043
* bcftools csq
4144

4245
- Fix a rare bug where indel combined with a substitution ending at exon boundary is

consensus.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,14 @@ static void init_data(args_t *args)
229229
args->hdr = args->files->readers[0].header;
230230
args->isample = -1;
231231
if ( !args->sample )
232+
{
232233
args->smpl = smpl_ilist_init(args->hdr,NULL,0,SMPL_NONE|SMPL_VERBOSE);
234+
if ( !args->smpl->n )
235+
{
236+
smpl_ilist_destroy(args->smpl);
237+
args->smpl = NULL;
238+
}
239+
}
233240
else if ( args->sample && strcmp("-",args->sample) )
234241
{
235242
args->smpl = smpl_ilist_init(args->hdr,args->sample,0,SMPL_NONE|SMPL_VERBOSE);
@@ -244,12 +251,22 @@ static void init_data(args_t *args)
244251
{
245252
if ( args->haplotype || args->allele )
246253
{
247-
if ( args->smpl->n > 1 ) error("Too many samples, only one can be used with -H\n");
254+
if ( args->smpl->n > 1 ) error("Too many samples, only one can be used with -H; check the -s,-S options\n");
248255
args->isample = args->smpl->idx[0];
249256
}
250257
else
258+
{
251259
args->iupac_GTs = 1;
260+
if ( args->smpl->n==1 )
261+
fprintf(stderr,"Note: applying IUPAC codes based on FORMAT/GT in sample %s\n",bcf_hdr_int2id(args->hdr,BCF_DT_SAMPLE,args->smpl->idx[0]));
262+
else
263+
fprintf(stderr,"Note: applying IUPAC codes based on FORMAT/GT in %d samples\n",args->smpl->n);
264+
}
252265
}
266+
else if ( args->output_iupac )
267+
fprintf(stderr,"Note: applying IUPAC codes based on REF,ALT%s\n",bcf_hdr_nsamples(args->hdr)?", ignoring samples":"");
268+
else
269+
fprintf(stderr,"Note: applying REF,ALT variants%s\n",bcf_hdr_nsamples(args->hdr)?", ignoring samples":"");
253270
int i;
254271
for (i=0; i<args->nmask; i++)
255272
{
@@ -272,7 +289,6 @@ static void init_data(args_t *args)
272289
if ( ! args->fp_out ) error("Failed to create %s: %s\n", args->output_fname, strerror(errno));
273290
}
274291
else args->fp_out = stdout;
275-
if ( args->isample<0 && !args->iupac_GTs ) fprintf(stderr,"Note: the --samples option not given, applying all records regardless of the genotype\n");
276292
if ( args->filter_str )
277293
args->filter = filter_init(args->hdr, args->filter_str);
278294
args->rid = -1;

0 commit comments

Comments
 (0)