Remove Header from SAM - File
2
0
Entering edit mode
9.7 years ago

Hey there,

I need to remove a header from a SAM file that I generated from a BAM file. Can this removal be performed on the SAM file directly?

I am fairly new to bioinformatics, just started my PhD. If a solution employing samtools, bedtools or similar would be possible, I'd appreciate it.

Thanks a lot,

Cheers
Stefan

sequencing software-error next-gen • 10k views
ADD COMMENT
3
Entering edit mode
9.7 years ago

In a SAM (not BAM) file, the header lines start with @. So a simple grep excluding that pattern would work:

grep -v '^@' your.sam > noheader.sam

But whatever you're doing, there is no really much interest in removing a SAM header. May be you're looking for

samtools reheader <in.header.sam> <in.bam>
ADD COMMENT
0
Entering edit mode

hey thanks for the quick reply,

yeah I'm not sure about the header removal... I am trying to implement the SVdetect program for CNV detection and always get the error "illegal division in line 2883..." because the script works with the example files and example configuration file and also with my created config file and the example data sets, i figured the problem is my input sam files. The difference between my Sam files and the example sam files is the absence of the header i think...

cheers

ADD REPLY
0
Entering edit mode

It is highly unlikely that line 2883 is a part of the header. I am not saying it can't be but it is unusual. So removing the header should not solve your problems. Post the full error and also line number 2883 from your SAM file.

ADD REPLY
2
Entering edit mode
9.7 years ago
Prakki Rama ★ 2.7k

Check this link. In your case, you don't need header. So, do not use option -h.

ADD COMMENT

Login before adding your answer.

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