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§
source§impl QGramIndex
impl QGramIndex
sourcepub fn new<'a, T, I>(q: u32, text: T, alphabet: &Alphabet) -> Selfwhere
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) -> Selfwhere 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
) -> Selfwhere
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 ) -> Selfwhere 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>
pub fn matches(&self, pattern: &[u8], min_count: usize) -> Vec<Match>
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>
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.
An exact match is a substring of pattern
occurring in the text of length at least q
.
Trait Implementations§
source§impl Clone for QGramIndex
impl Clone for QGramIndex
source§fn clone(&self) -> QGramIndex
fn clone(&self) -> QGramIndex
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for QGramIndex
impl Debug for QGramIndex
source§impl Default for QGramIndex
impl Default for QGramIndex
source§fn default() -> QGramIndex
fn default() -> QGramIndex
source§impl<'de> Deserialize<'de> for QGramIndex
impl<'de> Deserialize<'de> for QGramIndex
source§fn 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>,
source§impl Hash for QGramIndex
impl Hash for QGramIndex
source§impl Ord for QGramIndex
impl Ord for QGramIndex
source§fn cmp(&self, other: &QGramIndex) -> Ordering
fn cmp(&self, other: &QGramIndex) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<QGramIndex> for QGramIndex
impl PartialEq<QGramIndex> for QGramIndex
source§fn eq(&self, other: &QGramIndex) -> bool
fn eq(&self, other: &QGramIndex) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<QGramIndex> for QGramIndex
impl PartialOrd<QGramIndex> for QGramIndex
source§fn partial_cmp(&self, other: &QGramIndex) -> Option<Ordering>
fn partial_cmp(&self, other: &QGramIndex) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for QGramIndex
impl Serialize for QGramIndex
impl Eq for QGramIndex
impl StructuralEq for QGramIndex
impl StructuralPartialEq 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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.