[][src]Trait seq_io::PositionStore

pub trait PositionStore: Debug + Clone + Default + Send + Sync {
    type SeqLinesType: for<'a> LinesIterKind<'a>;
    type QualLinesType: for<'a> LinesIterKind<'a>;
    fn move_to_start(&mut self, search_pos: SearchPos, offset: usize);
fn set_record_start(&mut self, start: usize);
fn record_start(&self) -> usize;
fn set_seq_start(&mut self, pos: usize);
fn add_seq_line_start(&mut self, pos: usize);
fn seq_start(&self) -> usize;
fn seq_starts(&self) -> &[usize];
fn sep_pos(&self) -> usize;
fn qual_start(&self) -> usize;
fn set_record_end(&mut self, end: usize, has_line: bool);
fn record_end(&self) -> usize;
fn num_lines(&self) -> usize;
fn num_seq_lines(&self) -> usize;
fn line_offset(&self, search_pos: SearchPos, has_line: bool) -> usize;
fn seq_lines<'s>(
        &'s self,
        buffer: &'s [u8]
    ) -> <Self::SeqLinesType as LinesIterKind<'s>>::Out;
fn qual_lines<'s>(
        &'s self,
        _buffer: &'s [u8]
    ) -> <Self::QualLinesType as LinesIterKind<'s>>::Out; fn init(&mut self) { ... }
fn init_record(&mut self, start: usize) { ... }
fn set_sep_pos(&mut self, _pos: usize, _has_line: bool) { ... }
fn set_qual_start(&mut self, _pos: usize) { ... }
fn add_qual_line_start(&mut self, _pos: usize) { ... }
fn qual_starts(&self) -> &[usize] { ... }
fn has_qual(&self) -> bool { ... }
fn maybe_complete(&self) -> bool { ... }
fn num_qual_lines(&self) -> usize { ... }
fn head<'b>(&self, buffer: &'b [u8]) -> &'b [u8] { ... }
fn seq<'s>(&'s self, buffer: &'s [u8]) -> &'s [u8] { ... }
fn qual<'s>(&'s self, buffer: &'s [u8]) -> &'s [u8] { ... }
fn check_lengths(
        &self,
        buffer: &[u8],
        strict: bool
    ) -> Result<(), (usize, usize)> { ... }
fn join_seq<'a>(&'a self, buffer: &'a [u8]) -> Cow<'a, [u8]> { ... }
fn join_qual<'a>(&'a self, buffer: &'a [u8]) -> Cow<'a, [u8]> { ... }
fn join_seq_given<'a, F: FnOnce() -> &'a mut Vec<u8>>(
        &'a self,
        buffer: &'a [u8],
        owned_fn: F
    ) -> Cow<'a, [u8]> { ... }
fn join_qual_given<'a, F: FnOnce() -> &'a mut Vec<u8>>(
        &'a self,
        buffer: &'a [u8],
        owned_fn: F
    ) -> Cow<'a, [u8]> { ... }
fn from_other<S: PositionStore>(other: S) -> Self { ... } }

Trait for objects storing the coordinates of sequence records in the buffer.

The minimal methods required for FASTA parsing have to be implemented, FASTQ methods are optional (but should be implemented if storing quality data). A position store can of course choose to ignore some data by not doing anything in a method call.

Associated Types

type SeqLinesType: for<'a> LinesIterKind<'a>

type QualLinesType: for<'a> LinesIterKind<'a>

Loading content...

Required methods

fn move_to_start(&mut self, search_pos: SearchPos, offset: usize)

Move all stored coordinates back versus the start of the buffer by offset bytes. Reason: searcing got stuck due to reaching the end of the buffer. search_pos indicates in which part of the record searching got stuck. Everything that comes after search_pos should not be moved because it's not yet initialized for this record.

fn set_record_start(&mut self, start: usize)

Sets the start index of the record, always called first, may be called multiple times while skipping empty lines.

fn record_start(&self) -> usize

fn set_seq_start(&mut self, pos: usize)

Sets the start index of the sequence.

fn add_seq_line_start(&mut self, pos: usize)

Adds another sequence line start index.

fn seq_start(&self) -> usize

fn seq_starts(&self) -> &[usize]

fn sep_pos(&self) -> usize

fn qual_start(&self) -> usize

fn set_record_end(&mut self, end: usize, has_line: bool)

