noodles_sam::alignment::record_buf

Struct Builder

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

An alignment record builder.

Implementations§

Source§

impl Builder

Source

pub fn set_name<N>(self, name: N) -> Self
where N: Into<BString>,

Sets the read name.

§Examples
use bstr::ByteSlice;
use noodles_sam as sam;

let record = sam::alignment::RecordBuf::builder()
    .set_name("r1")
    .build();

assert_eq!(record.name(), Some(b"r1".as_bstr()));
Source

pub fn set_flags(self, flags: Flags) -> Self

Sets the flags.

§Examples
use noodles_sam::{self as sam, alignment::record::Flags};

let record = sam::alignment::RecordBuf::builder()
    .set_flags(Flags::empty())
    .build();

assert_eq!(record.flags(), Flags::empty());
Source

pub fn set_reference_sequence_id(self, reference_sequence_id: usize) -> Self

Sets the reference sequence ID.

§Examples
use noodles_sam as sam;

let record = sam::alignment::RecordBuf::builder()
    .set_reference_sequence_id(0)
    .build();

assert_eq!(record.reference_sequence_id(), Some(0));
Source

pub fn set_alignment_start(self, alignment_start: Position) -> Self

Sets the alignment start.

§Examples
use noodles_core::Position;
use noodles_sam as sam;

let record = sam::alignment::RecordBuf::builder()
    .set_alignment_start(Position::MIN)
    .build();

assert_eq!(record.alignment_start(), Some(Position::MIN));
Source

pub fn set_mapping_quality(self, mapping_quality: MappingQuality) -> Self

Sets the mapping quality.

§Examples
use noodles_sam::{self as sam, alignment::record::MappingQuality};

let record = sam::alignment::RecordBuf::builder()
    .set_mapping_quality(MappingQuality::MIN)
    .build();

assert_eq!(record.mapping_quality(), Some(MappingQuality::MIN));
Source

pub fn set_cigar(self, cigar: Cigar) -> Self

Sets the CIGAR operations.

§Examples
use noodles_sam::{
    self as sam,
    alignment::{
        record::cigar::{op::Kind, Op},
        record_buf::Cigar,
    },
};

let cigar: Cigar = [Op::new(Kind::Match, 4)].into_iter().collect();

let record = sam::alignment::RecordBuf::builder()
    .set_cigar(cigar.clone())
    .build();

assert_eq!(record.cigar(), &cigar);
Source

pub fn set_mate_reference_sequence_id( self, mate_reference_sequence_id: usize, ) -> Self

Sets the mate reference sequence ID.

§Examples
use noodles_sam as sam;

let record = sam::alignment::RecordBuf::builder()
    .set_mate_reference_sequence_id(0)
    .build();

assert_eq!(record.mate_reference_sequence_id(), Some(0));
Source

pub fn set_mate_alignment_start(self, mate_alignment_start: Position) -> Self

Sets the mate alignment start.

§Examples
use noodles_core::Position;
use noodles_sam as sam;

let record = sam::alignment::RecordBuf::builder()
    .set_mate_alignment_start(Position::MIN)
    .build();

assert_eq!(record.mate_alignment_start(), Some(Position::MIN));
Source

pub fn set_template_length(self, template_length: i32) -> Self

Sets the template length.

§Examples
use noodles_sam as sam;

let record = sam::alignment::RecordBuf::builder()
    .set_template_length(4)
    .build();

assert_eq!(record.template_length(), 4);
Source

pub fn set_sequence(self, sequence: Sequence) -> Self

Sets the sequence.

§Examples
use noodles_sam::{self as sam, alignment::record_buf::Sequence};

let sequence = Sequence::from(b"ACGT");

let record = sam::alignment::RecordBuf::builder()
    .set_sequence(sequence.clone())
    .build();

assert_eq!(record.sequence(), &sequence);
Source

pub fn set_quality_scores(self, quality_scores: QualityScores) -> Self

Sets the quality scores.

§Examples
use noodles_sam::{self as sam, alignment::record_buf::QualityScores};

let quality_scores = QualityScores::from(vec![45, 35, 43, 50]);

let record = sam::alignment::RecordBuf::builder()
    .set_quality_scores(quality_scores.clone())
    .build();

assert_eq!(record.quality_scores(), &quality_scores);
Source

pub fn set_data(self, data: Data) -> Self

Sets the data.

§Examples
use noodles_sam::{
    self as sam,
    alignment::{
        record::data::field::Tag,
        record_buf::{data::field::Value, Data},
    },
};

let data: Data = [(Tag::ALIGNMENT_HIT_COUNT, Value::from(1))]
    .into_iter()
    .collect();

let record = sam::alignment::RecordBuf::builder()
    .set_data(data.clone())
    .build();

assert_eq!(record.data(), &data);
Source

pub fn build(self) -> RecordBuf

Builds the alignment record.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::builder().build();
assert_eq!(record, sam::alignment::RecordBuf::default());

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() -> Self

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.