...
Since BAM files are binary, they can't be viewed directly using standard Unix file viewers such as more, less and head. We have seen how samtools view can be used to binary-format BAM files into text format for viewing. But samtools view also has options that let you do powerul filtering of the output. We focus on this filtering capability in this set of exercises.
Handy links
- The SAM format specification
- especially section 1.4 - alignment section fields
- Manual for SAMTools 1.3.1
- especially the 1st section on samtools view.
Setup
Set up a directory for these exercises and copy an indexed BAM file there. This is a renamed version of the yeast_pairedend.sort.bam file from our Alignment workflow exercises.
...
Code Block | ||||
---|---|---|---|---|
| ||||
mkdir -p $SCRATCH/core_ngs/samtools
cd $SCRATCH/core_ngs/samtools
cp $CORENGS/catchup/for_samtools/* . |
References
Handy links
- The SAM format specification
- especially section 1.4 - alignment section fields
- Manual for SAMTools 1.3.1
- especially the 1st section on samtools view.
SAM header fields
The 11 SAM alignment record required fields (Tab-delimited).
SAM flags field
Meaning of each bit (flag) in the SAM alignment records flags field (column 2). The most commonly querried flags are denoted in red.
SAM CIGAR string
Format of the CIGAR string in column 6 of SAM alignment records.
Exercises
Analyzing the CIGAR string
Filtering for only mapped reads (samtools view -F 0x4)
...