SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
samtools: parse error in SAM to BAM conversion chrisW Bioinformatics 12 01-14-2013 07:16 PM
bowtie2 failing with "Could not parse passthrough output:" error ManuSetty Bioinformatics 0 04-13-2012 10:59 PM
Can Biopython parse fastq file? ardmore Bioinformatics 2 11-29-2011 03:43 PM
Parse Web Blast Output empyrean Bioinformatics 0 07-08-2011 06:31 PM
One-liner to parse 454BaseCallerMetrics.txt pmiguel 454 Pyrosequencing 1 01-19-2011 06:54 AM

Reply
 
Thread Tools
Old 04-24-2012, 11:21 PM   #1
yksikaksi
Member
 
Location: Scandinavia

Join Date: Dec 2009
Posts: 20
Question How can I parse these reads

Code:
::::::::::::::
0H.ptFlagstat.txt
::::::::::::::
49080460 + 0 in total 
0 + 0 duplicates
6444347 + 0 mapped (13.13%:nan%)
49080460 + 0 paired in sequencing
45547041 + 0 read1  
3533419 + 0 read2   
5822436 + 0 properly paired (11.86%:nan%)  ***
5822436 + 0 with itself and mate mapped
621911 + 0 singletons (1.27%:nan%)
Good day.

I would like to parse the paired reads (***) from PCR duplicates removed sorted BAM files. I knew SAMtools or Picard tools can do that, however, I'm not sure what function or what option I should use.

Could anyone kindly please contribute the idea(s) or command line(s) or advice?

Thank you very much.
yksikaksi is offline   Reply With Quote
Old 04-25-2012, 05:36 AM   #2
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

PCR duplicates are marked in SAM/BAM as part of the read's FLAG entry (one of the bits).

You can use 'samtools view' with the -f and/or -F switches to filter reads based on their FLAG values.

By default 'samtools view' does BAM to SAM, but it can do SAM to SAM or BAM to BAM as well which is more sensible for filtering.
maubp is offline   Reply With Quote
Old 04-25-2012, 09:44 AM   #3
swbarnes2
Senior Member
 
Location: San Diego

Join Date: May 2008
Posts: 912
Default

What exactly are you trying to parse?

You can use samtools view and filter by flags (-f or -F) to break out particular kinds of reads based ontheri flags. You can use samtools view to make a .sam, and pipe that straight into a program like awk or grep.

Code:
samtools view file.bam | grep whatever - > grepped.sam
swbarnes2 is offline   Reply With Quote
Old 04-25-2012, 11:02 PM   #4
yksikaksi
Member
 
Location: Scandinavia

Join Date: Dec 2009
Posts: 20
Default

I want to exclude unmapped reads from the PCR duplicates removed BAM file (done by Picard MarkDuplicates tools) before carry on to downstream analysis. Thanks for the replied and suggestions. Appreciate that!
yksikaksi is offline   Reply With Quote
Old 04-26-2012, 09:16 AM   #5
swbarnes2
Senior Member
 
Location: San Diego

Join Date: May 2008
Posts: 912
Default

Code:
samtools view -bF 4 file.bam > mapped.bam
will make a new .bam that has only mapped reads.

the -F 4 means that it will exclude entries in your .bam that have the 4 flagged in the binary flag; 4 is the code for unmapped read. The -b means that it will output a .bam, instead of a .sam, which is the default behavior for samtools view.
swbarnes2 is offline   Reply With Quote
Old 04-26-2012, 11:24 AM   #6
yksikaksi
Member
 
Location: Scandinavia

Join Date: Dec 2009
Posts: 20
Default

Thanks for the code and the explanation. Thanks a lot.
yksikaksi is offline   Reply With Quote
Reply

Tags
bam, parse, pcr duplicates, picard, samtools

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 10:29 AM.


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