Text
Johannes Köster
University of Duisburg-Essen https://koesterlab.github.io
if __name__ == "__main__":
print("Hello world! I am easy to use, "
"but I can be slow and memory hungry "
"and you might spend many hours with "
"debugging runtime errors.")
#include <iostream.h>
main()
{
cout << "Hello World! I am fast \
but you might spend the \
rest of your life with debugging. \
" << endl;
return 0;
}
let mut s = String::from("hello");
let r1 = &mut s;
let r2 = &mut s; // compiler error
let mut s = String::from("hello");
let r1 = &s;
let r2 = &s;
let r3 = &mut s; // compiler error
fn main() {
let reference_to_nothing = dangle();
}
fn dangle() -> &String {
let s = String::from("hello");
&s // compiler error
}
fn main() {
println!("Hello World! I am fast and robust. \
I will shift your dev time from \
debugging to compiling.");
}
// Import some modules
use bio::alphabets;
use bio::data_structures::suffix_array::suffix_array;
use bio::data_structures::bwt::{bwt, less, Occ};
use bio::data_structures::fmindex::{FMIndex, FMIndexable};
use bio::io::fastq;
// a given text
let text = b"ACAGCTCGATCGGTA";
// Create an FM-Index for the given text.
// instantiate an alphabet
let alphabet = alphabets::dna::iupac_alphabet();
// calculate a suffix array
let pos = suffix_array(text);
// calculate BWT
let bwt = bwt(text, &pos);
// calculate less and Occ
let less = less(&bwt, &alphabet);
let occ = Occ::new(&bwt, 3, &alphabet);
// setup FMIndex
let fmindex = FMIndex::new(&bwt, &less, &occ);
// Iterate over a FASTQ file, use the alphabet to validate read
// sequences and search for exact matches in the FM-Index.
// obtain reader or fail with error (via the unwrap method)
let reader = fastq::Reader::from_file("reads.fastq").unwrap();
for result in reader.records() {
// obtain record or fail with error
let record = result.unwrap();
// obtain sequence
let seq = record.seq();
if alphabet.is_word(seq) {
let interval = fmindex.backward_search(seq.iter());
let positions = interval.occ(&pos);
}
}
https://rust-bio.github.io