The SAM file format specification makes clear that optional fields must follow the format TAG:TYPE:VALUE

Type   Regexp matching                                       VALUE Description
A     [!-~]                                                  Printable character
i     [-+]?[0-9]+                                            Signed integer
f     [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?                 Single-precision floating number
Z     [ !-~]*                                                Printable string, including space
H     ([0-9A-F][0-9A-F])*                                    Byte array in the Hex format10
B     [cCsSiIf](,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+    Integer or numeric array

However, looking at the samtools source code, I noticed this:


switch (aux_type) {
    case 'H':
    case 'Z':
        if (kputs(bam_aux2Z(s), linebuf) < 0) return false;
    case 'i': kputw(bam_aux2i(s), linebuf); break;
    case 'I': kputuw(bam_aux2i(s), linebuf); break;
    case 'A': kputc(bam_aux2A(s), linebuf); break;
    case 'f': kputd(bam_aux2f(s), linebuf); break;
    case 'B': kputs("*** Unhandled aux type ***", linebuf); return false;
    default:  kputs("*** Unknown aux type ***", linebuf); return false;


(1) I have never seen an "Integer or numeric array" of case "B". What does such an tag look like? Is there an example?

(2) Why is this currently "*** Unhandled aux type ***"? Was this the case with previous versions of samtools?


1 Answer 1

  1. An example would be ZC:B:i,271,271,1,0, which is from TMAP. The i part denotes the values held in the array, which are comma-separated.
  2. That code is only used in samtools fastq, where that tag type isn't output into fastq files.
  • $\begingroup$ Thanks for the help. "which is from TMAP"---where did you find this? $\endgroup$
    – EB2127
    Commented Apr 25, 2018 at 0:53
  • $\begingroup$ Also, how command is this tag? I don't think I've seen this type of tag "in the wild" in any BAM files....though perhaps I'm very wrong. $\endgroup$
    – EB2127
    Commented Apr 25, 2018 at 5:20
  • $\begingroup$ That particular example can be found here. You don't see tags like this that frequently, I had to search for a concrete example since I don't recall seeing any locally in a few years. $\endgroup$
    – Devon Ryan
    Commented Apr 25, 2018 at 6:38
  • 1
    $\begingroup$ Last questions: (1) I haven't seen this either. Is there any evidence that this tag format has largely been abandoned in recent years? (2) Is there a reason why the tag isn't output into FASTQ files? $\endgroup$
    – EB2127
    Commented Apr 25, 2018 at 17:38
  • 1
    $\begingroup$ That's used under the hood if you have more than 65535 CIGAR operations, but otherwise hasn't really seen wide-spread use. I guess no one ever saw the point in outputting that in fastq files. Presumably someone could make a PR to add it. $\endgroup$
    – Devon Ryan
    Commented Apr 25, 2018 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.