File write failed (wrong size) when filtering a bam file with interset
1
0
Entering edit mode
2.6 years ago
ManuelDB ▴ 110

I have a WES BAM file and I want to filter this using a BED file

 bedtools intersect -abam NA12878.bam -b BRCA1-expanded.bed  > ./NA_limited.bam

And I got this error

 E::bgzf_flush] File write failed (wrong size)
terminate called after throwing an instance of 'std::runtime_error'
  what():  can't write alignment record
Aborted (core dumped)
bedtools • 3.3k views
ADD COMMENT
0
Entering edit mode

Can you check if you have write permissions in the folder where you are writing the output?

ADD REPLY
0
Entering edit mode
drwxr-xr-x  2 mdb1c20 af 4096 Apr  7 20:38 bayes_NA

It runs for a while and the output file is created but a few minutes after starting running, the error occurs.

ADD REPLY
1
Entering edit mode
2.6 years ago
ATpoint 85k

It probably runs out of memory. Anyway, don't use bedtools here, there is no need for finding intersections. You can simply use samtools view -L where -L accepts that bed file to only return alignments overlapping it. That requires a indexed bam file.

ADD COMMENT
0
Entering edit mode

Thanks for your answer. I have followed your suggestion and seems that worked. However, if later I want to call variants from the output generated after executing samtools view, it seems that the SQ lines are not present. So I cannot sort the reads, neither create an index and then use a variant caller. Any suggestion to do this?

ADD REPLY
0
Entering edit mode

You have to include the options for the header of course. -h is you output sam, ot -b for bam, read the manuals of tools you use. Probably --fetch-pairs makes sense as well.

ADD REPLY

Login before adding your answer.

Traffic: 1596 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