Index BAM files
Indexing a genome sorted BAM file allows one to quickly extract alignments overlapping particular genomic regions. Moreover, indexing is required by genome viewers such as IGV so that the viewers can quickly display alignments in each genomic region to which you navigate.
This will create an additional “index” file. List (ls) the contents of the current directory and look for the new index file:
Now, let’s exploit the index to extract alignments from chromosome 20. To do
this, we use the samtools view command, which we will give proper treatment
in the next section. For now, just do it without understanding. No really. Do it.
How many alignments are there in this region?