Hi, I hope someone can help me with this, I don't know what I am missing.
I would like to swap positive and negative strands in a BAM file. Below is the steps I am taking:
samtools view -H mybam.bam > header.sam
samtools view -h mybam.bam | awk -F ' ' '$2=($2=="16"?"0":"16")' > Swapped.bam
samtools reheader header.sam Swapped.bam or samtools reheader header.sam Swapped.bam > newBam.bam
But when I want to see the file, I get:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[main_samview] truncated file.
Any ideas are appreciated!
Any suggestions for any replacement to awk? I can also go ahead without this step, (just always have to be sure to consider the opposite strand which sounds like more confusion down the road than changing the strands..)
Forgive my naiveness, if my steps don't make sense, I am trying to understand these Bam files and your suggestions would be great to have!
As I suspected that is absolutely not a valid reason to change your bam file and make into an invalid one!
What you probably mean is that your data is strand specific with a a library prep that sequences the complementary strand. That is fine. Tools are built to operate on that and once you assemble a transcript it will be in the correct orientation.
As for the display it is not a big deal. If your instruments sequences the complementary strand you should never just "choose" to present that as the leading strand because it "looks nicer" that way - that is not what the instrument measured - it amounts to data doctoring.
I see. yes, thats what I meant. Thank you for the explanation! :)