Skip to main content

FmdIndex

Struct FmdIndex 

Source
pub struct FmdIndex { /* private fields */ }
Expand description

Bidirectional FM-Index (FMD-Index) for strand-aware DNA search.

Indexes the concatenation text#reverse_complement(text)$ to enable efficient bidirectional extension for finding super-maximal exact matches (SMEMs).

Implementations§

Source§

impl FmdIndex

Source

pub fn new(seq: &[u8]) -> Self

Build an FMD-Index from a DNA sequence.

The input seq should contain only A, C, G, T characters. Internally constructs the concatenation seq#rev_comp(seq)$ and builds both the forward and reverse FM-indexes.

§Example
use cyanea_seq::fmd_index::FmdIndex;

let fmd = FmdIndex::new(b"ACGT");
let interval = fmd.backward_search(b"ACG");
assert!(!interval.is_empty());
Source

pub fn init_interval(&self, c: u8) -> BiInterval

Initialize a bi-interval for a single character.

Returns the interval representing all suffixes starting with c in both the forward and reverse indexes.

Source

pub fn extend_backward(&self, interval: &BiInterval, c: u8) -> BiInterval

Extend the bi-interval by prepending character c (backward extension).

This performs a standard backward search step on the forward index and updates the reverse interval accordingly.

Source

pub fn extend_forward(&self, interval: &BiInterval, c: u8) -> BiInterval

Extend the bi-interval by appending character c (forward extension).

This performs a backward search step on the reverse index and updates the forward interval accordingly.

Source

pub fn locate(&self, interval: &BiInterval) -> Vec<usize>

Retrieve text positions from a bi-interval.

Returns all suffix array positions within [0, text_len) — i.e., positions in the original sequence (not its reverse complement).

Full backward search for an exact pattern.

Processes the pattern from right to left using the forward index, returning the final bi-interval. The interval may be empty if the pattern is not found.

Source

pub fn smems( &self, query: &[u8], min_len: usize, ) -> Vec<(usize, usize, BiInterval)>

Find all Super-Maximal Exact Matches (SMEMs) of query against the index.

Returns a vector of (query_start, query_end, interval) triples, where query_start..query_end is the matching substring of the query. An SMEM is a maximal exact match that is not contained within any longer match at the same query position.

Only matches of length >= min_len are returned.

§Algorithm

For each starting position in the query, extend backward as far as possible, recording the maximal intervals. Then filter to retain only super-maximal matches — those not properly contained in another match.

Trait Implementations§

Source§

impl Clone for FmdIndex

Source§

fn clone(&self) -> FmdIndex

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FmdIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.