bamtools split ERROR: could not open mybam.bam for writing.
0
0
Entering edit mode
12 weeks ago

While splitting my bam files using split command creates 'could not open file' error. my ulimit has been changed to unlimited. Headers in my bam file contain special characters like this '/'. Could headers be a reason for the problem?

PS- I could not edit my bam headers.

bam bamtools • 664 views
0
Entering edit mode

What was the commands you run? What errors did you get?

0
Entering edit mode

Sorry. This is the command I used:

bamtools split -in ERRXXXXXXXX.bam -reference
bamtools split ERROR: could not open ERRXXXXXXXX_XXX(X/XX/XX)_3_XXXX.bam for writing.

0
Entering edit mode

Your command looks incomplete and the error message is referencing something not included in the command here. Is that a copy-paste error?

0
Entering edit mode

I am quite sure that the provided command is complete. Initially i thought I am encountering an error similar to these below,

But I could not get this rectified based on the solutions given there. So I suspect, it could be due to special characters in the headers. Could anyone help me edit/replace those special characters in the bam file headers?

1
Entering edit mode

You need to grab the header from the current file and then edit it to remove / characters. Then use the edited header to reheader the BAM file. Process is roughly described here: Bam Header Edit

Take a look at samtools reheader in-line help.