pub fn bwt(text: &[u8], pos: RawSuffixArraySlice) -> BWT {
    assert_eq!(text.len(), pos.len());
    let n = text.len();
    let mut bwt: BWT = repeat(0).take(n).collect();
    for r in 0..n {
        let p = pos[r];
        bwt[r] = if p > 0 { text[p - 1] } else { text[n - 1] };
    }

    bwt
}
/// Calculate Burrows-Wheeler-Transform of the given text of length n.
/// Complexity: O(n).
///
/// # Arguments
///
/// * `text` - the text ended by sentinel symbol (being lexicographically smallest)
/// * `pos` - the suffix array for the text
///
/// # Example
///
/// ```
/// use bio::data_structures::bwt::bwt;
/// use bio::data_structures::suffix_array::suffix_array;
/// let text = b"GCCTTAACATTATTACGCCTA$";
/// let pos = suffix_array(text);
/// let bwt = bwt(text, &pos);
/// assert_eq!(bwt, b"ATTATTCAGGACCC$CTTTCAA");
/// ```
Calculate Burrows-Wheeler-Transform of the given text of length n.
Calculate Burrows - Wheeler - Transform of the given text of length n .
pub fn bwt(text: &[u8], pos: RawSuffixArraySlice) -> BWT {
    assert_eq!(text.len(), pos.len());
    let n = text.len();
    let mut bwt: BWT = repeat(0).take(n).collect();
    for r in 0..n {
        let p = pos[r];
        bwt[r] = if p > 0 { text[p - 1] } else { text[n - 1] };
    }
    bwt
}
pub fn bwt ( text : & [ u8 ] , pos : RawSuffixArraySlice ) -> BWT { assert_eq ! ( text len ( ) pos len ( ) ) ; let n = text . len ( ) ; let mut bwt : BWT = repeat ( 0 ) . take ( n ) . collect ( ) ; for r in 0 .. n { let p = pos [ r ] ; bwt [ r ] = if p > 0 { text [ p - 1 ] } else { text [ n - 1 ] } ; } bwt }
Calculate Burrows-Wheeler-Transform of the given text of length n.
Complexity: O(n).
Calculate Burrows - Wheeler - Transform of the given text of length n . Complexity : O ( n ) .
text
&[u8]
pos
RawSuffixArraySlice
text
&[u8]
pos
RawSuffixArraySlice
example
```
use bio::data_structures::bwt::bwt;
use bio::data_structures::suffix_array::suffix_array;
let text = b"GCCTTAACATTATTACGCCTA$";
let pos = suffix_array(text);
let bwt = bwt(text, &pos);
assert_eq!(bwt, b"ATTATTCAGGACCC$CTTTCAA");
```
` ` ` use bio :: data_structures :: bwt :: bwt ; use bio :: data_structures :: suffix_array :: suffix_array ; let text = b " GCCTTAACATTATTACGCCTA$ " ; let pos = suffix_array ( text ) ; let bwt = bwt ( text &pos ) ; assert_eq! ( bwt b " ATTATTCAGGACCC$CTTTCAA " ) ; ` ` `