Struct bio::data_structures::qgram_index::QGramIndex
source · pub struct QGramIndex { /* private fields */ }
Expand description
A classical, flexible, q-gram index implementation.
Implementations
sourceimpl QGramIndex
impl QGramIndex
sourcepub fn new(q: u32, text: &[u8], alphabet: &Alphabet) -> Self
pub fn new(q: u32, text: &[u8], alphabet: &Alphabet) -> Self
Create a new q-gram index.
The q has to be smaller than b / log2(|A|) with |A| being the alphabet size and b the number
bits with the usize
data type.
sourcepub fn with_max_count(
q: u32,
text: &[u8],
alphabet: &Alphabet,
max_count: usize
) -> Self
pub fn with_max_count(
q: u32,
text: &[u8],
alphabet: &Alphabet,
max_count: usize
) -> Self
Create a new q-gram index, only considering q-grams that occur at most max_count
times.
The q has to be smaller than b / log2(|A|) with |A| being the alphabet size and b the number
bits with the usize
data type.
sourcepub fn qgram_matches(&self, qgram: usize) -> &[usize]
pub fn qgram_matches(&self, qgram: usize) -> &[usize]
Return text positions with matching q-gram. Complexity O(1).
sourcepub fn matches(&self, pattern: &[u8], min_count: usize) -> Vec<Match> ⓘ
pub fn matches(&self, pattern: &[u8], min_count: usize) -> Vec<Match> ⓘ
Return matches of the given pattern. Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.
sourcepub fn exact_matches(&self, pattern: &[u8]) -> Vec<ExactMatch> ⓘ
pub fn exact_matches(&self, pattern: &[u8]) -> Vec<ExactMatch> ⓘ
Return exact matches (substrings) of the given pattern. Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for QGramIndex
impl<'de> Deserialize<'de> for QGramIndex
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Serialize for QGramIndex
impl Serialize for QGramIndex
Auto Trait Implementations
impl RefUnwindSafe for QGramIndex
impl Send for QGramIndex
impl Sync for QGramIndex
impl Unpin for QGramIndex
impl UnwindSafe for QGramIndex
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more