Are you using the latest version of samtools and HTSlib? If not, please specify.
samtools 1.21
Please describe your environment.
- Linux 6.14.0-1012-aws
- x86_64
- gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Please specify the steps taken to generate the issue, the command you are running and the relevant output.
I understand that "samtools view -r RG" should only output those reads in read group RG. However, it seems to always include reads that do not belong to a read group, i.e. that have no RG tag.
The attached file has three reads. The first read (Q1) belongs to RG1, the second (Q2) to RG2, and the third (Q3) to no read group.
no.sam.gz
$ samtools view -r RG1 no.sam
Q1 4 * 0 0 * * 0 0 TCTACACG...
Q3 4 * 0 0 * * 0 0 TCTACACGACGC...
$ samtools view -r RG2 no.sam
Q2 4 * 0 0 * * 0 0 TCTACACGACG...
Q3 4 * 0 0 * * 0 0 TCTACACG...
$ samtools view -r foobar no.sam
Q3 4 * 0 0 * * 0 0 TCTACAC...
Are you using the latest version of samtools and HTSlib? If not, please specify.
samtools 1.21
Please describe your environment.
Please specify the steps taken to generate the issue, the command you are running and the relevant output.
I understand that "samtools view -r RG" should only output those reads in read group RG. However, it seems to always include reads that do not belong to a read group, i.e. that have no RG tag.
The attached file has three reads. The first read (Q1) belongs to RG1, the second (Q2) to RG2, and the third (Q3) to no read group.
no.sam.gz
$ samtools view -r RG1 no.samQ1 4 * 0 0 * * 0 0 TCTACACG...Q3 4 * 0 0 * * 0 0 TCTACACGACGC...$ samtools view -r RG2 no.samQ2 4 * 0 0 * * 0 0 TCTACACGACG...Q3 4 * 0 0 * * 0 0 TCTACACG...$ samtools view -r foobar no.samQ3 4 * 0 0 * * 0 0 TCTACAC...