Struct noodles_sam::alignment::record_buf::RecordBuf
source · 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<&Name>
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());
sourcepub fn name_mut(&mut self) -> &mut Option<Name>
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));
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.
§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.
§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.
§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.
§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));