Module noodles::sam::header [−][src]
Expand description
SAM header and records.
A SAM header is a list of header records. There are 5 record types: header (@HD
),
reference sequence (@SQ
), read group (@RG
), program (@PG
), and comment (@CO
).
Each record is effectively a map. It defines key-value pairs associated with that record type.
All records are optional, which means an empty header is considered a valid SAM header.
If there is a header record, it must appear as the first record.
Reference sequence, read group, program, and comment records are lists of records of the same
type. Reference sequences must be ordered; whereas read groups, programs, and comments can be
unordered. (sam::Header
defines them to be ordered.)
Examples
Parse a SAM header
use noodles_sam as sam;
let s = "\
@HD\tVN:1.6\tSO:coordinate
@SQ\tSN:sq0\tLN:8
@SQ\tSN:sq1\tLN:13
";
let header: sam::Header = s.parse()?;
assert!(header.header().is_some());
assert_eq!(header.reference_sequences().len(), 2);
assert!(header.read_groups().is_empty());
assert!(header.programs().is_empty());
assert!(header.comments().is_empty());
Create a SAM header
use noodles_sam::{self as sam, header::{self, ReferenceSequence}};
let header = sam::Header::builder()
.set_header(header::header::Header::default())
.add_reference_sequence(ReferenceSequence::new("sq0", 8)?)
.add_reference_sequence(ReferenceSequence::new("sq1", 13)?)
.build();
assert!(header.header().is_some());
assert_eq!(header.reference_sequences().len(), 2);
assert!(header.read_groups().is_empty());
assert!(header.programs().is_empty());
assert!(header.comments().is_empty());
Modules
SAM header header and fields.
SAM header program and fields.
SAM header read group and fields.
SAM header record and components.
SAM header reference sequence and fields.
Structs
A SAM header builder.
A SAM header.
A SAM header program.
A SAM header read group.
A generic SAM header record.
A SAM header reference sequence.
Enums
An error returned when a raw SAM header fails to parse.
Type Definitions
An ordered map of programs.
An ordered map of read groups.
A reference seqeuence dictionary.