I have a paired-end BAM file and I found that some pairs/mates have identical positions on the chromosome, i.e., the numbers in the POS and PNEXT fields are exactly the same. I want to remove these reads.
I also found that some reads present more than 2 times in my BAM file (same QNAME) (I think paired-end reads should have two records/rows in a BAM file). I want to keep the first two records/rows and remove the others.
I used samtools rmdup to remove duplicates.
Any help will be greatly appreciated. Thank you.