1 // The Computer Language Benchmarks Game
2 // http://benchmarksgame.alioth.debian.org/
4 // contributed by the Rust Project Developers
5 // contributed by TeXitoi
6 // contributed by BurntSushi
10 use std
::io
::{self, Read}
;
12 macro_rules
! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() }
}
15 let mut seq
= String
::with_capacity(50 * (1 << 20));
16 io
::stdin().read_to_string(&mut seq
).unwrap();
19 seq
= regex
!(">[^\n]*\n|\n").replace_all(&seq
, "").into_owned();
23 regex
!("agggtaaa|tttaccct"),
24 regex
!("[cgt]gggtaaa|tttaccc[acg]"),
25 regex
!("a[act]ggtaaa|tttacc[agt]t"),
26 regex
!("ag[act]gtaaa|tttac[agt]ct"),
27 regex
!("agg[act]taaa|ttta[agt]cct"),
28 regex
!("aggg[acg]aaa|ttt[cgt]ccct"),
29 regex
!("agggt[cgt]aa|tt[acg]accct"),
30 regex
!("agggta[cgt]a|t[acg]taccct"),
31 regex
!("agggtaa[cgt]|[acg]ttaccct"),
34 println
!("{} {}", re
.to_string(), re
.find_iter(&seq
).count());
38 (regex
!("B"), "(c|g|t)"),
39 (regex
!("D"), "(a|g|t)"),
40 (regex
!("H"), "(a|c|t)"),
41 (regex
!("K"), "(g|t)"),
42 (regex
!("M"), "(a|c)"),
43 (regex
!("N"), "(a|c|g|t)"),
44 (regex
!("R"), "(a|g)"),
45 (regex
!("S"), "(c|g)"),
46 (regex
!("V"), "(a|c|g)"),
47 (regex
!("W"), "(a|t)"),
48 (regex
!("Y"), "(c|t)"),
51 for (re
, replacement
) in substs
{
52 seq
= re
.replace_all(&seq
, replacement
).into_owned();
54 println
!("\n{}\n{}\n{}", ilen
, clen
, seq
.len());