noodles_sam::alignment::record_buf

Struct RecordBuf

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

An alignment record buffer.

Implementations§

Source§

impl RecordBuf

Source

pub fn try_from_alignment_record<R>(header: &Header, record: &R) -> Result<Self>
where R: Record,

Converts an alignment record to a buffer.

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

let header = sam::Header::default();
let record = sam::Record::default();

let record_buf = RecordBuf::try_from_alignment_record(&header, &record)?;

assert_eq!(record_buf, RecordBuf::default());
Source§

impl RecordBuf

Source

pub fn builder() -> Builder

Creates an alignment record builder.

§Examples
use noodles_sam as sam;
let builder = sam::alignment::RecordBuf::builder();
Source

pub fn name(&self) -> Option<&BStr>

Returns the name.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.name().is_none());
Source

pub fn name_mut(&mut self) -> &mut Option<BString>

Returns a mutable reference to the name.

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

let mut record = sam::alignment::RecordBuf::default();
*record.name_mut() = Some("r1".into());

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

pub fn flags(&self) -> Flags

Returns the flags.

§Examples
use noodles_sam::{self as sam, alignment::record::Flags};
let record = sam::alignment::RecordBuf::default();
assert_eq!(record.flags(), Flags::UNMAPPED);
Source

pub fn flags_mut(&mut self) -> &mut Flags

Returns a mutable reference to the flags.

§Examples
use noodles_sam::{self as sam, alignment::record::Flags};
let mut record = sam::alignment::RecordBuf::default();
*record.flags_mut() = Flags::empty();
assert!(record.flags().is_empty());
Source

pub fn reference_sequence_id(&self) -> Option<usize>

Returns the reference sequence ID.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.reference_sequence_id().is_none());
Source

pub fn reference_sequence_id_mut(&mut self) -> &mut Option<usize>

Returns a mutable reference to the reference sequence ID.

§Examples
use noodles_sam as sam;
let mut record = sam::alignment::RecordBuf::default();
*record.reference_sequence_id_mut() = Some(0);
assert_eq!(record.reference_sequence_id(), Some(0));
Source

pub fn alignment_start(&self) -> Option<Position>

Returns the alignment start.

This position is 1-based, inclusive.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.alignment_start().is_none());
Source

pub fn alignment_start_mut(&mut self) -> &mut Option<Position>

Returns a mutable reference to the alignment start.

This position is 1-based, inclusive.

§Examples
use noodles_core::Position;
use noodles_sam as sam;
let mut record = sam::alignment::RecordBuf::default();
*record.alignment_start_mut() = Some(Position::MIN);
assert_eq!(record.alignment_start(), Some(Position::MIN));
Source

pub fn mapping_quality(&self) -> Option<MappingQuality>

Returns the mapping quality.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.mapping_quality().is_none());
Source

pub fn mapping_quality_mut(&mut self) -> &mut Option<MappingQuality>

Returns a mutable reference to the mapping quality.

§Examples
use noodles_sam::{self as sam, alignment::record::MappingQuality};
let mut record = sam::alignment::RecordBuf::default();
*record.mapping_quality_mut() = Some(MappingQuality::MIN);
assert_eq!(record.mapping_quality(), Some(MappingQuality::MIN));
Source

pub fn cigar(&self) -> &Cigar

Returns the CIGAR operations.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.cigar().as_ref().is_empty());
Source

pub fn cigar_mut(&mut self) -> &mut Cigar

Returns a mutable reference to 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 mut record = sam::alignment::RecordBuf::default();
*record.cigar_mut() = cigar.clone();

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

pub fn mate_reference_sequence_id(&self) -> Option<usize>

Returns the mate reference sequence ID.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.mate_reference_sequence_id().is_none());
Source

pub fn mate_reference_sequence_id_mut(&mut self) -> &mut Option<usize>

Returns a mutable reference to the mate reference sequence ID.

§Examples
use noodles_sam as sam;
let mut record = sam::alignment::RecordBuf::default();
*record.mate_reference_sequence_id_mut() = Some(0);
assert_eq!(record.mate_reference_sequence_id(), Some(0));
Source

pub fn mate_alignment_start(&self) -> Option<Position>

Returns the mate alignment start.

This position is 1-based, inclusive.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.mate_alignment_start().is_none());
Source

pub fn mate_alignment_start_mut(&mut self) -> &mut Option<Position>

Returns a mutable reference to the mate alignment start.

This position is 1-based, inclusive.

§Examples
use noodles_core::Position;
use noodles_sam as sam;
let mut record = sam::alignment::RecordBuf::default();
*record.mate_alignment_start_mut() = Some(Position::MIN);
assert_eq!(record.mate_alignment_start(), Some(Position::MIN));
Source

pub fn template_length(&self) -> i32

Returns the template length.

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

pub fn template_length_mut(&mut self) -> &mut i32

