pub struct Record { /* private fields */ }
Expand description
An instance of a Fastx Record. This is a two attribute object containing the sequence ID and the Sequence.
Implementations§
source§impl Record
impl Record
sourcepub fn new() -> Self
pub fn new() -> Self
Usage
Creates a new instance of a [Record]
let record = fxread::Record::new();
assert!(record.empty());
sourcepub fn new_fasta(data: Vec<u8>, id: usize, seq: usize) -> Self
pub fn new_fasta(data: Vec<u8>, id: usize, seq: usize) -> Self
Usage
Creates a new instance of a [Record]
from a preinitialized
[Vec<u8>]
with the id
and seq
endpoints calculated. These
endpoints are inclusive of the ‘\n’ terminator and the data is
expected to exclude the prefix ‘>’ marker.
let data = b">seq.0\nACGT\n".to_vec();
let id = 6;
let seq = 5;
let fasta = fxread::Record::new_fasta(data, id, seq);
assert_eq!(fasta.id(), b"seq.0");
assert_eq!(fasta.seq(), b"ACGT");
sourcepub fn new_fastq(
data: Vec<u8>,
id: usize,
seq: usize,
plus: usize,
qual: usize
) -> Self
pub fn new_fastq( data: Vec<u8>, id: usize, seq: usize, plus: usize, qual: usize ) -> Self
Usage
Creates a new instance of a [Record]
from a preinitialized
[Vec<u8>]
with the id
, seq
, plus
, and qual
endpoints calculated.
These endpoints are inclusive of the ‘\n’ terminator and the data is
expected to exclude the prefix ‘@’ marker.
let data = b"@seq.0\nACGT\n+\n1234\n".to_vec();
let id = 6;
let seq = 5;
let plus = 2;
let qual = 5;
let fasta = fxread::Record::new_fastq(data, id, seq, plus, qual);
assert_eq!(fasta.id(), b"seq.0");
assert_eq!(fasta.seq(), b"ACGT");
assert_eq!(fasta.plus().unwrap(), b"+");
assert_eq!(fasta.qual().unwrap(), b"1234");
sourcepub fn valid_header(&self) -> bool
pub fn valid_header(&self) -> bool
Checks if [Record]
has a valid header
sourcepub fn plus_range(&self) -> Option<Range<usize>>
pub fn plus_range(&self) -> Option<Range<usize>>
Returns the Range of the ‘+’ region of a fastq
sourcepub fn qual_range(&self) -> Option<Range<usize>>
pub fn qual_range(&self) -> Option<Range<usize>>
Returns the Range of the quality score if it exists
sourcepub fn qual_mut(&mut self) -> Option<&mut [u8]>
pub fn qual_mut(&mut self) -> Option<&mut [u8]>
Returns a mutable reference of the quality score if it exists
sourcepub fn valid(&self) -> bool
pub fn valid(&self) -> bool
Validates that the record is not partially constructed or composed of unexpected nucleotides
sourcepub fn seq_rev_comp(&self) -> Vec<u8>
pub fn seq_rev_comp(&self) -> Vec<u8>
Reverse Complements the sequence
sourcepub fn rev_comp(&mut self)
pub fn rev_comp(&mut self)
Reverse Complements the sequence in place Also reverses the quality scores if present
sourcepub fn trim_left(&mut self, size: usize) -> Result<()>
pub fn trim_left(&mut self, size: usize) -> Result<()>
Trims the nucleotides from the left of the sequence and the corresponding quality scores if present Returns an error if the size is greater than the sequence length
sourcepub fn trim_right(&mut self, size: usize) -> Result<()>
pub fn trim_right(&mut self, size: usize) -> Result<()>
Trims the nucleotides from the right of the sequence and the corresponding quality scores if present Returns an error if the size is greater than the sequence length
sourcepub fn as_str_checked(&self) -> Result<&str, Utf8Error>
pub fn as_str_checked(&self) -> Result<&str, Utf8Error>
Underlying record as str
sourcepub fn id_str_checked(&self) -> Result<&str, Utf8Error>
pub fn id_str_checked(&self) -> Result<&str, Utf8Error>
ID as str
sourcepub fn seq_str_checked(&self) -> Result<&str, Utf8Error>
pub fn seq_str_checked(&self) -> Result<&str, Utf8Error>
Sequence as str