Skip to content

"samtools view -r" includes reads with no read group #2265

Description

@matt-sexton

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...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions