home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (regexdna.groovy)

This example Groovy source code file (regexdna.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

b':', b':', d':', h':', k':', m':', m':', r':', r':', s':', stringbuffer, v':', y':', y':'

The Groovy regexdna.groovy source code

// The Computer Language Benchmark Games
// http://shootout.alioth.debian.org/
// contributed by James Durbin
// based very closely on Ruby version by jose fco. gonzalez

def seq = new StringBuffer();   
seq = System.in.readLines().join("\n")+"\n";

initialLength = seq.length();
seq = (seq =~">.*\n|\n").replaceAll("");
codeLength = seq.length();

   "agggtaaa|tttaccct" ,
   println "$it "+(seq =~it).getCount();

   'B':'(c|g|t)', 'D':'(a|g|t)', 'H':'(a|c|t)', 'K':'(g|t)',
   'M':'(a|c)', 'N':'(a|c|g|t)', 'R':'(a|g)', 'S':'(c|t)',
   'V':'(a|c|g)', 'W':'(a|t)', 'Y':'(c|t)'
].each { f,r -> 
   seq = (seq =~ f).replaceAll(r);

println "";
println initialLength;
println codeLength;
println seq.length();

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy regexdna.groovy source code file:

new blog posts


Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.