pub struct RangeSearch<'a, Q: ?Sized> { /* private fields */ }Expand description
A subsequence along with its starting index. This is used for restricting the search range when performing a search. See Restricting the search range for more details.
It is compatible with:
- Performing string search via the
ByteSubstringtrait - Searching for k-mers using methods similar to those in
FindKmers - Searching for amino acids in a nucleotides sequence similar to methods in
Translate. This requires the original type to implementTranslatealso
Note
All search methods called on a RangeSearch struct return indices with
respect to the original sequence, not the subsequence.
§Parameters
Q tracks the type of the original sequence type. This controls whether
find_next_aa and find_next_aa_in_frame are available.
Implementations§
Source§impl<Q> RangeSearch<'_, Q>where
Q: Translate,
impl<Q> RangeSearch<'_, Q>where
Q: Translate,
Sourcepub fn find_next_aa(self, aa: u8) -> Option<usize>
pub fn find_next_aa(self, aa: u8) -> Option<usize>
Slides base by base over the sequence until the next translated aa is
found and returns that index (or None otherwise).
Sourcepub fn find_next_aa_in_frame(self, aa: u8) -> Option<usize>
pub fn find_next_aa_in_frame(self, aa: u8) -> Option<usize>
Slides codon by codon over the sequence (reading frame starting from 0
in the full sequence) until the next translated aa is found and
returns that index (or None otherwise).
This is different than calling Translate::find_next_aa_in_frame on a
slice, since it uses the reading frame of the full sequence, irrelevant
of the starting position of the search.
Source§impl<'a, Q: ?Sized> RangeSearch<'a, Q>
impl<'a, Q: ?Sized> RangeSearch<'a, Q>
Sourcepub fn position<P>(&self, predicate: P) -> Option<usize>
pub fn position<P>(&self, predicate: P) -> Option<usize>
Takes a closure and returns the index of the first byte found within
the sequence that satisfies the closure. Wraps Iterator::position.
Sourcepub fn rposition<P>(&self, predicate: P) -> Option<usize>
pub fn rposition<P>(&self, predicate: P) -> Option<usize>
Takes a closure and returns the index of the last byte found within the
sequence that satisfies the closure. Wraps Iterator::rposition.
Sourcepub fn find_kmers<const MAX_LEN: usize, T>(
self,
kmers: &T,
) -> Option<Range<usize>>where
T: FindKmersInSeq<MAX_LEN>,
pub fn find_kmers<const MAX_LEN: usize, T>(
self,
kmers: &T,
) -> Option<Range<usize>>where
T: FindKmersInSeq<MAX_LEN>,
Returns the indices of the leftmost occurrence of any of the k-mers in the passed collection.
If no occurrence is found, then None is returned. To find all matches
rather than just the first, use find_all_kmers. A similar
unrestricted version of this method exists in FindKmers.
Sourcepub fn find_kmers_rev<const MAX_LEN: usize, T>(
self,
kmers: &T,
) -> Option<Range<usize>>where
T: FindKmersInSeq<MAX_LEN>,
pub fn find_kmers_rev<const MAX_LEN: usize, T>(
self,
kmers: &T,
) -> Option<Range<usize>>where
T: FindKmersInSeq<MAX_LEN>,
Returns the indices of the rightmost occurrence of any of the k-mers in the passed collection.
If no occurrence is found, then None is returned. To find all matches
rather than just the last, use find_all_kmers. A similar
unrestricted version of this method exists in FindKmers.
Sourcepub fn find_all_kmers<const MAX_LEN: usize, T>(
self,
kmers: &'a T,
) -> impl Iterator<Item = Range<usize>> + 'awhere
Q: 'a,
T: FindKmersInSeq<MAX_LEN>,
pub fn find_all_kmers<const MAX_LEN: usize, T>(
self,
kmers: &'a T,
) -> impl Iterator<Item = Range<usize>> + 'awhere
Q: 'a,
T: FindKmersInSeq<MAX_LEN>,
Returns an iterator over the indices of all matches between the k-mers in the sequence and those in the passed collection.
Consider using find_kmers if only a single match is needed. A
similar unrestricted version of this method exists in FindKmers.
Sourcepub fn find_all_kmers_rev<const MAX_LEN: usize, T>(
self,
kmers: &'a T,
) -> impl Iterator<Item = Range<usize>> + 'awhere
Q: 'a,
T: FindKmersInSeq<MAX_LEN>,
pub fn find_all_kmers_rev<const MAX_LEN: usize, T>(
self,
kmers: &'a T,
) -> impl Iterator<Item = Range<usize>> + 'awhere
Q: 'a,
T: FindKmersInSeq<MAX_LEN>,
Returns an iterator over the indices of all matches between the k-mers in the sequence and those in the passed collection, in reverse order.
Consider using find_kmers_rev if only a single match is needed. A
similar unrestricted version of this method exists in FindKmers.
Trait Implementations§
Source§impl<Q: ?Sized> ByteSubstring for RangeSearch<'_, Q>
impl<Q: ?Sized> ByteSubstring for RangeSearch<'_, Q>
Source§fn contains_substring(&self, needle: impl AsRef<[u8]>) -> bool
fn contains_substring(&self, needle: impl AsRef<[u8]>) -> bool
true is the substring is found and false if not. Searches in
the forward direction.Source§fn find_substring(&self, needle: impl AsRef<[u8]>) -> Option<Range<usize>>
fn find_substring(&self, needle: impl AsRef<[u8]>) -> Option<Range<usize>>
None if not. Searches in
the forward direction.Source§fn find_fuzzy_substring<const DIFFERENCES_ALLOWED: usize>(
&self,
needle: impl AsRef<[u8]>,
) -> Option<Range<usize>>
fn find_fuzzy_substring<const DIFFERENCES_ALLOWED: usize>( &self, needle: impl AsRef<[u8]>, ) -> Option<Range<usize>>
Source§fn find_byte(&self, byte: u8) -> Option<usize>
fn find_byte(&self, byte: u8) -> Option<usize>
byte in the haystack.Source§fn find_repeating_byte(&self, needle: u8, size: usize) -> Option<Range<usize>>
fn find_repeating_byte(&self, needle: u8, size: usize) -> Option<Range<usize>>
find_k_repeating
for more details.