SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Consensus FASTA from BAM files mixter Bioinformatics 14 05-19-2014 09:07 AM
building a consensus FASTA from BAM(s) adaptivegenome Bioinformatics 3 06-18-2013 07:10 PM
BWA sam and Samtools sam->bam conversion problem maasha Bioinformatics 6 06-05-2013 07:39 AM
NEw to Chip-seq and have .bam/.sam/.bam.bai files... then what? NGS newbie Bioinformatics 11 05-25-2011 07:48 AM
Bam and Sam don't like my fasta file mindlessbrain Bioinformatics 2 12-09-2010 10:47 PM

Reply
 
Thread Tools
Old 07-29-2010, 07:26 AM   #1
Canadian_philosophy
Junior Member
 
Location: Canada

Join Date: Apr 2010
Posts: 5
Exclamation BAM/SAM to Fasta

Hi there,

I have a couple of aligned sequences from BWA. I used samtools to get the BAM format. What I really need is the Fasta format of these aligned sequences. Is there a program that would help?

Thanks.
Canadian_philosophy is offline   Reply With Quote
Old 07-29-2010, 07:56 AM   #2
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,343
Default

Yes, several, including one line shell scripts.

Possibly seqret from EMBOSS 6.3.x will do what you want.

See also this thread for SAM/BAM to FASTQ which is very relevant:
http://seqanswers.com/forums/showthread.php?t=6164
maubp is offline   Reply With Quote
Old 07-29-2010, 09:40 AM   #3
Canadian_philosophy
Junior Member
 
Location: Canada

Join Date: Apr 2010
Posts: 5
Default

Thanks Maubp, I just downloaded Emboss. I will get back if I bump into trouble.
Thanks very much.
Canadian_philosophy is offline   Reply With Quote
Old 03-24-2011, 03:36 AM   #4
olus
Member
 
Location: milan, italy

Join Date: Aug 2008
Posts: 22
Default

This one liner would give you a fasta formatted file from a bam alignment:

samtools view filename.bam | awk '{OFS="\t"; print ">"$1"\n"$10}' - > filename.fasta

Hope this helps.

Gabriel
olus is offline   Reply With Quote
Old 03-24-2011, 03:45 AM   #5
ulz_peter
Senior Member
 
Location: Graz, Austria

Join Date: Feb 2010
Posts: 215
Default

Or picard SamToFastq:

Works with BAM Files as well and supports some other options:

http://picard.sourceforge.net/comman...tml#SamToFastq
ulz_peter is offline   Reply With Quote
Old 05-13-2011, 01:37 PM   #6
tejaminnu
Junior Member
 
Location: New York City

Join Date: May 2011
Posts: 4
Default

Hi Gabriel,

Is there a way to do the opposite ? What i mean is that, i have a file called mrna_ref.fa (fasta file), can i convert it into a sam or a bam file using Samtools in the command line.

Regards
Teja
tejaminnu is offline   Reply With Quote
Old 05-15-2011, 01:54 AM   #7
olus
Member
 
Location: milan, italy

Join Date: Aug 2008
Posts: 22
Default

Hi Teja.
In theory you can convert a multifasta file in a sam (tabular) file, and then convert to bam with samtools view -b.
But the fasta file only contains information on the nucletide sequence itself, nothing about the mapping, read quality etc... which are indeed the columns of the sam file (you will also need to rebuild the sam header).
In conclusion I think it's useless to convert a fasta file into a sam file, but I can't exclude that you are dealing with something that requires such conversion.
Would please briefly explain your case?

Thank you.

Best regards.
Gabriel
__________________
gabriele bucci
olus is offline   Reply With Quote
Old 05-15-2011, 01:56 AM   #8
tejaminnu
Junior Member
 
Location: New York City

Join Date: May 2011
Posts: 4
Default Hi

Hi Gabriel,

I want to send u the file. which is very small. Probably u can have a look at it .. Can u just send me a mail to this id, if its not a problem.

[email protected]

Regards
Teja
tejaminnu is offline   Reply With Quote
Old 05-15-2011, 02:01 AM   #9
tejaminnu
Junior Member
 
Location: New York City

Join Date: May 2011
Posts: 4
Default

Basically i have a Stand Alone Blast program running. The "fasta" file served as a reference file using which i blasted the large database file that i had. I am trying to find out if i can call SNP's using "Blast" program.

And i want to confirm it by getting the SNP's using Samtools.

Is the above explanation even valid. ?

Do let me know

Regards
Teja
tejaminnu is offline   Reply With Quote
Old 05-15-2011, 02:09 AM   #10
tejaminnu
Junior Member
 
Location: New York City

Join Date: May 2011
Posts: 4
Default

Hi Gabriel,

I want to send u the file. which is very small. Probably u can have a look at it .. Can u just send me a mail to this id, if its not a problem.

[email protected]

Basically i have a Stand Alone Blast program running. The "fasta" file served as a reference file using which i blasted the large database file that i had. I am trying to find out if i can call SNP's using "Blast" program.

And i want to confirm it by getting the SNP's using Samtools.

Is the above explanation even valid. ?

Do let me know


Regards
Teja
tejaminnu is offline   Reply With Quote
Old 05-16-2011, 03:06 AM   #11
olus
Member
 
Location: milan, italy

Join Date: Aug 2008
Posts: 22
Default

Quote:
Originally Posted by tejaminnu View Post
Hi Gabriel,

I want to send u the file. which is very small. Probably u can have a look at it .. Can u just send me a mail to this id, if its not a problem.

[email protected]

Basically i have a Stand Alone Blast program running. The "fasta" file served as a reference file using which i blasted the large database file that i had. I am trying to find out if i can call SNP's using "Blast" program.

And i want to confirm it by getting the SNP's using Samtools.

Is the above explanation even valid. ?

Do let me know


Regards
Teja
Hi.
If I understand it right, you have to:
1) align your fasta query file (mrna_fa) to a reference with blast
2) parse the blast output to be compliant with sam
3) use samtools to call SNPs (to a properly indexed reference)

for point 2) you can look at here:
http://seqanswers.com/forums/showthread.php?t=3759

In general I can say that blast it's not suited for efficient SNP calling , but I may be wrong.

Gabriel
__________________
gabriele bucci
olus is offline   Reply With Quote
Reply

Tags
bam, bwa, fasta, sam

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 08:36 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.