Question: "[E::bgzf_read] Read block operation failed" error - possible truncation/corruption of BAM file
0
gravatar for gordo2b
16 months ago by
gordo2b0
gordo2b0 wrote:

Hey!

I am trying to run velocyto on my BAM file, however I was getting some errors that implied a truncation or corruption of the BAM file. I tested that this wasn't velocyto related by running samtools index on the file, which achieved a highly similar error (below), so it's most likely the file itself which is the problem.

samtools index WT_UT_possorted_genome_bam.bam 
[E::bgzf_uncompress] Inflate operation failed: progress temporarily not possible, or in() / out() returned an error
[E::bgzf_read] Read block operation failed with error 1 after 0 of 4 bytes
samtools index: failed to create index for "WT_UT_possorted_genome_bam.bam"

I've tried some suggested approaches for checking the state of my BAM including samtools quickcheck -v (seems fine) and manually checking for the correct BAM footer (matches what it should look like):

tail -c 28 WT_UT_possorted_genome_bam.bam | hexdump -C
00000000  1f 8b 08 04 00 00 00 00  00 ff 06 00 42 43 02 00  |............BC..|
00000010  1b 00 03 00 00 00 00 00  00 00 00 00              |............|
0000001c

I would ask is the file definitely corrupted, and if not is there any way to check further or fix the file?

Poster suggested solutions:

samtools quickcheck -qvvv WT_UT_possorted_genome_bam.bam 
verbosity set to 3
checking WT_UT_possorted_genome_bam.bam
opened WT_UT_possorted_genome_bam.bam
WT_UT_possorted_genome_bam.bam is sequence data
WT_UT_possorted_genome_bam.bam has 66 targets in header.
WT_UT_possorted_genome_bam.bam has good EOF block.

Just displaying command and error content (several lines of BAM output follow this error):

samtools view WT_UT_possorted_genome_bam.bam | tail
[E::bgzf_uncompress] Inflate operation failed: progress temporarily not possible, or in() / out() returned an error
[E::bgzf_read] Read block operation failed with error 1 after 0 of 4 bytes
[main_samview] truncated file.
samtools • 2.8k views
ADD COMMENTlink modified 16 months ago • written 16 months ago by gordo2b0

Run samtools quickcheck -qvvv your.bam.

ADD REPLYlink written 16 months ago by ATpoint46k

Added to post, looks good

ADD REPLYlink written 16 months ago by gordo2b0

Hmm, based on qhat you posted the file looks ok based on https://github.com/samtools/samtools/issues/785 . You could do samtools view testWT_UT_possorted_genome_bam.bam | tail which then should give you the last line of the non-corrupted part of the file. Then inspect the n+1st line and see what is going on.

ADD REPLYlink modified 16 months ago • written 16 months ago by ATpoint46k

Added to post, view is also having issues, but not clear why. Thanks for the input btw!

ADD REPLYlink written 16 months ago by gordo2b0

Strange. I suggest you recreate that file. Might be the simpler workaround than digging out the cause of that error. I guess that if one of the maintainers of samtools in https://github.com/samtools/samtools/issues/785 did not have a good response we will not find one either.

ADD REPLYlink written 16 months ago by ATpoint46k

I normally would, hoped not to in this case as this bam is linked to an output that already has already been through a lot of processing. I'll have a think about a way around it. Thanks again for the input!

ADD REPLYlink written 16 months ago by gordo2b0

Would you happen to have an update on this? Running into the same problem and the bam files themself seem fine.

ADD REPLYlink written 6 weeks ago by barati0

If these errors come up how can the file be fine?

ADD REPLYlink written 6 weeks ago by ATpoint46k

They've all been downloaded from TCGA with a lot of post-processing that worked on them. I'm trying to use diffbind for some count matrices, so I'm super confused about why they're showing up as truncated now :/

ADD REPLYlink written 6 weeks ago by barati0

Probably something went wrong during the "lot of post-processing". Look, if you need help then please open a new question and include all relevant code. Anecdotal descriptions are rarely fruitful.

ADD REPLYlink written 6 weeks ago by ATpoint46k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2585 users visited in the last hour
_