Access read group tag for BAM reads – rust-htslib

I’m sure this is probably straightforward, but I can’t figure out how to access the read group information on a per-read basis within a BAM file. I can get it from the header, but I can’t determine how to use aux or any other record method to get that info. I realize this might change after issues #170 and #209 are implemented, but what’s the current approach for this?

Asked Dec 15 ’20 at 14:38

avatar of jlboat


2 Answers:

Assuming the read group information is stored in RG:Z: fields, it can be accessed via bam::record::Record::aux(b"RG"). This method should return a Aux::String(<&'a [u8]>) containing the read group information as raw bytes.

Answered Dec 15 ’20 at 15:15

avatar of jch-13


Thank you! I thought I had tried that, but it’s working for me now so I’m not complaining.

Answered Dec 15 ’20 at 15:40

avatar of jlboat


Read more here: Source link