Skip to content

Commit

Permalink
Do not require -s - when there were no samples in the VCF
Browse files Browse the repository at this point in the history
Also, print a notice to indicate whether what's being applied is the GTs or REF,ALT

Resolves #2260
  • Loading branch information
pd3 committed Sep 9, 2024
1 parent 8d62697 commit 17b6563
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Changes affecting specific commands:
- Allow to apply a reference allele which overlaps a previous deletion, there is no
need to complain about overlapping alleles in such case

- Fix a bug which required `-s -` to be present even when there were no samples in the VCF
(#2260)

* bcftools csq

- Fix a rare bug where indel combined with a substitution ending at exon boundary is
Expand Down
20 changes: 18 additions & 2 deletions consensus.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,14 @@ static void init_data(args_t *args)
args->hdr = args->files->readers[0].header;
args->isample = -1;
if ( !args->sample )
{
args->smpl = smpl_ilist_init(args->hdr,NULL,0,SMPL_NONE|SMPL_VERBOSE);
if ( !args->smpl->n )
{
smpl_ilist_destroy(args->smpl);
args->smpl = NULL;
}
}
else if ( args->sample && strcmp("-",args->sample) )
{
args->smpl = smpl_ilist_init(args->hdr,args->sample,0,SMPL_NONE|SMPL_VERBOSE);
Expand All @@ -244,12 +251,22 @@ static void init_data(args_t *args)
{
if ( args->haplotype || args->allele )
{
if ( args->smpl->n > 1 ) error("Too many samples, only one can be used with -H\n");
if ( args->smpl->n > 1 ) error("Too many samples, only one can be used with -H; check the -s,-S options\n");
args->isample = args->smpl->idx[0];
}
else
{
args->iupac_GTs = 1;
if ( args->smpl->n==1 )
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]));
else
fprintf(stderr,"Note: applying IUPAC codes based on FORMAT/GT in %d samples\n",args->smpl->n);
}
}
else if ( args->output_iupac )
fprintf(stderr,"Note: applying IUPAC codes based on REF,ALT%s\n",bcf_hdr_nsamples(args->hdr)?", ignoring samples":"");
else
fprintf(stderr,"Note: applying REF,ALT variants%s\n",bcf_hdr_nsamples(args->hdr)?", ignoring samples":"");
int i;
for (i=0; i<args->nmask; i++)
{
Expand All @@ -272,7 +289,6 @@ static void init_data(args_t *args)
if ( ! args->fp_out ) error("Failed to create %s: %s\n", args->output_fname, strerror(errno));
}
else args->fp_out = stdout;
if ( args->isample<0 && !args->iupac_GTs ) fprintf(stderr,"Note: the --samples option not given, applying all records regardless of the genotype\n");
if ( args->filter_str )
args->filter = filter_init(args->hdr, args->filter_str);
args->rid = -1;
Expand Down

0 comments on commit 17b6563

Please sign in to comment.