I added the @HQ field in the line .. header.sam is still human readable and when I do
samtools reheader header.bam header.unique.bam
It says
open: No such file or directory
[main_reheader] fail to open file header.unique.bam
I have the same issue with samtools no matter how hard I'm trying to grab the header it just doesn't work ..
samtools view -H file.bam > header.sam
samtools reheader header.bam header.unique.bam
[samopen] no @SQ lines in the header.
[sam_read1] missing header? Abort!
Header.bam has the following content :
@SQ SN:chr1 LN:197195432
@SQ SN:chr2 LN:181748087
@SQ SN:chr3 LN:159599783
@SQ SN:chr4 LN:155630120
@SQ SN:chr5 LN:152537259
@SQ SN:chr6 LN:149517037
@SQ SN:chr7 LN:152524553
@SQ SN:chr8 LN:131738871
@SQ SN:chr9 LN:124076172
@SQ SN:chr10 LN:129993255
@SQ SN:chr11 LN:121843856
@SQ SN:chr12 LN:121257530
@SQ SN:chr13 LN:120284312
@SQ SN:chr14 LN:125194864
@SQ SN:chr15 LN:103494974
@SQ SN:chr16 LN:98319150
@SQ SN:chr17 LN:95272651
@SQ SN:chr18 LN:90772031
@SQ SN:chr19 LN:61342430
@SQ SN:chrX LN:166650296
@SQ SN:chrY LN:15902555
@SQ SN:chrM LN:16299
@PG ID:bwa PN:bwa VN:0.5.9-r16
~
~
Interesting thing .. I can view the header of header.bam just by typing
$ view header-1ips.sam
Hi,
Your header is lacking in the first line (@HD field). Below an example:
@HD VN:1.0 GO:none SO:coordinate
Try to edit the samfile adding the @HD record and let me know.
PS: columns are tab-delimited.
I added the @HQ field in the line .. header.sam is still human readable and when I do
samtools reheader header.bam header.unique.bam
It says
open: No such file or directory
[main_reheader] fail to open file header.unique.bam
It is because you don't have "header.unique.sam" file in the same directory. In the command you say "header.unique.bam" and error is about .sam? I think you are mixing sam and bam extensions.
yeah sorry I mixed up sam and bam in my answer (edited now..), I do have the two files in the same directory which is why I don't understand why it doesn't work..
In your original post, you have "header.sam" and here now you have "header.bam". Also, in the error, it shows you - fail to open "header.unique.sam" but in input you have "header.unique.bam". Please check all the files in directory and give your commands accordingly.
I'm sorry, I'm just confused whenever I type here, all the extension I use are proper and are BAM format :) The problem come from the syntax ..
Log in to answer this question.
Works fine for me. 1) Did you try to output the first command on to your screen to see if everything is right? 2) Are you providing an existing bam file that doesn't have any issues itself?
uhm .. is there a way to be sure my bam file doesn't have any issue?
can you please show the content of : `header.sam' ?
I have edited my question with the content of the header.sam file
Did you get the files using soap2sam.pl ? If yes, that script doesn't insert headers, you have to do "samtools view -bt" first: http://samtools.sourceforge.net/samtools.shtml#5
sam files are from GSNAP .. we then used samtools to have the bam files.