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?
File write failed (wrong size) when filtering a bam file with interset
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)
• 5,054 views
•
link
1 answer
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.
• 0 views
•
link
• 0 views
•
link
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.
• 0 views
•
link
Log in to answer this question.
Can you check if you have write permissions in the folder where you are writing the output?
It runs for a while and the output file is created but a few minutes after starting running, the error occurs.