Skip to content

Commit f4fac3c

Browse files
committed
Replace assert with an error message to help with debugging. See #1044
1 parent d61277e commit f4fac3c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vcfmerge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int info_rules_add_values(args_t *args, bcf_hdr_t *hdr, bcf1_t *line, inf
495495
else if ( var_len==BCF_VL_G )
496496
{
497497
args->maux->nagr_map = bcf_alleles2gt(line->n_allele-1,line->n_allele-1)+1;
498-
assert( ret==line->n_allele || ret==args->maux->nagr_map );
498+
if ( ret!=line->n_allele && ret!=args->maux->nagr_map ) error("Wrong number of %s fields at %s:%"PRId64"\n",rule->hdr_tag,bcf_seqname(hdr,line),(int64_t) line->pos+1);
499499
if ( ret==line->n_allele ) // haploid
500500
{
501501
args->maux->nagr_map = line->n_allele;
@@ -974,7 +974,7 @@ void merge_chrom2qual(args_t *args, bcf1_t *out)
974974
int k = 0;
975975
for (i=0; i<ma->nals; i++)
976976
if ( i==0 || al_idxs[i] ) ma->out_als[k++] = strdup(ma->als[i]);
977-
assert( k==ma->nout_als );
977+
if ( k!=ma->nout_als ) error("Error: could not merge alleles at %s:%"PRId64", sanity check failed: %d!=%d\n",bcf_seqname(out_hdr,out),out->pos+1,k,ma->nout_als);
978978
normalize_alleles(ma->out_als, ma->nout_als);
979979
bcf_update_alleles(out_hdr, out, (const char**) ma->out_als, ma->nout_als);
980980
free(al_idxs);

0 commit comments

Comments
 (0)