Total reads aligning to each reference within a bam file I have two PCR amplicons that have been multiplexed and sequenced using the nanopore minion.

I have aligned the fastq reads using minimap2 with a reference file containing both amplicon sequences and generated a bam file that I have viewed using IGV.

I am looking for a way to generate some simple summary statistics.

In particular, is there a way to extract the total number of fastq reads aligning to each amplicon reference from the bam file?
The quick way to get the number of alignments on each reference is 

samtools idxstats my_bam.bam


Number of reads on each reference is column 3. Although, as has been pointed out, this will give you the total number of alignments per reference, not the total number of reads (each read might give rise to more than one alignment). That said I do tend to us this as generally I'm after a rough approximation, rather than an accurate number. 

In theory, only one alignment for each read should be marked as primary, so the following should give you what you need quickly and at low memory usage:

samtools view -bF 2304 my_bam.bam &gt; primary_only.bam
samtools index primary_only.bam
samtools idxstats primary_only.bam