Skip to content

Commit

Permalink
Propagate bam_mplp_auto() error code, throw an error on truncated bam…
Browse files Browse the repository at this point in the history
…/cram files
  • Loading branch information
pd3 committed May 24, 2024
1 parent 4ad2efd commit 57b9072
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Changes affecting specific commands:
- Fix a segfault with --no-HWE-prob. The bug was introduced with the output format change in
1.19 which replaced the DC section with DCv2 (#2180)

* bcftools mpileup

- Return non-zero error code when the input BAM/CRAM file is truncated (#2177)

* bcftools norm

- Support realignment of symbolic <DUP.*> alleles, similarly to <DEL.*> added previously
Expand Down
15 changes: 11 additions & 4 deletions mpileup.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mpileup.c -- mpileup subcommand. Previously bam_plcmd.c from samtools
Copyright (C) 2008-2023 Genome Research Ltd.
Copyright (C) 2008-2024 Genome Research Ltd.
Portions copyright (C) 2009-2012 Broad Institute.
Author: Heng Li <lh3@sanger.ac.uk>
Expand Down Expand Up @@ -612,7 +612,7 @@ static int mpileup_reg(mplp_conf_t *conf, uint32_t beg, uint32_t end)
}
}
}
return 0;
return ret;
}

static int mpileup(mplp_conf_t *conf)
Expand Down Expand Up @@ -938,6 +938,7 @@ static int mpileup(mplp_conf_t *conf)


// Run mpileup for multiple regions
int ret = 0;
if ( nregs )
{
int ireg = 0;
Expand Down Expand Up @@ -966,12 +967,18 @@ static int mpileup(mplp_conf_t *conf)
bam_mplp_reset(conf->iter);
}
}
mpileup_reg(conf,conf->reg_itr->beg,conf->reg_itr->end);
ret = mpileup_reg(conf,conf->reg_itr->beg,conf->reg_itr->end);
if ( ret<0 ) break;
}
while ( regitr_loop(conf->reg_itr) );
}
else
mpileup_reg(conf,0,UINT32_MAX);
ret = mpileup_reg(conf,0,UINT32_MAX);
if ( ret<0 )
{
fprintf(stderr, "[%s] failed to read from input file\n", __func__);
exit(EXIT_FAILURE);
}

flush_bcf_records(conf, conf->bcf_fp, conf->bcf_hdr, NULL);

Expand Down

0 comments on commit 57b9072

Please # to comment.