MCPcopy Create free account
hub / github.com/apache/groovy / main

Method main

benchmark/bench/regexdna.java:17–61  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

15 }
16
17 public static void main(String[] args) {
18 BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
19 StringBuffer sb = new StringBuffer(10240);
20 char[] cbuf = new char[10240];
21 int charsRead = 0;
22 try {
23 while ((charsRead = r.read(cbuf, 0, 10240)) != -1)
24 sb.append(cbuf, 0, charsRead);
25 } catch (java.io.IOException e) {
26 return;
27 }
28 String sequence = sb.toString();
29
30 int initialLength = sequence.length();
31 sequence = Pattern.compile(">.*\n|\n").matcher(sequence).replaceAll("");
32 int codeLength = sequence.length();
33
34 String[] variants = { "agggtaaa|tttaccct" ,"[cgt]gggtaaa|tttaccc[acg]", "a[act]ggtaaa|tttacc[agt]t",
35 "ag[act]gtaaa|tttac[agt]ct", "agg[act]taaa|ttta[agt]cct", "aggg[acg]aaa|ttt[cgt]ccct",
36 "agggt[cgt]aa|tt[acg]accct", "agggta[cgt]a|t[acg]taccct", "agggtaa[cgt]|[acg]ttaccct" };
37 for (int i = 0; i < variants.length; i++) {
38 int count = 0;
39 Matcher m = Pattern.compile(variants[i]).matcher(sequence);
40 while (m.find())
41 count++;
42 System.out.println(variants[i] + " " + count);
43 }
44
45 sequence = Pattern.compile("B").matcher(sequence).replaceAll("(c|g|t)");
46 sequence = Pattern.compile("D").matcher(sequence).replaceAll("(a|g|t)");
47 sequence = Pattern.compile("H").matcher(sequence).replaceAll("(a|c|t)");
48 sequence = Pattern.compile("K").matcher(sequence).replaceAll("(g|t)");
49 sequence = Pattern.compile("M").matcher(sequence).replaceAll("(a|c)");
50 sequence = Pattern.compile("N").matcher(sequence).replaceAll("(a|c|g|t)");
51 sequence = Pattern.compile("R").matcher(sequence).replaceAll("(a|g)");
52 sequence = Pattern.compile("S").matcher(sequence).replaceAll("(c|g)");
53 sequence = Pattern.compile("V").matcher(sequence).replaceAll("(a|c|g)");
54 sequence = Pattern.compile("W").matcher(sequence).replaceAll("(a|t)");
55 sequence = Pattern.compile("Y").matcher(sequence).replaceAll("(c|t)");
56
57 System.out.println();
58 System.out.println(initialLength);
59 System.out.println(codeLength);
60 System.out.println(sequence.length());
61 }
62}

Callers

nothing calls this directly

Calls 8

readMethod · 0.65
toStringMethod · 0.65
compileMethod · 0.65
appendMethod · 0.45
lengthMethod · 0.45
replaceAllMethod · 0.45
findMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected