eduKateSG · Why Science?
Read one sequencing alignment as a transparent scientific record—then check the reference, coordinates, flags and uncertainty behind it
Choose the closest route, then return to the full index whenever you need the wider evidence chain.
Science learning becomes powerful when students can tell a measured pattern from a model, a statistical decision from a mechanism, and a useful lead from a finished conclusion. The Sequence Alignment/Map format, or SAM, is a tab-delimited text format for sequence-alignment records. The official SAM/BAM specification describes an optional header followed by alignments; header lines begin with @, and every alignment line has eleven mandatory fields followed by optional TAG:TYPE:VALUE fields. The current specification is SAM/BAM version 1.6. SAM makes records inspectable, but a syntactically valid line does not prove that the alignment is correct, unique, biologically meaningful or suitable for a downstream clinical conclusion. This guide supports Primary Science, PSLE Science, Secondary Science, O-Level Science and STEM education as a longform evidence-reading route; it is not medical advice, a laboratory protocol, an admission promise or a career guarantee.
Related eduKate reading: CRAM and reference-based genomic compression; refget and globally identifiable reference sequences; htsget and secure genomic data streaming; Science Learning Hub; Education Hub; STEM Education; Careers by Subject Capability.
Primary and official sources checked on 12 October 2026: Official SAM/BAM Format Specification Working Group specification, version 1.6, 12 August 2025; Official SAM/BAM and related specifications repository; Official SAM optional-fields specification, 9 September 2024; 2026 Singapore–Cambridge O-Level Biology syllabus; MOE G2/G3 Lower Secondary Science teaching and learning syllabus; 2026 MOE G2 Computing syllabus. Standards, binary encodings and recommendations can change, so preserve the dated documentation, reference and software versions used.
A deeper reading route
SAM turns an aligner result into named fields that people and programs can inspect. QNAME identifies the query template; FLAG compresses multiple Boolean states into bits; RNAME and POS locate the reported mapping; MAPQ describes uncertainty under the aligner’s model; CIGAR explains how query and reference positions advance; mate, sequence and quality fields complete the mandatory record. The text is readable, but every field still depends on a reference, software choice and experimental design.
The header is scientific context rather than decorative preamble. @SQ records define reference sequence names and lengths, and their order helps define coordinate sorting. @RG can distinguish read groups, libraries or samples; @PG can preserve program chains; @HD can state format and sorting information. Removing the header while keeping alignment lines can make apparently clear coordinates impossible to interpret safely.
FLAG and CIGAR reward precise reasoning. FLAG values are sums of bit masks, so one decimal number can indicate pairing, strand, secondary or supplementary status and quality filtering. CIGAR operations describe alignment geometry, not a biological diagnosis: matches, insertions, deletions, clipping and skipped regions affect query and reference coordinates differently. A correct interpretation follows the specification one operation at a time.
Mapping quality is not base quality and is not a universal probability calibrated identically across aligners. The specification defines MAPQ as a phred-scaled probability that the mapping position is wrong, with 255 meaning unavailable. In practice, algorithms estimate or approximate that quantity differently. Reports should name the aligner, parameters and multi-mapping policy instead of comparing MAPQ values as if every tool used one laboratory instrument.
Optional tags extend SAM without changing the eleven mandatory columns. Standard tags can carry edit distance, alignment score, read group, original qualities and supplementary-alignment links; local tags can also appear. A parser must respect the TAG:TYPE:VALUE structure and the companion specification. Unknown or absent tags should remain unknown, not be converted into a confident biological statement.
For students, SAM is a satisfying bridge from school tables to research computing. One row is a structured claim, a header supplies shared context, and uncertainty remains visible beside the result. The deeper lesson is cheerful and durable: readable data help us ask better questions, but reading a record is only the beginning of evaluating evidence.
| Stage | Question | Evidence | Responsible output |
|---|---|---|---|
| Context | Which reference and processing history apply? | @HD, @SQ, @RG and @PG header records | An interpretable alignment context |
| Locate | Where is the query reported to map? | RNAME, POS, FLAG and mate fields | A reference-relative placement claim |
| Explain | How does query sequence relate to reference? | CIGAR, SEQ, QUAL and optional tags | A structured alignment description |
| Judge | How strong and reproducible is the claim? | MAPQ, alternatives, provenance and validation | A bounded scientific interpretation |
Inside this guide
1–12 · Foundations and design
- 1. Start with the alignment question
- 2. Use the current specification
- 3. Recognise the two sections
- 4. Read tabs, not visual spaces
- 5. Protect the header
- 6. Understand @HD
- 7. Understand @SQ
- 8. Understand read groups
- 9. Understand program records
- 10. Count eleven mandatory fields
- 11. Read QNAME as a query-template name
- 12. Decode FLAG bitwise
13–24 · Models and estimation
- 13. Treat primary as an algorithmic choice
- 14. Read RNAME with the dictionary
- 15. Read POS as one-based
- 16. Interpret MAPQ narrowly
- 17. Walk the CIGAR string
- 18. Distinguish clipping from deletion
- 19. Read mate fields together
- 20. Keep SEQ and QUAL aligned
- 21. Use optional tags by specification
- 22. Distinguish AS, NM and evidence
- 23. Follow supplementary links
- 24. Respect sorting declarations
25–36 · Diagnostics and interpretation
- 25. Index the correct representation
- 26. Validate reference identity
- 27. Audit unmapped records
- 28. Connect to Primary Science
- 29. Connect to Secondary Science
- 30. Connect to mathematics
- 31. Connect to computing
- 32. Connect to pathways
- 33. Did you know?
- 34. Write a reader-ready methods note
- 35. Build a validation ladder
- 36. Finish with a reproducible bundle
Section 1 of 36
1. Start with the alignment question
SAM records where an analysis reports a sequence segment relative to a reference. The scientific question should name the sample, assay, reference assembly and reason the alignment is being inspected.
Working checkpoint — SAM: Write the query, reference and intended downstream use before opening the file. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 2 of 36
2. Use the current specification
The official working-group document identifies SAM/BAM format version 1.6 and is dated 12 August 2025. A dated specification is part of reproducibility.
Working checkpoint — alignment record: Record the document version, retrieval date and software implementation. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 3 of 36
3. Recognise the two sections
A SAM file contains an optional header section followed by an alignment section. If a header is present, it comes before the alignments.
Working checkpoint — FLAG: Check that parsing preserves the boundary and the original header text. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 4 of 36
4. Read tabs, not visual spaces
SAM alignment records are tab-delimited. Copying a line through a proportional editor or wrapping it visually can hide the real field boundaries.
Working checkpoint — CIGAR: Validate delimiters and field counts with a standards-aware parser. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 5 of 36
5. Protect the header
Header records carry the reference dictionary, sorting declaration, read groups and program history needed to interpret downstream rows.
Working checkpoint — mapping quality: Archive the complete header with every derived subset. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 6 of 36
6. Understand @HD
The optional @HD record can state the format version and sorting order. If present, it must be the first header line and appear only once.
Working checkpoint — reference dictionary: Compare declared sorting with the actual record order. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 7 of 36
7. Understand @SQ
@SQ records identify reference sequences with required names and lengths. Their order helps define coordinate sorting, so it is part of the data model.
Working checkpoint — SAM: Compare @SQ names, lengths and checksums with the intended reference. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 8 of 36
8. Understand read groups
@RG can distinguish sample, library, platform and run context. Downstream duplicate marking or variant calling can depend on accurate read-group assignment.
Working checkpoint — alignment record: Check every RG tag against one matching @RG header record. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 9 of 36
9. Understand program records
@PG records can describe programs, versions, command lines and parent program relationships. They are useful provenance but can be incomplete or altered.
Working checkpoint — FLAG: Preserve the header and add an external workflow manifest. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 10 of 36
10. Count eleven mandatory fields
Each alignment line has at least eleven tab-separated fields in a fixed order. Placeholders such as 0 or * represent unavailable values as defined for each field.
Working checkpoint — CIGAR: Reject truncated rows and interpret placeholders field by field. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 11 of 36
11. Read QNAME as a query-template name
QNAME groups records from the same query template. It is an identifier, not proof that the reads came from one biological molecule after all processing.
Working checkpoint — mapping quality: Check naming conventions and pair structure before grouping records. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 12 of 36
12. Decode FLAG bitwise
FLAG is an integer bit field. Its bits can describe pairing, mapping, strand, first or last segment, secondary alignment, quality filtering, duplication and supplementary alignment.
Working checkpoint — reference dictionary: Decode the bits and test impossible or contradictory combinations. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 13 of 36
13. Treat primary as an algorithmic choice
A query can have multiple alignments. The primary record is generally the chosen best alignment, but the specification notes that the choice can be arbitrary.
Working checkpoint — SAM: Inspect secondary and supplementary records before claiming uniqueness. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 14 of 36
14. Read RNAME with the dictionary
RNAME refers to a reference sequence name declared by the header when reference metadata are present. Similar chromosome labels do not guarantee the same assembly or sequence.
Working checkpoint — alignment record: Resolve the name against @SQ and the exact reference release. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 15 of 36
15. Read POS as one-based
POS is the one-based leftmost mapping position of the first CIGAR operation that consumes a reference base. Zero has a special unmapped meaning.
Working checkpoint — FLAG: Convert coordinates explicitly when comparing with zero-based formats such as BED. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 16 of 36
16. Interpret MAPQ narrowly
MAPQ is defined as a phred-scaled probability that the mapping position is wrong, rounded to an integer; 255 means unavailable. Calibration varies among aligners.
Working checkpoint — CIGAR: Report aligner, version and multi-mapping policy beside MAPQ. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 17 of 36
17. Walk the CIGAR string
CIGAR encodes how query and reference advance through matches, insertions, deletions, skips, clipping and padding. Different operations consume different coordinate spaces.
Working checkpoint — mapping quality: Build a small operation table before calculating spans. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 18 of 36
18. Distinguish clipping from deletion
Soft clipping retains clipped bases in SEQ, hard clipping omits them, and deletion consumes reference but not query. Mixing these concepts changes breakpoint and length interpretations.
Working checkpoint — reference dictionary: Recalculate query and reference consumption independently. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 19 of 36
19. Read mate fields together
RNEXT, PNEXT and TLEN describe relationships within a template. They need FLAG and the aligner’s pairing conventions for interpretation.
Working checkpoint — SAM: Check both mates instead of trusting one record in isolation. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 20 of 36
20. Keep SEQ and QUAL aligned
SEQ stores segment sequence and QUAL stores base qualities when available. Orientation and clipping rules matter when comparing them to the original read.
Working checkpoint — alignment record: Verify sequence length, quality length and strand handling. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 21 of 36
21. Use optional tags by specification
Optional fields use TAG:TYPE:VALUE structure. Standard uppercase tags are defined in the companion document, while lowercase tags are reserved for local use.
Working checkpoint — FLAG: Record tag definitions and do not guess unknown semantics. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 22 of 36
22. Distinguish AS, NM and evidence
Alignment score and edit-distance tags can aid filtering, yet their exact generation depends on the aligner and scoring system. Neither is a universal biological confidence score.
Working checkpoint — CIGAR: Compare only values produced under compatible methods. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 23 of 36
23. Follow supplementary links
Supplementary records can represent pieces of a chimeric alignment, and the SA tag can link related segments. Structural-variant or fusion claims require further evidence.
Working checkpoint — mapping quality: Plot all segments and inspect sequence support. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 24 of 36
24. Respect sorting declarations
The @HD SO tag can state coordinate, query-name, unsorted or unknown order. A label should be verified because incorrect sorting can break indexing or grouping.
Working checkpoint — reference dictionary: Scan ordering and rebuild metadata after any resort. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 25 of 36
25. Index the correct representation
The official specification defines BAM indexing rather than a native SAM index. Large textual SAM is commonly converted to a coordinate-sorted binary form for regional access.
Working checkpoint — SAM: Record conversion tools and verify counts before and after conversion. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 26 of 36
26. Validate reference identity
Reference names alone can collide across assemblies. Lengths, checksums and sequence identifiers help prevent a record from being placed on the wrong reference.
Working checkpoint — alignment record: Use refget or equivalent checksums where available. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 27 of 36
27. Audit unmapped records
An unmapped FLAG does not force every coordinate-related field to be blank, and mate information can remain meaningful. Simplistic filters can discard useful context.
Working checkpoint — FLAG: Apply the specification’s rules rather than a one-field shortcut. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 28 of 36
28. Connect to Primary Science
A fictional table of objects, locations and confidence shows why every row needs column definitions and shared context.
Working checkpoint — CIGAR: Use invented data and ask pupils to explain what remains uncertain. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 29 of 36
29. Connect to Secondary Science
Alignment resembles comparing an observed sequence with a reference while recording differences and uncertainty. Fair interpretation still depends on controls and methods.
Working checkpoint — mapping quality: Separate observation, algorithmic placement and biological conclusion. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 30 of 36
30. Connect to mathematics
Bit masks, one-based coordinates, logarithmic quality scales and string operations connect SAM to number systems, probability and discrete mathematics.
Working checkpoint — reference dictionary: Decode one FLAG and calculate one CIGAR span by hand. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 31 of 36
31. Connect to computing
Streaming parsers, schemas, validation, indexing and provenance show how text formats become scientific infrastructure.
Working checkpoint — SAM: Test malformed tabs, unknown tags and inconsistent headers. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Section 32 of 36
32. Connect to pathways
Sequence alignment connects biology, statistics, software engineering and genomic data stewardship and can illuminate STEM study and career pathways.
Working checkpoint — alignment record: Check current official qualifications separately. Read every placement beside FLAG, MAPQ, alternatives, CIGAR, base qualities and sample-level evidence.
For future study, connect alignment to biology, mathematics and computing while checking official pathways separately.
Section 33 of 36
33. Did you know?
One SAM alignment line always has eleven mandatory fields, but its decimal FLAG can silently carry many simultaneous yes-or-no states.
Working checkpoint — FLAG: Translate the FLAG into named bits before reading the rest of the row. Preserve secondary, supplementary, filtered and unmapped records; a primary-only view is not the complete evidence.
For scientific writing, cite the SAM specification, reference, aligner, parameters and validation.
Section 34 of 36
34. Write a reader-ready methods note
Name the assay, aligner and version, parameters, reference and checksum, SAM specification, read-group handling, filters and validation.
Working checkpoint — CIGAR: Keep the exact command and header with the note. Separate readable syntax and valid parsing from correct placement, biological mechanism and clinical meaning.
For students, ask what one row claims, which header defines its symbols and what uncertainty remains.
Section 35 of 36
35. Build a validation ladder
Validate syntax, header references, field ranges, FLAG logic, CIGAR spans, pairing, sorting and small known fixtures before interpreting a cohort.
Working checkpoint — mapping quality: Stop at the earliest failing layer. Treat QNAME, RNAME, POS and read-group identifiers as scientific inputs: a silent mismatch can reverse the record.
For parents, a useful checkpoint is whether the reference and software choices are named.
Section 36 of 36
36. Finish with a reproducible bundle
Deliver original files or hashes, reference identifiers, complete header, software environment, commands, validation logs, derived tables and bounded claims.
Working checkpoint — reference dictionary: Make every alignment interpretation traceable to its record and context. Keep the complete header, reference identity, aligner and version, commands, record and optional-tag definitions together.
For a classroom model, align invented letter strings to a fictional reference and keep alternatives visible.
Contents · Previous section · Continue to the Science Learning Hub
