noodles_sam::header

Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

A SAM header builder.

Implementations§

Source§

impl Builder

Source

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());
Source

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"[..]));
Source

pub fn add_reference_sequence<N>( self, name: N, reference_sequence: Map<ReferenceSequence>, ) -> Self
where N: Into<BString>,

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"[..]));
Source

pub fn add_read_group<I>(self, id: I, map: Map<ReadGroup>) -> Self
where I: Into<BString>,

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"[..]));
Source

pub fn add_program<I>(self, id: I, map: Map<Program>) -> Self
where I: Into<BString>,

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"[..]));
Source

pub fn add_comment<C>(self, comment: C) -> Self
where C: Into<BString>,

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"[..]);
Source

pub fn build(self) -> Header

Builds a SAM header.

§Examples
use noodles_sam as sam;
let header = sam::Header::builder().build();
assert!(header.is_empty());

Trait Implementations§

Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.