[−][src]Trait seq_io::fastx::Record
FASTX record trait implemented by both RefRecord
and OwnedRecord
which adds more methods to BaseRecord
.
Required methods
fn write_wrap<W>(&self, writer: W, wrap: usize) -> Result<()> where
W: Write,
W: Write,
Write the record to the given io::Write
instance. For FASTA,
the sequence is wrapped to produce multi-line FASTA with a
maximum width specified by wrap
.
Wrapping FASTQ sequence and quality lines is explicitly not supported
because such files are prone to parsing problems.
fn write_as<W>(
&self,
writer: W,
format: SeqFormat,
wrap_fasta: Option<usize>
) -> Result<()> where
W: Write,
&self,
writer: W,
format: SeqFormat,
wrap_fasta: Option<usize>
) -> Result<()> where
W: Write,
Writes the record to an output given a sequence format.
FASTA lines can be wrapped by specifying wrap_fasta = Some(width)
.
Panics
Panics if SeqFormat::FASTQ
was specified, but there is no quality
information available becase the input is FASTA.
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::fastx::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.
Implementors
impl Record for OwnedRecord
[src]
fn write_wrap<W>(&self, writer: W, wrap: usize) -> Result<()> where
W: Write,
[src]
W: Write,
fn write_as<W>(
&self,
writer: W,
format: SeqFormat,
wrap_fasta: Option<usize>
) -> Result<()> where
W: Write,
[src]
&self,
writer: W,
format: SeqFormat,
wrap_fasta: Option<usize>
) -> Result<()> where
W: Write,
fn check_lengths(&self) -> Result<&Self, Error>
[src]
impl<'a, S> Record for RefRecord<'a, S> where
S: PositionStore,
[src]
S: PositionStore,