This is for a course I am currently taking. I have downloaded an indexed bam file (.bai) of all the exome reads from thr 1000 genomes project. The next step in this assignment is extracting the reads for chromosome 22 of this file. I tried samtools to do this
samtools view -b NA20515.bam.bai chr22 > chr22.bam
But I am met with the error
[E::hts_hopen] Failed to open file NA20515.bam.bai [E::hts_open_format] Failed to open file NA20515.bam.bai samtools view: failed to open "NA20515.bam.bai" for reading: Exec format error
Obviously I don't think I can do this with samtools. Is there any other way to do this?