SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Aligned to UCSC genome using Bowtie2, how do I interpret QNAME in SAM file? KnowNothing2 Bioinformatics 10 12-11-2013 03:21 PM
bowtie2: running out of memory? impeachme2 Bioinformatics 6 07-17-2013 04:11 PM
Tophat2 very slow when running over Bowtie2 jdenvir Bioinformatics 2 02-18-2013 06:28 AM
Bowtie2 ( not running with option --sam-rg CHRYSES Bioinformatics 2 01-24-2012 03:28 AM
Bowtie2 running infinitely jaZt Bioinformatics 0 01-16-2012 02:47 AM

Reply
 
Thread Tools
Old 02-24-2015, 03:46 PM   #1
morning latte
Member
 
Location: MI

Join Date: Jun 2013
Posts: 91
Default SAM file after running bowtie2

Hello experts,

I ran bowtie2 mapping with "local" setting on my illumina datasets a while ago and sam files were generated. Basically, I mapped reads onto assembled contigs. Unfortunately, sequence reads used for mapping are not available anymore so I need run bowtie2 again without "local" setting. Is there any way that I can do something with the sam files generated before? Any comments would be appreciated.
morning latte is offline   Reply With Quote
Old 02-24-2015, 04:12 PM   #2
Brian Bushnell
Super Moderator
 
Location: Walnut Creek, CA

Join Date: Jan 2014
Posts: 2,707
Default

Can you clarify your goal? It sounds like you want to convert the sam files to fastq files in order to remap them; is that correct? The other option, converting local alignments into global alignments, is not really as far as I know. Converting the sam to fastq is easy, though, as long as the reads were soft-clipped rather than hard-clipped.
Brian Bushnell is offline   Reply With Quote
Old 02-25-2015, 05:27 AM   #3
diego diaz
Member
 
Location: Santiago, Chile

Join Date: Oct 2013
Posts: 62
Default

You can transform your bam files into fastq files. There is a great tool called bam2fastq for this purpose.

Link:
http://www.hudsonalpha.org/gsl/software/bam2fastq.php

to extract only unaligned reads:
bam2fastq -o yourdata_unaligned.fastq --no-aligned yourdata.bam

to extract only aligned reads:
bam2fastq -o yourdata_aligned.fastq --no-unaligned yourdata.bam

Last edited by diego diaz; 02-25-2015 at 12:31 PM.
diego diaz is offline   Reply With Quote
Old 02-25-2015, 07:40 AM   #4
morning latte
Member
 
Location: MI

Join Date: Jun 2013
Posts: 91
Default

Thanks!

To clarify my goal, I would like to obtain fastq files used for mapping from SAM files. Based on comments from Brian Bushnell and diego diaz, it looks doable. Is there any tool for SAM files not BAM files? Thanks.
morning latte is offline   Reply With Quote
Old 02-25-2015, 10:32 AM   #5
Brian Bushnell
Super Moderator
 
Location: Walnut Creek, CA

Join Date: Jan 2014
Posts: 2,707
Default

Reformat will do that:
reformat.sh in=reads.sam out=reads.fastq

Depending on whether the reads were initially paired, you may need to reprocess the output. Do you happen to know if they were paired?
Brian Bushnell is offline   Reply With Quote
Old 02-25-2015, 10:34 AM   #6
morning latte
Member
 
Location: MI

Join Date: Jun 2013
Posts: 91
Default

For input of bowtie2 mapping, i used paired reads with flags -1 and -2.
morning latte is offline   Reply With Quote
Old 02-25-2015, 10:49 AM   #7
Brian Bushnell
Super Moderator
 
Location: Walnut Creek, CA

Join Date: Jan 2014
Posts: 2,707
Default

OK - in that case, after you convert the sam to fastq as above, you should first test if the pairs are correctly ordered, like this:

reformat.sh in=reads.fastq verifypairing

If that completes successfully and says the reads were correctly paired, then you can simply de-interleave it into two files like this:

reformat.sh in=reads.fastq out1=r1.fastq out2=r2.fastq

That will probably be the case. If not, let me know and that can be solved also.
Brian Bushnell is offline   Reply With Quote
Old 02-25-2015, 12:24 PM   #8
diego diaz
Member
 
Location: Santiago, Chile

Join Date: Oct 2013
Posts: 62
Default

Also you can use SamToFastq from PicardTools to convert your sam files into fastqs.
diego diaz is offline   Reply With Quote
Old 02-25-2015, 03:21 PM   #9
swbarnes2
Senior Member
 
Location: San Diego

Join Date: May 2008
Posts: 912
Default

Did you check to see if bowtie will take a .bam as input, instead of a fastq?

My version, which might be a little old says it has an option

Code:
 -r                 query input files are raw one-sequence-per-line
So rather than reformat the .sam to a fastq, maybe you could do a little unix piping, and use the file you already have, without having to make a fastq version of it.
swbarnes2 is offline   Reply With Quote
Old 02-25-2015, 03:23 PM   #10
morning latte
Member
 
Location: MI

Join Date: Jun 2013
Posts: 91
Default

Thanks all for the valuable comments.

Basically, I have tried reformat with multiple sam files and it worked great. I will also try with other comments (e.g. PicardTools). Thanks again!
morning latte 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 12:06 AM.


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