pub struct RecordBuilder { /* private fields */ }Expand description
Builder for creating individual BAM/SAM records without a parent SamBuilder.
This builder simplifies test record creation by providing a chainable interface
for setting all record fields. All fields have sensible defaults. Unlike
SamBuilder, this creates records directly without accumulating them.
§Examples
use fgumi_sam::builder::{RecordBuilder, ConsensusTagsBuilder};
use noodles::sam::alignment::record::Flags;
// Create a simple unmapped read
let record = RecordBuilder::new()
.name("read1")
.sequence("ACGT")
.qualities(&[30, 30, 30, 30])
.build();
// Create a mapped paired-end R1
let r1 = RecordBuilder::new()
.name("read1")
.sequence("ACGTACGT")
.qualities(&[30; 8])
.paired(true)
.first_segment(true)
.reference_sequence_id(0)
.alignment_start(100)
.cigar("8M")
.mapping_quality(60)
.build();
// Create a record with tags
let record = RecordBuilder::new()
.name("read1")
.sequence("ACGT")
.tag("RG", "A")
.tag("MI", "AAAA-CCCC/A")
.build();Implementations§
Source§impl RecordBuilder
impl RecordBuilder
Sourcepub fn new() -> RecordBuilder
pub fn new() -> RecordBuilder
Creates a new builder with default values.
Sourcepub fn mapped_read() -> RecordBuilder
pub fn mapped_read() -> RecordBuilder
Creates a new builder pre-configured for a typical mapped read.
Sets common defaults:
reference_sequence_id: 0mapping_quality: 60- CIGAR will be auto-generated as
{len}Mif not explicitly set
§Examples
use fgumi_sam::builder::RecordBuilder;
use noodles::sam::alignment::record::Cigar;
let record = RecordBuilder::mapped_read()
.name("read1")
.sequence("ACGTACGT")
.alignment_start(100)
.build();
assert_eq!(record.reference_sequence_id(), Some(0));
assert!(!record.cigar().is_empty()); // Auto-generated as "8M"Sourcepub fn name(self, name: &str) -> RecordBuilder
pub fn name(self, name: &str) -> RecordBuilder
Sets the read name.
Sourcepub fn sequence(self, seq: &str) -> RecordBuilder
pub fn sequence(self, seq: &str) -> RecordBuilder
Sets the sequence.
Sourcepub fn qualities(self, quals: &[u8]) -> RecordBuilder
pub fn qualities(self, quals: &[u8]) -> RecordBuilder
Sets the quality scores (Phred+33 ASCII).
Sourcepub fn flags(self, flags: Flags) -> RecordBuilder
pub fn flags(self, flags: Flags) -> RecordBuilder
Sets all flags at once.
Sourcepub fn paired(self, paired: bool) -> RecordBuilder
pub fn paired(self, paired: bool) -> RecordBuilder
Sets the paired flag.
Sourcepub fn first_segment(self, is_first: bool) -> RecordBuilder
pub fn first_segment(self, is_first: bool) -> RecordBuilder
Sets the first segment (R1) flag. Implies paired.
Sourcepub fn properly_paired(self, properly_paired: bool) -> RecordBuilder
pub fn properly_paired(self, properly_paired: bool) -> RecordBuilder
Sets the properly paired flag. Implies paired.
Sourcepub fn unmapped(self, unmapped: bool) -> RecordBuilder
pub fn unmapped(self, unmapped: bool) -> RecordBuilder
Sets the unmapped flag.
Sourcepub fn reverse_complement(self, reverse: bool) -> RecordBuilder
pub fn reverse_complement(self, reverse: bool) -> RecordBuilder
Sets the reverse complement flag.
Sourcepub fn secondary(self, secondary: bool) -> RecordBuilder
pub fn secondary(self, secondary: bool) -> RecordBuilder
Sets the secondary alignment flag.
Sourcepub fn supplementary(self, supplementary: bool) -> RecordBuilder
pub fn supplementary(self, supplementary: bool) -> RecordBuilder
Sets the supplementary alignment flag.
Sourcepub fn reference_sequence_id(self, id: usize) -> RecordBuilder
pub fn reference_sequence_id(self, id: usize) -> RecordBuilder
Sets the reference sequence ID (0-based).
Sourcepub fn alignment_start(self, pos: usize) -> RecordBuilder
pub fn alignment_start(self, pos: usize) -> RecordBuilder
Sets the alignment start position (1-based).
Sourcepub fn mapping_quality(self, mapq: u8) -> RecordBuilder
pub fn mapping_quality(self, mapq: u8) -> RecordBuilder
Sets the mapping quality.
Sourcepub fn cigar(self, cigar: &str) -> RecordBuilder
pub fn cigar(self, cigar: &str) -> RecordBuilder
Sets the CIGAR string.
Sourcepub fn mate_reference_sequence_id(self, id: usize) -> RecordBuilder
pub fn mate_reference_sequence_id(self, id: usize) -> RecordBuilder
Sets the mate reference sequence ID (0-based).
Sourcepub fn mate_alignment_start(self, pos: usize) -> RecordBuilder
pub fn mate_alignment_start(self, pos: usize) -> RecordBuilder
Sets the mate alignment start position (1-based).
Sourcepub fn template_length(self, tlen: i32) -> RecordBuilder
pub fn template_length(self, tlen: i32) -> RecordBuilder
Sets the template length (insert size).
Sourcepub fn mate_reverse_complement(self, reverse: bool) -> RecordBuilder
pub fn mate_reverse_complement(self, reverse: bool) -> RecordBuilder
Sets the mate reverse complement flag.
Sourcepub fn mate_unmapped(self, unmapped: bool) -> RecordBuilder
pub fn mate_unmapped(self, unmapped: bool) -> RecordBuilder
Sets the mate unmapped flag.
Sourcepub fn tag<V>(self, tag: &str, value: V) -> RecordBuilder
pub fn tag<V>(self, tag: &str, value: V) -> RecordBuilder
Adds a SAM tag.
§Examples
use fgumi_sam::builder::RecordBuilder;
let record = RecordBuilder::new()
.name("read1")
.tag("RG", "A")
.tag("MI", "AAAA-CCCC/A")
.build();Adds consensus tags using a ConsensusTagsBuilder.
§Examples
use fgumi_sam::builder::{RecordBuilder, ConsensusTagsBuilder};
let record = RecordBuilder::new()
.sequence("ACGT")
.consensus_tags(
ConsensusTagsBuilder::new()
.depth_max(10)
.depth_min(5)
.error_rate(0.01)
)
.build();Trait Implementations§
Source§impl Debug for RecordBuilder
impl Debug for RecordBuilder
Source§impl Default for RecordBuilder
impl Default for RecordBuilder
Source§fn default() -> RecordBuilder
fn default() -> RecordBuilder
Auto Trait Implementations§
impl Freeze for RecordBuilder
impl RefUnwindSafe for RecordBuilder
impl Send for RecordBuilder
impl Sync for RecordBuilder
impl Unpin for RecordBuilder
impl UnsafeUnpin for RecordBuilder
impl UnwindSafe for RecordBuilder
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more