Struct noodles_sam::header::Builder
source · pub struct Builder { /* private fields */ }
Expand description
A SAM header builder.
Implementations§
source§impl Builder
impl Builder
sourcepub fn set_header(self, header: Map<Header>) -> Self
pub fn set_header(self, header: Map<Header>) -> Self
Sets a SAM header header.
§Examples
use noodles_sam as sam;
let header = sam::Header::builder()
.set_header(Default::default())
.build();
assert!(header.header().is_some());
sourcepub fn set_reference_sequences(
self,
reference_sequences: ReferenceSequences
) -> Self
pub fn set_reference_sequences( self, reference_sequences: ReferenceSequences ) -> Self
Sets the reference sequences.
§Examples
use std::num::NonZeroUsize;
use bstr::BString;
use noodles_sam::{
self as sam,
header::record::value::{map::ReferenceSequence, Map},
};
let reference_sequences = [(
BString::from("sq0"),
Map::<ReferenceSequence>::new(NonZeroUsize::try_from(13)?),
)]
.into_iter()
.collect();
let header = sam::Header::builder()
.set_reference_sequences(reference_sequences)
.build();
let reference_sequences = header.reference_sequences();
assert_eq!(reference_sequences.len(), 1);
assert!(reference_sequences.contains_key(&b"sq0"[..]));
sourcepub fn add_reference_sequence<N>(
self,
name: N,
reference_sequence: Map<ReferenceSequence>
) -> Self
pub fn add_reference_sequence<N>( self, name: N, reference_sequence: Map<ReferenceSequence> ) -> Self
Adds a reference sequence to the SAM header.
§Examples
use std::num::NonZeroUsize;
use noodles_sam::{
self as sam,
header::record::value::{map::ReferenceSequence, Map},
};
let header = sam::Header::builder()
.add_reference_sequence(
"sq0",
Map::<ReferenceSequence>::new(NonZeroUsize::try_from(13)?),
)
.build();
let reference_sequences = header.reference_sequences();
assert_eq!(reference_sequences.len(), 1);
assert!(reference_sequences.contains_key(&b"sq0"[..]));
sourcepub fn add_read_group<I>(self, id: I, map: Map<ReadGroup>) -> Self
pub fn add_read_group<I>(self, id: I, map: Map<ReadGroup>) -> Self
Adds a read group to the SAM header.
§Examples
use noodles_sam::{
self as sam,
header::record::value::{map::ReadGroup, Map},
};
let header = sam::Header::builder()
.add_read_group("rg0", Map::<ReadGroup>::default())
.build();
let read_groups = header.read_groups();
assert_eq!(read_groups.len(), 1);
assert!(read_groups.contains_key(&b"rg0"[..]));
sourcepub fn add_program<I>(self, id: I, map: Map<Program>) -> Self
pub fn add_program<I>(self, id: I, map: Map<Program>) -> Self
Adds a program to the SAM header.
§Examples
use noodles_sam::{self as sam, header::record::value::{map::Program, Map}};
let header = sam::Header::builder()
.add_program("noodles-sam", Map::<Program>::default())
.build();
let programs = header.programs();
assert_eq!(programs.as_ref().len(), 1);
assert!(programs.as_ref().contains_key(&b"noodles-sam"[..]));
sourcepub fn add_comment<C>(self, comment: C) -> Self
pub fn add_comment<C>(self, comment: C) -> Self
Adds a comment to the SAM header.
§Examples
use noodles_sam as sam;
let header = sam::Header::builder().add_comment("noodles-sam").build();
let comments = header.comments();
assert_eq!(comments.len(), 1);
assert_eq!(&comments[0], &b"noodles-sam"[..]);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more