Skip to content

Instantly share code, notes, and snippets.

View kellyrob99's full-sized avatar

Kelly Robinson kellyrob99

View GitHub Profile
@kellyrob99
kellyrob99 / DNAtoRNA
Created October 16, 2011 22:03
BioGroovy 'Hello World' updated for v3.0.2 of BioJava
@GrabResolver(name='biojava', root='http://www.biojava.org/download/maven/')
@Grab('org.biojava:biojava3-core:3.0.2')
import org.biojava3.core.sequence.*;
rna = new DNASequence("atgccgaatcgtaa").RNASequence
println rna
@kellyrob99
kellyrob99 / BioGroovyFasta.groovy
Created October 16, 2011 22:16
BioGroovy reading fasta file
@GrabResolver(name='biojava', root='http://www.biojava.org/download/maven/')
@Grab('org.biojava:biojava3-core:3.0.2')
import org.biojava3.core.sequence.*
import org.biojava3.core.sequence.io.*
import org.biojava3.core.sequence.compound.*
def testFasta = '''> seq1 This is the description of my first sequence.
AGTACGTAGTAGCTGCTGCTACGTGCGCTAGCTAGTACGTCA
CGACGTAGATGCTAGCTGACTCGATGC
> seq2 This is a description of my second sequence.
@kellyrob99
kellyrob99 / bioGroovyDNAtoRNA.groovy
Created October 18, 2011 17:30
BioGroovy with args
@GrabResolver(name='biojava', root='http://www.biojava.org/download/maven/')
@Grab('org.biojava:biojava3-core:3.0.2')
import org.biojava3.core.sequence.*;
rna = new DNASequence(args? args[0] : '').RNASequence
println rna
@kellyrob99
kellyrob99 / charSetDetector.gradle
Created October 21, 2011 07:23
CharsetDetector task for Gradle, utilizes juniversalchardet
import org.mozilla.universalchardet.UniversalDetector
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath files('juniversalchardet-1.0.3.jar') // not available in public repository :(
}
}
@kellyrob99
kellyrob99 / build.gradle
Created November 27, 2011 23:20 — forked from glaforge/build.gradle
build.gradle for setting up a new gradle-based project
apply plugin:'groovy'
apply plugin:'idea'
apply plugin:'project-report'
apply plugin:'maven'
repositories {
mavenLocal()
mavenCentral()
}
@kellyrob99
kellyrob99 / jenkinsSVNVersionChecker.groovy
Created December 4, 2011 18:03
A script to find the source control version of the last successful build on every Jenkins job for a particular server. Outputs whether or not each job is building the expectedVersion.
import groovy.json.JsonSlurper
assert args && args.size() == 2
def urls = args[0].split(',')
def expectedVersion = args[1]
urls.each { url ->
println "examining url $url"
def json = new JsonSlurper().parseText(url.toURL().text)
json.jobs.each {
@kellyrob99
kellyrob99 / jenkinsBuildArtifacts.groovy
Created December 4, 2011 18:07
Example of parsing out the artifacts of the last successful build on Jenkins/Hudson using the JSON api
import groovy.json.*
def HOSTNAME = 'http://ci.jruby.org'
def JOBNAME = 'jruby-dist'
def JOB_URL = "$HOSTNAME/job/$JOBNAME/lastSuccessfulBuild"
def text = "$JOB_URL/api/json".toURL().text
println JsonOutput.prettyPrint(text)
def json = new JsonSlurper().parseText(text)
json.artifacts.each{
println it
}
@kellyrob99
kellyrob99 / openCsv.groovy
Created December 4, 2011 18:35
OpenCSV in a groovy script to read in a file, filter the content and write out the result
@Grab(group = 'net.sf.opencsv', module = 'opencsv', version = '2.3')
import au.com.bytecode.opencsv.CSVReader
import au.com.bytecode.opencsv.CSVParser
import au.com.bytecode.opencsv.CSVWriter
def TEST_FILE_NAME = 'test.csv'
def TEST_OUTPUT_FILE_NAME = 'testOut.csv'
List<String[]> rows = new CSVReader(new FileReader(new File(TEST_FILE_NAME)), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_ESCAPE_CHARACTER, CSVParser.DEFAULT_QUOTE_CHARACTER, 1).readAll()
def rowsOver100 = rows.findAll {it[1].toInteger() > 100}
import org.mbte.gretty.httpserver.*
@GrabResolver(name='gretty',
root='http://groovypp.artifactoryonline.com/groovypp/libs-releases-local')
@Grab('org.mbte.groovypp:gretty:0.4.279')
GrettyServer server = []
server.groovy = [
localAddress: new InetSocketAddress("localhost", 8080),
defaultHandler: {
@kellyrob99
kellyrob99 / grettyGreenMailServer.groovy
Created December 28, 2011 02:06
Use Gretty to provide a JSON front end for a GreenMail smtp test server
@GrabResolver(name = 'gretty', root = 'http://groovypp.artifactoryonline.com/groovypp/libs-releases-local')
@Grab('org.mbte.groovypp:gretty:0.4.279')
@Grab('com.icegreen:greenmail:1.3.1b')
import javax.mail.internet.MimeMessage
import org.jboss.netty.channel.local.LocalAddress
import org.mbte.gretty.httpserver.GrettyServer
import com.icegreen.greenmail.user.*
import com.icegreen.greenmail.util.*
//create the greenmail server