"[E::bgzf_read] Read block operation failed" error - possible truncation/corruption of BAM file
0
1
Entering edit mode
5.1 years ago
gordo2b ▴ 10

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 • 17k views
ADD COMMENT
1
Entering edit mode

Got the similar errors when running samtools depth, also the quickcheck didn't show any issues.

[E::bgzf_read] Read block operation failed with error 1 after 198 of 248 bytes

Maybe my bam file is too large (139G) ?

ADD REPLY
0
Entering edit mode

It means the file is corrputed, this is unrelated to size.

ADD REPLY
0
Entering edit mode

Yeah I think it really is... I tried one more time and samtools stoped at the same place

[E::bgzf_uncompress] Inflate operation failed: 1
[E::bgzf_read] Read block operation failed with error 1 after 198 of 248 bytes
samtools depth: couldn't read from input file

I may need to redo the alignment...

ADD REPLY
0
Entering edit mode

Run samtools quickcheck -qvvv your.bam.

ADD REPLY
0
Entering edit mode

Added to post, looks good

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 861 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6