[][src]Trait seq_io::fastq::Record

pub trait Record: BaseRecord {
    fn qual(&self) -> &[u8];
fn full_qual(&self) -> Cow<'_, [u8]>;
fn full_qual_given<'s, F>(&'s self, owned_fn: F) -> Cow<'s, [u8]>
    where
        F: FnOnce() -> &'s mut Vec<u8>,
        Self: Sized
;
fn check_lengths(&self) -> Result<&Self, Error>; }

FASTQ record trait implemented by both RefRecord and OwnedRecord which adds more methods to BaseRecord.

Required methods

fn qual(&self) -> &[u8]

Return the FASTQ quality line as byte slice

fn full_qual(&self) -> Cow<'_, [u8]>

fn full_qual_given<'s, F>(&'s self, owned_fn: F) -> Cow<'s, [u8]> where
    F: FnOnce() -> &'s mut Vec<u8>,
    Self: Sized

fn check_lengths(&self) -> Result<&Self, Error>

Checks if the lengths of the sequence and quality lines are equal. If not, returns an error of ErrorKind::UnequalLengths.

RefRecord implementation

The RefRecord implementation (which is also used internally when Reader::next is called) defaults to not checking line ends, which is faster, but may lead to wrong results in very unusual cases. More precisely, RefRecord::check_lengths() first compares lengths without removing the line endings. If lengths are different, the check is repeated with line endings. The downside of this strategy is that it can theoretically lead to records with different line lengths being accepted (even if it's a very unlikely scenario, see example below).

If a more strict check for this corner case is required, use check_lengths_strict.

Example

use seq_io::prelude::*;
use seq_io::fastq::Reader;

let seq = b"@id\nAGT\n+\nII\r\n";

let mut reader = Reader::new(&seq[..]);
let record = reader.next().unwrap().unwrap();

// check not failing despite lengths being different
assert!(record.check_lengths().is_ok());

// more strict check fails
assert!(record.check_lengths_strict().is_err());

Note on errors

Record objects do not have any information about their position, within the file. Therefore, Error::position() will return None. Error::record_id() is always defined. In contrast, errors of ErrorKind::UnequalLengths returned by Reader::next will contain the correct position.

Loading content...

Implementors

impl Record for OwnedRecord[src]

impl<'a, S> Record for RefRecord<'a, S> where
    S: PositionStore
[src]

Loading content...