[][src]Function chordclust::read_fasta_sorted

pub fn read_fasta_sorted<Buf: Read>(buf: Buf) -> Vec<String>

Read the sequences inside a buffer in FASTA format and store it in a sorted Vec<String> by length. Based on the greedy nature of the algorithm, the first sequence that is seen will form a cluster,

Examples

use chordclust::read_fasta_sorted;

const FASTA_FILE: &[u8] = b">id desc
AAAA
> id2 another|desc
AAAATTT
> id3 final|desc
AAUUT
";
let vec = read_fasta_sorted(std::io::Cursor::new(FASTA_FILE));
println!("{:#?}", vec);
assert!(vec[..(vec.len())]
    .iter()
    .zip(vec[1..].iter())
    .all(|(a, b)| a.len() > b.len()));