Struct noodles_sam::alignment::record_buf::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<&Name>

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

Returns a mutable reference to the name.

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

let name = Name::from(b"r1");

let mut record = sam::alignment::RecordBuf::default();
*record.name_mut() = Some(name.clone());

assert_eq!(record.name(), Some(&name));
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.

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

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

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

§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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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<Box<dyn Name + '_>>

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.
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.
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) -> Result<Option<usize>>

Returns the alignment span.
source§

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

Calculates the end position.
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> 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> ToOwned for T
where T: Clone,

§

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

§

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