fn sample<DBWT: Borrow<BWT>, DLess: Borrow<Less>, DOcc: Borrow<Occ>>(
        &self,
        text: &[u8],
        bwt: DBWT,
        less: DLess,
        occ: DOcc,
        sampling_rate: usize,
    ) -> SampledSuffixArray<DBWT, DLess, DOcc> {
        let mut sample =
            Vec::with_capacity((self.len() as f32 / sampling_rate as f32).ceil() as usize);
        let mut extra_rows = HashMapFx::default();
        let sentinel = sentinel(text);

        for i in 0..self.len() {
            let idx = self.get(i).unwrap();
            if (i % sampling_rate) == 0 {
                sample.push(idx);
            } else if bwt.borrow()[i] == sentinel {
                // If bwt lookup will return a sentinel
                // Text suffixes that begin right after a sentinel are always saved as extra rows
                // to help deal with FM index last to front inaccuracy when there are many sentinels
                extra_rows.insert(i, idx);
            }
        }

        SampledSuffixArray {
            bwt,
            less,
            occ,
            sample,
            s: sampling_rate,
            extra_rows,
            sentinel,
        }
    }
/// Sample the suffix array with the given sample rate.
///
/// # Arguments
///
/// * `text` - text that the suffix array is built on
/// * `bwt` - the corresponding BWT
/// * `less` - the corresponding less array
/// * `occ` - the corresponding occ table
/// * `sampling_rate` - if sampling rate is k, every k-th entry will be kept
///
/// # Example
///
/// ```
/// use bio::alphabets::dna;
/// use bio::data_structures::bwt::{bwt, less, Occ};
/// use bio::data_structures::suffix_array::{suffix_array, SuffixArray};
///
/// let text = b"ACGCGAT$";
/// let alphabet = dna::n_alphabet();
/// let sa = suffix_array(text);
/// let bwt = bwt(text, &sa);
/// let less = less(&bwt, &alphabet);
/// let occ = Occ::new(&bwt, 3, &alphabet);
/// let sampled = sa.sample(text, &bwt, &less, &occ, 2);
///
/// for i in 0..sa.len() {
///     assert_eq!(sa.get(i), sampled.get(i));
/// }
/// ```
Sample the suffix array with the given sample rate.
Sample the suffix array with the given sample rate .
fn sample<DBWT: Borrow<BWT>, DLess: Borrow<Less>, DOcc: Borrow<Occ>>(
        &self,
        text: &[u8],
        bwt: DBWT,
        less: DLess,
        occ: DOcc,
        sampling_rate: usize,
    ) -> SampledSuffixArray<DBWT, DLess, DOcc> {
        let mut sample =
            Vec::with_capacity((self.len() as f32 / sampling_rate as f32).ceil() as usize);
        let mut extra_rows = HashMapFx::default();
        let sentinel = sentinel(text);
        for i in 0..self.len() {
            let idx = self.get(i).unwrap();
            if (i % sampling_rate) == 0 {
                sample.push(idx);
            } else if bwt.borrow()[i] == sentinel {
                // If bwt lookup will return a sentinel
                // Text suffixes that begin right after a sentinel are always saved as extra rows
                // to help deal with FM index last to front inaccuracy when there are many sentinels
                extra_rows.insert(i, idx);
            }
        }
        SampledSuffixArray {
            bwt,
            less,
            occ,
            sample,
            s: sampling_rate,
            extra_rows,
            sentinel,
        }
    }
fn sample < DBWT : Borrow < BWT > , DLess : Borrow < Less > , DOcc : Borrow < Occ > > ( & self , text : & [ u8 ] , bwt : DBWT , less : DLess , occ : DOcc , sampling_rate : usize , ) -> SampledSuffixArray < DBWT , DLess , DOcc > { let mut sample = Vec :: with_capacity ( ( self . len ( ) as f32 / sampling_rate as f32 ) . ceil ( ) as usize ) ; let mut extra_rows = HashMapFx :: default ( ) ; let sentinel = sentinel ( text ) ; for i in 0 .. self . len ( ) { let idx = self . get ( i ) . unwrap ( ) ; if ( i % sampling_rate ) == 0 { sample . push ( idx ) ; } else if bwt . borrow ( ) [ i ] == sentinel { // If bwt lookup will return a sentinel // Text suffixes that begin right after a sentinel are always saved as extra rows // to help deal with FM index last to front inaccuracy when there are many sentinels extra_rows . insert ( i , idx ) ; } } SampledSuffixArray { bwt , less , occ , sample , s : sampling_rate , extra_rows , sentinel , } }
Sample the suffix array with the given sample rate.
Sample the suffix array with the given sample rate .
&self
text
&[u8]
bwt
DBWT
less
DLess
occ
DOcc
sampling_rate
usize
&self
text
&[u8]
bwt
DBWT
less
DLess
occ
DOcc
sampling_rate
usize
example
```
use bio::alphabets::dna;
use bio::data_structures::bwt::{bwt, less, Occ};
use bio::data_structures::suffix_array::{suffix_array, SuffixArray}.

let text = b"ACGCGAT$";
let alphabet = dna::n_alphabet();
let sa = suffix_array(text);
let bwt = bwt(text, &sa);
let less = less(&bwt, &alphabet);
let occ = Occ::new(&bwt, 3, &alphabet);
let sampled = sa.sample(text, &bwt, &less, &occ, 2).


` ` ` use bio :: alphabets :: dna ; use bio :: data_structures :: bwt :: { bwt less Occ } ; use bio :: data_structures :: suffix_array :: { suffix_array SuffixArray } . let text = b " ACGCGAT$ " ; let alphabet = dna :: n_alphabet () ; let sa = suffix_array ( text ) ; let bwt = bwt ( text &sa ) ; let less = less ( &bwt &alphabet ) ; let occ = Occ :: new ( &bwt 3 &alphabet ) ; let sampled = sa . sample ( text &bwt &less &occ 2 ) .