Sets the record end. Happens only if parsing was successful up to here, for FASTA it will be called after set_seq_start, [add_seq_line, ] and set_sep_pos. The index of the record end is actually the index of the actual record end (\n) + 1, which normally also is the potential start of the next record. A slice of FASTA sequence &buffer[pos.seq_start()..pos.record_end()] would thus include \n at the end, usually one would therefore use &buffer[pos.seq_start()..pos.record_end() - 1]. Including the newline may also fail at the end of the input if there is no newline (then, the record_end would be buffer length + 2!.

  • The has_line argument is usually true, it can be false if the record end is the same as the sequence start for FASTA, meaning that there is no sequence line. This is important to know, because the position may assume a sequence line when set_seq_start() was called, but the parser later finds then finds out that there actually isn't any. For FASTQ, this is not an issue because missing lines are not accepted.

fn record_end(&self) -> usize

fn num_lines(&self) -> usize

Returns the number of lines that the whole record covers. Used for incrementing the line counter of the parser, it should thus be correct!

fn num_seq_lines(&self) -> usize

Returns the number of lines that the sequence has. Should be correct, used when iterating, and a number > 1 will just take a slice of the whole sequence.

fn line_offset(&self, search_pos: SearchPos, has_line: bool) -> usize

fn seq_lines<'s>(
    &'s self,
    buffer: &'s [u8]
) -> <Self::SeqLinesType as LinesIterKind<'s>>::Out

Returns an iterator over sequence lines

fn qual_lines<'s>(
    &'s self,
    _buffer: &'s [u8]
) -> <Self::QualLinesType as LinesIterKind<'s>>::Out

Returns an iterator over quality lines

Loading content...

Provided methods

fn init(&mut self)

Initialize the record. Called before set_record_start(). This is the place to clear old information if necessary.

fn init_record(&mut self, start: usize)

Combines init() and set_record_start()

fn set_sep_pos(&mut self, _pos: usize, _has_line: bool)

Sets the start index of the FASTQ separator byte. This method is also called for FASTA records before set_record_end() with the same position. The has_line argument has the same meaning as there.

fn set_qual_start(&mut self, _pos: usize)

Set the start of the quality information. Only ever called on FASTQ records.

fn add_qual_line_start(&mut self, _pos: usize)

Adds another quality line start index (only multi-line FASTQ).

fn qual_starts(&self) -> &[usize]

fn has_qual(&self) -> bool

Should return, whether there is quality information present (e.g. test if set_qual_start() was called).

fn maybe_complete(&self) -> bool

Returns whether the position is complete in the sense that set_record_end() was called. In some cases, this may not be easy to determine, then true can be returned if record_end() will not panic

fn num_qual_lines(&self) -> usize

Returns the number of quality lines (1 if not multiline FASTQ, 0 if FASTA)

fn head<'b>(&self, buffer: &'b [u8]) -> &'b [u8]

Returns a slice of the head.

fn seq<'s>(&'s self, buffer: &'s [u8]) -> &'s [u8]

Returns a slice of the sequence.

fn qual<'s>(&'s self, buffer: &'s [u8]) -> &'s [u8]

Returns a slice of the quality information.

fn check_lengths(
    &self,
    buffer: &[u8],
    strict: bool
) -> Result<(), (usize, usize)>

fn join_seq<'a>(&'a self, buffer: &'a [u8]) -> Cow<'a, [u8]>

fn join_qual<'a>(&'a self, buffer: &'a [u8]) -> Cow<'a, [u8]>

fn join_seq_given<'a, F: FnOnce() -> &'a mut Vec<u8>>(
    &'a self,
    buffer: &'a [u8],
    owned_fn: F
) -> Cow<'a, [u8]>

fn join_qual_given<'a, F: FnOnce() -> &'a mut Vec<u8>>(
    &'a self,
    buffer: &'a [u8],
    owned_fn: F
) -> Cow<'a, [u8]>

fn from_other<S: PositionStore>(other: S) -> Self

Loading content...

Implementors

impl PositionStore for seq_io::fasta::single_line::RangeStore[src]

type SeqLinesType = LinePositionIterKind

type QualLinesType = LinePositionIterKind

impl PositionStore for seq_io::fasta::LineStore[src]

type SeqLinesType = LinePositionIterKind

type QualLinesType = LinePositionIterKind

impl PositionStore for MultiRangeStore[src]

type SeqLinesType = LinesParseKind

type QualLinesType = LinesParseKind

impl PositionStore for seq_io::fastq::RangeStore[src]

type SeqLinesType = LinePositionIterKind

type QualLinesType = LinePositionIterKind

impl PositionStore for seq_io::fastx::LineStore[src]

type SeqLinesType = LinePositionIterKind

type QualLinesType = LinePositionIterKind

Loading content...