Returns a mutable reference to template length.

§Examples
use noodles_sam as sam;
let mut record = sam::alignment::RecordBuf::default();
*record.template_length_mut() = 4;
assert_eq!(record.template_length(), 4);
Source

pub fn sequence(&self) -> &Sequence

Returns the sequence.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.sequence().is_empty());
Source

pub fn sequence_mut(&mut self) -> &mut Sequence

Returns a mutable reference to sequence.

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

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

let mut record = sam::alignment::RecordBuf::default();
*record.sequence_mut() = sequence.clone();

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

pub fn quality_scores(&self) -> &QualityScores

Returns the quality scores.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.quality_scores().is_empty());
Source

pub fn quality_scores_mut(&mut self) -> &mut QualityScores

Returns a mutable reference to quality scores.

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

let quality_scores = QualityScores::default();

let mut record = sam::alignment::RecordBuf::default();
*record.quality_scores_mut() = quality_scores.clone();

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

pub fn data(&self) -> &Data

Returns the data.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.data().is_empty());
Source

pub fn data_mut(&mut self) -> &mut Data

Returns a mutable reference to 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 mut record = sam::alignment::RecordBuf::default();
*record.data_mut() = data.clone();

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

pub fn reference_sequence<'a>( &self, header: &'a Header, ) -> Option<Result<(&'a [u8], &'a Map<ReferenceSequence>)>>

Returns the associated reference sequence.

§Examples
use noodles_sam as sam;
let header = sam::Header::default();
let record = sam::alignment::RecordBuf::default();
assert!(record.reference_sequence(&header).is_none());
Source

pub fn mate_reference_sequence<'a>( &self, header: &'a Header, ) -> Option<Result<(&'a [u8], &'a Map<ReferenceSequence>)>>

Returns the associated mate reference sequence.

§Examples
use noodles_sam as sam;
let header = sam::Header::default();
let record = sam::alignment::RecordBuf::default();
assert!(record.mate_reference_sequence(&header).is_none());
Source

pub fn alignment_span(&self) -> Option<usize>

Returns the alignment span.

§Examples
use noodles_sam as sam;
let record = sam::alignment::RecordBuf::default();
assert!(record.alignment_span().is_none());
Source

pub fn alignment_end(&self) -> Option<Position>

Calculates the end position.

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

let record = sam::alignment::RecordBuf::builder()
    .set_alignment_start(Position::try_from(8)?)
    .set_cigar([Op::new(Kind::Match, 5)].into_iter().collect())
    .build();

assert_eq!(record.alignment_end(), Position::new(12));

Trait Implementations§

Source§

impl Clone for RecordBuf

Source§

fn clone(&self) -> RecordBuf

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RecordBuf

Source§

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

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

impl Default for RecordBuf

Source§

fn default() -> Self

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

impl PartialEq for RecordBuf

Source§

fn eq(&self, other: &RecordBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Record for RecordBuf

Source§

fn name(&self) -> Option<&BStr>

Returns the name.
Source§

fn flags(&self) -> Result<Flags>

Returns the flags.
Source§

fn reference_sequence_id<'r, 'h: 'r>( &'r self, _: &'h Header, ) -> Option<Result<usize>>

Returns the reference sequence ID.
Source§

fn alignment_start(&self) -> Option<Result<Position>>

Returns the alignment start. Read more
Source§

fn mapping_quality(&self) -> Option<Result<MappingQuality>>

Returns the mapping quality.
Source§

fn cigar(&self) -> Box<dyn Cigar + '_>

Returns the CIGAR operations.
Source§

fn mate_reference_sequence_id<'r, 'h: 'r>( &'r self, _: &'h Header, ) -> Option<Result<usize>>

Returns the mate reference sequence ID.
Source§

fn mate_alignment_start(&self) -> Option<Result<Position>>

Returns the mate alignment start. Read more
Source§

fn template_length(&self) -> Result<i32>

Returns the template length.
Source§

fn sequence(&self) -> Box<dyn Sequence + '_>

Returns the sequence.
Source§

fn quality_scores(&self) -> Box<dyn QualityScores + '_>

Returns the quality scores.
Source§

fn data(&self) -> Box<dyn Data + '_>

Returns the data.
Source§

fn reference_sequence<'h>( &self, header: &'h Header, ) -> Option<Result<(&'h BStr, &'h Map<ReferenceSequence>)>>

Returns the associated reference sequence.
Source§

fn mate_reference_sequence<'h>( &self, header: &'h Header, ) -> Option<Result<(&'h BStr, &'h Map<ReferenceSequence>)>>

Returns the associated mate reference sequence.
Source§

fn alignment_span(&self) -> Option<Result<usize>>

Returns the alignment span.
Source§

fn alignment_end(&self) -> Option<Result<Position>>

Calculates the end position. Read more
Source§

impl StructuralPartialEq for RecordBuf

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.