I have an alignment file for a protein encoded by about ~3000 bases (I have both bam and sam files), and I am looking to extract all the reads that from bases 877-981. Is there any way to do this with samtools?
I tried using this command:
samtools view 8.2alnCorrected.bam "877-981" > filteredreads.bam
However I got this message with an empty file:
region "877-981" specifies an unknown reference name. Continue anyway.
Take a look at the manual to correctly specify the region (RNAME[:STARTPOS[-ENDPOS]]): http://www.htslib.org/doc/samtools.html