![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
the header of SAM and BAM missing | dongshenglulv | Bioinformatics | 5 | 10-24-2011 12:44 AM |
SAM header missing in BFAST | cdry7ue | Bioinformatics | 6 | 05-03-2011 03:13 PM |
how to convert sam to bam with EOF marker in header | jianfeng.mao | Bioinformatics | 2 | 12-17-2010 06:56 AM |
missing header information in bam cause GATK unifiedgenotyper fail | foxyg | Bioinformatics | 3 | 11-11-2010 10:37 AM |
sam/bam header lines | keebs42 | Bioinformatics | 1 | 08-21-2009 12:25 PM |
![]() |
|
Thread Tools |
![]() |
#1 |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]()
I have a sam file that I want to convert to a bam file:
samtools view -b -S in.sam > out.bam I get this error: [samopen] no @SQ lines in the header. [sam_read1] missing header? Abort! My sam file looks perfectly normal to me. Does anyone see what I'm doing wrong? Thanks. Eric |
![]() |
![]() |
![]() |
#2 |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]()
To add to my previous post: I also tried the following command but I got the same error message:
samtools view -h -b -S in.sam > out.bam |
![]() |
![]() |
![]() |
#3 | |
Senior Member
Location: St. Louis, MO, USA Join Date: Apr 2011
Posts: 124
|
![]()
I think you might need to specify a reference file containing the names of the sequences and the total sequence lengths. This is done with the "-t" flag. Here is a description from samtools:
Quote:
|
|
![]() |
![]() |
![]() |
#4 |
Peter (Biopython etc)
Location: Dundee, Scotland, UK Join Date: Jul 2009
Posts: 1,543
|
![]()
Or from memory -T can specify a FASTA file of the references.
|
![]() |
![]() |
![]() |
#5 |
Senior Member
Location: San Diego Join Date: May 2008
Posts: 912
|
![]() |
![]() |
![]() |
![]() |
#6 | |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]() Quote:
Eric |
|
![]() |
![]() |
![]() |
#7 | |
Member
Location: Newark, Delaware, USA Join Date: Mar 2012
Posts: 16
|
![]() Quote:
I am also facing the same problem. I couldn't undertsood this line of yours "I didn't use the -h option, so then when I went to convert it back to a bam file, I couldn't fix things simply by adding the -h option. I had to go back and remake the sam file with -h" how to did you make same file with -h? Did you use Bwa to create sam file.? |
|
![]() |
![]() |
![]() |
#8 | |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]() Quote:
It's been a while, but I think that I created a sam file with samtools' view command and that that command accepts a -h flag, which will create a sam file with appropriate headers. Eric |
|
![]() |
![]() |
![]() |
#9 | |
Member
Location: Newark, Delaware, USA Join Date: Mar 2012
Posts: 16
|
![]() Quote:
[samopen] no @SQ lines in the header. [sam_read1] missing header? Abort! So I wanted to know how did you do it . Thanks |
|
![]() |
![]() |
![]() |
#10 | |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]() Quote:
Another thing to try if that doesn't work is using the -r option in bwa to add read group information when you create your original alignment file. Eric |
|
![]() |
![]() |
![]() |
#11 |
Member
Location: Newark, Delaware, USA Join Date: Mar 2012
Posts: 16
|
![]()
I will give it a shot. by -r you mean -R ? cause as I see the alignment options -r is with uppercase. There is no lower case 'r' option.
|
![]() |
![]() |
![]() |
#12 |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]() |
![]() |
![]() |
![]() |
#13 |
Member
Location: Newark, Delaware, USA Join Date: Mar 2012
Posts: 16
|
![]() |
![]() |
![]() |
![]() |
#14 |
Member
Location: North Carolina Join Date: Sep 2011
Posts: 38
|
![]()
I converted sam file to bam, then removes PCR duplicates, then convert bam to sam. It showed the same error msg:
error msg: [samopen] no @SQ lines in the header. [sam_read1] missing header? Abort! I tried -h option, still didn't work... |
![]() |
![]() |
![]() |
#15 |
Member
Location: Seattle Join Date: Jul 2011
Posts: 98
|
![]()
Hi bbm,
You might want to try Picard's AddOrReplaceReadGroups: http://picard.sourceforge.net/comman...laceReadGroups |
![]() |
![]() |
![]() |
#16 |
Junior Member
Location: London Join Date: Aug 2010
Posts: 4
|
![]()
I also came across the 'missing header' error. I found that that when converting BAM-> SAM, I had forgotten about printing the headers. This fixed it for me:
BAM -> SAM: Note : -h print header for the SAM output Code:
samtools view -h in.bam > out.sam SAM -> BAM (even SAM produced from BWA): Code:
samtools view -bS in.sam > out.bam |
![]() |
![]() |
![]() |
#17 |
Member
Location: Slovenia Join Date: Mar 2015
Posts: 19
|
![]()
i have the same problem...
this is from the man samtools: o Import SAM to BAM when @SQ lines are present in the header: samtools view -bS aln.sam > aln.bam If @SQ lines are absent: samtools faidx ref.fa samtools view -bt ref.fa.fai aln.sam > aln.bam where ref.fa.fai is generated automatically by the faidx command. However, i don't know which ref.fa to use. The sam i'm trying to convert to bam, sort and index was generated by a foreign seq searching program, readscan, which uses host and pathogen ref seqs and try to map to both of them. the actual sam file i'm trying to convert is "ambiguous.sam" which contains reads mapped to both ref seqs. can somebody please explain what is going on... what are @SQ lines, why does samtools need them to convert to bam and index the file, why am i expected to provide a ref.fa .... its really confusing tnx ! |
![]() |
![]() |
![]() |
#18 |
Senior Member
Location: uk Join Date: Mar 2009
Posts: 667
|
![]()
If you are aligning to something like the human genome, then you would usually have one @SQ line for each chromosome in the sam file header.
If you have the sequences of the host and pathogen the reads were mapped to, you could combine them into a ref.fa file, and run samtools faidx. |
![]() |
![]() |
![]() |
Tags |
error message, sam to bam |
Thread Tools | |
|
|