Skip to main content

SAM Format

Stream SAM (Sequence Alignment/Map) text alignments as one record per read.

Overview

PropertyValue
Format idsam
ClassSAMIterable
Extensions.sam
ReadYes
WriteNo
Extraalignment (pysam)
Maturitystable

Record shape

Same fields as BAM:

{
"query_name": "read1",
"flag": 0,
"reference_id": 0,
"reference_start": 100,
"mapping_quality": 60,
"cigarstring": "50M",
"next_reference_id": -1,
"next_reference_start": -1,
"template_length": 0,
"query_sequence": "ACGT...",
"query_qualities": "IIII...",
}

Requires a filename (streams not supported).

Usage

from iterable import open_iterable

with open_iterable("alignments.sam", format="sam") as source:
for aln in source:
print(aln["query_name"], aln["reference_start"])

Install with pip install iterabledata[alignment].

See also