pub struct RecordBuf { /* private fields */ }
Expand description
An alignment record buffer.
Implementations§
Source§impl RecordBuf
impl RecordBuf
Sourcepub fn try_from_alignment_record<R>(header: &Header, record: &R) -> Result<Self>where
R: Record,
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
impl RecordBuf
Sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates an alignment record builder.
§Examples
use noodles_sam as sam;
let builder = sam::alignment::RecordBuf::builder();
Sourcepub fn name(&self) -> Option<&BStr>
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());
Sourcepub fn name_mut(&mut self) -> &mut Option<BString>
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()));
Sourcepub fn flags(&self) -> Flags
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);
Sourcepub fn flags_mut(&mut self) -> &mut Flags
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());
Sourcepub fn reference_sequence_id(&self) -> Option<usize>
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());
Sourcepub fn reference_sequence_id_mut(&mut self) -> &mut Option<usize>
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));
Sourcepub fn alignment_start(&self) -> Option<Position>
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());
Sourcepub fn alignment_start_mut(&mut self) -> &mut Option<Position>
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));
Sourcepub fn mapping_quality(&self) -> Option<MappingQuality>
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());
Sourcepub fn mapping_quality_mut(&mut self) -> &mut Option<MappingQuality>
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));
Sourcepub fn cigar(&self) -> &Cigar
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());
Sourcepub fn cigar_mut(&mut self) -> &mut Cigar
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);
Sourcepub fn mate_reference_sequence_id(&self) -> Option<usize>
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());
Sourcepub fn mate_reference_sequence_id_mut(&mut self) -> &mut Option<usize>
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));
Sourcepub fn mate_alignment_start(&self) -> Option<Position>
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());
Sourcepub fn mate_alignment_start_mut(&mut self) -> &mut Option<Position>
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));
Sourcepub fn template_length(&self) -> i32
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);
Sourcepub fn template_length_mut(&mut self) -> &mut i32
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);
Sourcepub fn sequence(&self) -> &Sequence
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());
Sourcepub fn sequence_mut(&mut self) -> &mut Sequence
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);
Sourcepub fn quality_scores(&self) -> &QualityScores
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());
Sourcepub fn quality_scores_mut(&mut self) -> &mut QualityScores
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);
Sourcepub fn data(&self) -> &Data
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());
Sourcepub fn data_mut(&mut self) -> &mut Data
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);
Sourcepub fn reference_sequence<'a>(
&self,
header: &'a Header,
) -> Option<Result<(&'a [u8], &'a Map<ReferenceSequence>)>>
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());
Sourcepub fn mate_reference_sequence<'a>(
&self,
header: &'a Header,
) -> Option<Result<(&'a [u8], &'a Map<ReferenceSequence>)>>
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());
Sourcepub fn alignment_span(&self) -> Option<usize>
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());
Sourcepub fn alignment_end(&self) -> Option<Position>
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 Record for RecordBuf
impl Record for RecordBuf
Source§fn reference_sequence_id<'r, 'h: 'r>(
&'r self,
_: &'h Header,
) -> Option<Result<usize>>
fn reference_sequence_id<'r, 'h: 'r>( &'r self, _: &'h Header, ) -> Option<Result<usize>>
Source§fn mapping_quality(&self) -> Option<Result<MappingQuality>>
fn mapping_quality(&self) -> Option<Result<MappingQuality>>
Source§fn mate_reference_sequence_id<'r, 'h: 'r>(
&'r self,
_: &'h Header,
) -> Option<Result<usize>>
fn mate_reference_sequence_id<'r, 'h: 'r>( &'r self, _: &'h Header, ) -> Option<Result<usize>>
Source§fn mate_alignment_start(&self) -> Option<Result<Position>>
fn mate_alignment_start(&self) -> Option<Result<Position>>
Source§fn template_length(&self) -> Result<i32>
fn template_length(&self) -> Result<i32>
Source§fn quality_scores(&self) -> Box<dyn QualityScores + '_>
fn quality_scores(&self) -> Box<dyn QualityScores + '_>
Source§fn reference_sequence<'h>(
&self,
header: &'h Header,
) -> Option<Result<(&'h BStr, &'h Map<ReferenceSequence>)>>
fn reference_sequence<'h>( &self, header: &'h Header, ) -> Option<Result<(&'h BStr, &'h Map<ReferenceSequence>)>>
Source§fn mate_reference_sequence<'h>(
&self,
header: &'h Header,
) -> Option<Result<(&'h BStr, &'h Map<ReferenceSequence>)>>
fn mate_reference_sequence<'h>( &self, header: &'h Header, ) -> Option<Result<(&'h BStr, &'h Map<ReferenceSequence>)>>
impl StructuralPartialEq for RecordBuf
Auto Trait Implementations§
impl Freeze for RecordBuf
impl RefUnwindSafe for RecordBuf
impl Send for RecordBuf
impl Sync for RecordBuf
impl Unpin for RecordBuf
impl UnwindSafe for RecordBuf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)