![]() |
How can I parse these reads
Code:
:::::::::::::: 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. |
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. |
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 |
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!
|
Code:
samtools view -bF 4 file.bam > mapped.bam 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. |
Thanks for the code and the explanation. Thanks a lot.
|
All times are GMT -8. The time now is 07:54 PM. |
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.