Struct bio::data_structures::qgram_index::QGramIndex
source · [−]pub struct QGramIndex { /* private fields */ }
Expand description
A classical, flexible, q-gram index implementation.
Uses |alphabet|^q + k words of memory, where k is the number of q-grams in the text with count at most max_count
(if specified).
Implementations
sourceimpl QGramIndex
impl QGramIndex
sourcepub fn new<'a, T, I>(q: u32, text: T, alphabet: &Alphabet) -> Self where
I: Iterator<Item = &'a u8> + ExactSizeIterator + Clone,
T: IntoIterator<Item = &'a u8, IntoIter = I> + Sized,
pub fn new<'a, T, I>(q: u32, text: T, alphabet: &Alphabet) -> Self where
I: Iterator<Item = &'a u8> + ExactSizeIterator + Clone,
T: IntoIterator<Item = &'a u8, IntoIter = I> + Sized,
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<'a, T, I>(
q: u32,
text: T,
alphabet: &Alphabet,
max_count: usize
) -> Self where
I: Iterator<Item = &'a u8> + ExactSizeIterator + Clone,
T: IntoIterator<Item = &'a u8, IntoIter = I> + Sized,
pub fn with_max_count<'a, T, I>(
q: u32,
text: T,
alphabet: &Alphabet,
max_count: usize
) -> Self where
I: Iterator<Item = &'a u8> + ExactSizeIterator + Clone,
T: IntoIterator<Item = &'a u8, IntoIter = I> + Sized,
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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn matches(&self, pattern: &[u8], min_count: usize) -> Vec<Match>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return matches of the given pattern, matching in at least min_count
q-grams.
Complexity O(m + k) for pattern of length m and k being the number of matching q-grams.
A match is a substring of pattern
and a corresponding substring of the text that share at least min_count
q-grams.
sourcepub fn exact_matches(&self, pattern: &[u8]) -> Vec<ExactMatch>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn exact_matches(&self, pattern: &[u8]) -> Vec<ExactMatch>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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.
An exact match is a substring of pattern
occurring in the text of length at least q
.
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.