Struct noodles_sam::header::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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more