SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
sam to bam conversion error, no @SQ lines in the header, missing header? efoss Bioinformatics 17 12-03-2015 04:28 AM
.SAM to .BAM with SAM file header @PG emilyjia2000 Bioinformatics 13 06-14-2011 12:21 PM
SAM header missing in BFAST cdry7ue Bioinformatics 6 05-03-2011 02:13 PM
missing header information in bam cause GATK unifiedgenotyper fail foxyg Bioinformatics 3 11-11-2010 09:37 AM
sam/bam header lines keebs42 Bioinformatics 1 08-21-2009 11:25 AM

Reply
 
Thread Tools
Old 05-18-2011, 08:45 PM   #1
dongshenglulv
Member
 
Location: Shanghai

Join Date: May 2011
Posts: 15
Default the header of SAM and BAM missing

Hi

I use the soap2sam.pl to convert the soap file file.soap to file.sam, but the header in file.sam is missing, so I have to add the header to the file.sam. When I convert this file.sam to file.bam, the header in file.bam is missing again. I don't know why.
dongshenglulv is offline   Reply With Quote
Old 05-18-2011, 09:57 PM   #2
doc.ramses
Member
 
Location: Planet Earth

Join Date: Jan 2011
Posts: 26
Default

Using the latest samtools (0.1.16) with samtools view -bS <in.sam> <out.bam> should write you a bam file with a header.
doc.ramses is offline   Reply With Quote
Old 05-18-2011, 10:06 PM   #3
dongshenglulv
Member
 
Location: Shanghai

Join Date: May 2011
Posts: 15
Default

Actually I did. I'm using the samtools (0.1.16),
Here is my command line,

$ samtools view -bt hg19.fa.fai unsorted.sam -o unsorted.bam
note that the unsorted.sam has no header @SQ

then I tried this,
$ samtools view -hbt hg19.fa.fai unsorted.sam -o unsorted.bam
the -h can include the header in the output

but I failed to merge the header into unsorted.bam
dongshenglulv is offline   Reply With Quote
Old 05-20-2011, 05:48 AM   #4
krinard
Junior Member
 
Location: boston

Join Date: Jan 2011
Posts: 2
Default

Perhaps you could try this approach, although it doesn't resolve the reason why you are losing your header.

1) Get the header from your sam file by doing (although you have this header already, I believe)

samtools view -HS <yourfile.sam> > <yourheader.sam>

2) Then reheader your bam file:

samtools reheader <yourheader.sam> <yourfile.bam>

where yourfile.bam is the bam file lacking the header
krinard is offline   Reply With Quote
Old 05-20-2011, 06:14 AM   #5
dongshenglulv
Member
 
Location: Shanghai

Join Date: May 2011
Posts: 15
Default

Thanks very much, it's solved
dongshenglulv is offline   Reply With Quote
Old 10-23-2011, 11:44 PM   #6
phatjoe
Member
 
Location: Asia

Join Date: Aug 2011
Posts: 13
Default

Hi,

I am currently facing the same problem with soap2sam.pl as well. I've actually tried this

samtools faidx reference.fa
samtools view -bt reference.fa.fai aln.sam >aln.bam

The conversion from sam <-->bam went fine,somehow when when I ran the mpileup |bcftools commands I couldnt manage to get anything in my *.vcf file.

I am trying the alternative as mentioned by krinard. When I ran

samtools view -HS test.sam > header_test.sam

samtools outputs this
[samopen] no @SQ lines in the header.

Am I missing something here? I am currently using samtools 0.1.17 (r973:277) though.

Any help will be much appreciated!
phatjoe is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 03:46 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO