]>
git.proxmox.com Git - rustc.git/blob - vendor/regex-1.4.6/examples/shootout-regex-dna-single.rs
1 // The Computer Language Benchmarks Game
2 // https://benchmarksgame-team.pages.debian.net/benchmarksgame/
4 // contributed by the Rust Project Developers
5 // contributed by TeXitoi
6 // contributed by BurntSushi
10 use std
::io
::{self, Read}
;
14 ::regex
::Regex
::new($re
).unwrap()
19 let mut seq
= String
::with_capacity(50 * (1 << 20));
20 io
::stdin().read_to_string(&mut seq
).unwrap();
23 seq
= regex
!(">[^\n]*\n|\n").replace_all(&seq
, "").into_owned();
27 regex
!("agggtaaa|tttaccct"),
28 regex
!("[cgt]gggtaaa|tttaccc[acg]"),
29 regex
!("a[act]ggtaaa|tttacc[agt]t"),
30 regex
!("ag[act]gtaaa|tttac[agt]ct"),
31 regex
!("agg[act]taaa|ttta[agt]cct"),
32 regex
!("aggg[acg]aaa|ttt[cgt]ccct"),
33 regex
!("agggt[cgt]aa|tt[acg]accct"),
34 regex
!("agggta[cgt]a|t[acg]taccct"),
35 regex
!("agggtaa[cgt]|[acg]ttaccct"),
38 println
!("{} {}", re
.to_string(), re
.find_iter(&seq
).count());
42 (regex
!("B"), "(c|g|t)"),
43 (regex
!("D"), "(a|g|t)"),
44 (regex
!("H"), "(a|c|t)"),
45 (regex
!("K"), "(g|t)"),
46 (regex
!("M"), "(a|c)"),
47 (regex
!("N"), "(a|c|g|t)"),
48 (regex
!("R"), "(a|g)"),
49 (regex
!("S"), "(c|g)"),
50 (regex
!("V"), "(a|c|g)"),
51 (regex
!("W"), "(a|t)"),
52 (regex
!("Y"), "(c|t)"),
55 for (re
, replacement
) in substs
{
56 seq
= re
.replace_all(&seq
, replacement
).into_owned();
58 println
!("\n{}\n{}\n{}", ilen
, clen
, seq
.len());