Could not parse the header line

Error using samtools mpileup

samtools mpileup SAMPLE_sorted.bam

"Could not parse the header line:... "

Problem:

The problem can be due to a comma in the gene/contig ID

gi|3656203|ref|NZ_CM002351|:c1052230-105140,c1051398-1051048

Samtools mpileup is adding information to the original contig ID separated by comma.

...CONTIG,length=1543,IDX=923609>

and gets confused if the gene ID already includes a comma: 1005929-1007642,1007542-1008571

Solution:

Remove all comma from your gene or contig ID names before running samtools.