Skip to content

Main content

BAM CIGAR Opcode Length Split Tool

Decode one unsigned BAM CIGAR word: low four bits select the operation and the upper bits encode positive length.

Loading tool…

Description

Split one packed BAM CIGAR integer.

Sequence alignments distinguish flag bits, query/reference coordinates, CIGAR operations and scoring conventions. A single flag or length contribution does not establish a complete valid alignment; consuming reference bases differs from consuming query bases or counting a gap penalty.

Split one packed BAM CIGAR integer.

When to use this tool

Use BAM CIGAR Opcode Length Split when checking the stated alignment flag, operation, span or gap-scoring convention.

How to use the tool and how it works

  1. Enter encoded. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read length, opcode, operation. Use the output convention below.

Split one packed BAM CIGAR integer. Require encoded in unsigned 32-bit range; opcode = encoded mod 16, length = floor(encoded/16), require opcode 0..8 and positive length, map opcode to M/I/D/N/S/H/P/=/X.1

SAM/BAM defines separate flag, quality and CIGAR conventions. This local operation does not validate a complete alignment record.2

Input fieldMeaning and unitsAccepted input
encodedSupplied unsigned 32-bit integer with operation in low four bits and length in the upper bits.Required. Safe integer; minimum 0; maximum 4294967295.
Output fieldInterpretationReturned shape
lengthLengthRequired. Safe integer.
opcodeOpcodeRequired. Safe integer.
operationOperationRequired. Text; maximum UTF-16 length 8192.
json
{
  "input": {
    "encoded": 160
  },
  "output": {
    "length": 10,
    "opcode": 0,
    "operation": "M"
  }
}

Limitations and assumptions

  • This handles a supplied decoded integer, not byte order, a BAM binary file or full CIGAR validity.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use a complete SAM/BAM and reference-aware validator or alignment method with explicit clipping, coordinate and scoring policies for full processing.

References

  1. Calculation and input contract: bioinformatics/bam-cigar-opcode-length-split — tool.io

  2. SAM/BAM format specification, version 1.6 — SAM/BAM Format Specification Working Group

Similar or alternative tools