Permalink
Browse files

Next flow initial commit

  • Loading branch information...
pditommaso committed Mar 22, 2013
0 parents commit c080150321e5000a2c891e477bb582df07b7f75f
Showing with 4,875 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +110 −0 bin/nextflow.sh
  3. +174 −0 build.gradle
  4. +46 −0 examples/blast.nextflow
  5. +7 −0 examples/env.nextflow
  6. +5 −0 examples/hello.nextflow
  7. +6 −0 examples/vars.nextflow
  8. +33 −0 nextflow.iml
  9. +68 −0 src/main/groovy/nextflow/Const.groovy
  10. +132 −0 src/main/groovy/nextflow/Nextflow.groovy
  11. +191 −0 src/main/groovy/nextflow/Session.groovy
  12. +553 −0 src/main/groovy/nextflow/processor/AbstractScriptProcessor.groovy
  13. +201 −0 src/main/groovy/nextflow/processor/LocalScriptProcessor.groovy
  14. +46 −0 src/main/groovy/nextflow/processor/NopeScriptProcessor.groovy
  15. +46 −0 src/main/groovy/nextflow/processor/OgeScriptProcessor.groovy
  16. +133 −0 src/main/groovy/nextflow/processor/Processor.groovy
  17. +86 −0 src/main/groovy/nextflow/processor/TaskDef.groovy
  18. +116 −0 src/main/groovy/nextflow/script/AbstractScript.groovy
  19. +79 −0 src/main/groovy/nextflow/script/CliBinding.groovy
  20. +54 −0 src/main/groovy/nextflow/script/CliOptions.groovy
  21. +356 −0 src/main/groovy/nextflow/script/CliRunner.groovy
  22. +32 −0 src/main/groovy/nextflow/script/TaskScriptClosureTransform.groovy
  23. +168 −0 src/main/groovy/nextflow/script/TaskScriptClosureTransformImpl.groovy
  24. +196 −0 src/main/groovy/nextflow/util/FileHelper.groovy
  25. +188 −0 src/main/groovy/nextflow/util/LoggerHelper.groovy
  26. +79 −0 src/test/groovy/BlastScriptTest.groovy
  27. +50 −0 src/test/groovy/ScriptBindOnTermination.groovy
  28. +33 −0 src/test/groovy/ScriptEnv.groovy
  29. +31 −0 src/test/groovy/ScriptNoInputNoOutput.groovy
  30. +77 −0 src/test/groovy/ScriptProcessorTest.groovy
  31. +86 −0 src/test/groovy/nextflow/SessionTest.groovy
  32. +113 −0 src/test/groovy/nextflow/script/NextflowRunnerTest.groovy
  33. +138 −0 src/test/groovy/nextflow/util/FileHelperTest.groovy
  34. +149 −0 src/test/groovy/script/ScriptRunnerTest.groovy
  35. +29 −0 src/zandbox/BindHandlesTest.groovy
  36. +29 −0 src/zandbox/ChainingTest.groovy
  37. +33 −0 src/zandbox/CliBuilderTest.groovy
  38. +31 −0 src/zandbox/ClosureTest.groovy
  39. +42 −0 src/zandbox/ConfigSlurperTest.groovy
  40. +53 −0 src/zandbox/DataflowBroadcastTest.groovy
  41. +41 −0 src/zandbox/DataflowDeadLockTest.groovy
  42. +39 −0 src/zandbox/DataflowMapTest.groovy
  43. +37 −0 src/zandbox/DataflowQueueTest1.groovy
  44. +41 −0 src/zandbox/DataflowQueueTest2.groovy
  45. +45 −0 src/zandbox/DataflowQueueTest2withDaemonGroup.groovy
  46. +44 −0 src/zandbox/DataflowQueueTest3.groovy
  47. +70 −0 src/zandbox/DataflowStreamTest.groovy
  48. +45 −0 src/zandbox/DataflowVarsTest.groovy
  49. +52 −0 src/zandbox/JCommanderTest.groovy
  50. +64 −0 src/zandbox/Operator2Test.groovy
  51. +56 −0 src/zandbox/Operator3Test.groovy
  52. +57 −0 src/zandbox/Operator4Test.groovy
  53. +66 −0 src/zandbox/OperatorMapTest.groovy
  54. +48 −0 src/zandbox/OperatorPoison.groovy
  55. +38 −0 src/zandbox/OperatorPoisonWithVar.groovy
  56. +49 −0 src/zandbox/OperatorTest.groovy
  57. +44 −0 src/zandbox/SplitterTest.groovy
  58. +35 −0 src/zandbox/TemplateEngineTest.groovy
@@ -0,0 +1,5 @@
.idea/**
.gradle/**
.nextflow.log*
build/**
out/**
@@ -0,0 +1,110 @@
#!/bin/bash
#
# Copyright (c) 2012, the authors.
#
# This file is part of 'Nextflow'.
#
# Nextflow is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Nextflow is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Nextflow. If not, see <http://www.gnu.org/licenses/>.
#
#set -e
#set -u
#set -o errexit
# the application 'base' folder
bin_dir=`dirname "$0"`
bin_dir=`cd "$bin_dir"; pwd`
base_dir=`dirname $bin_dir`
# define the java env
java=java
if test -n "$JAVA_HOME"; then
java="$JAVA_HOME/bin/java"
fi
#
# Variable definition
#
declare -a args=()
DEBUG=''
MAIN_CLASS='nextflow.script.CliRunner'
JVM_ARGS+=" -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true"
#
# classpath when the application is compiled with gradle
#
if [ -e "$base_dir/build/classes/main" ]; then
CLASSPATH="$base_dir/build/classes/main"
CLASSPATH+=":$base_dir/build/classes/test"
CLASSPATH+=":$base_dir/build/resources/main"
for file in $base_dir/build/dependency-libs/*.jar; do
CLASSPATH+=":$file";
done
#
# deployed application class -- only jar in the libs folder
#
#elif [ -e $base_dir/libs ]; then
# CLASSPATH="$base_dir/conf"
# for file in $base_dir/libs/*.jar; do
# CLASSPATH+=":$file";
# done
else
echo "Missing application libraries -- Nextflow cannot start"
exit 1
fi
#
# Handle special program cli options
#
while [ "$*" != "" ]; do
if [[ "$1" == '--debug' || "$1" == '--trace' ]]; then
args+=("$1")
elif [ "$1" == '--with-jrebel' ]; then
if [ "$JREBEL_HOME" ]; then
JVM_ARGS+=" -javaagent:$JREBEL_HOME/jrebel.jar -Drebel.log.file=./jrebel-client.log"
else
echo "WARN: To use JReber define the JREBEL_HOME variable in environment"
fi
elif [ "$1" == '--remote-debugger' ]; then
DEBUG='-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8010'
else
args+=("$1")
fi
# move to the next option
shift
done
# Show some variable when in DEBUG mode
if [ "$DEBUG" != '' ]; then
echo Launch environment
echo ------------------
echo base_dir: $base_dir
echo jvmargs: $JVM_ARGS
echo debug: $DEBUG
echo classpath:
echo $CLASSPATH | tr ":" "\n" | sort
echo ''
echo Launching it!
echo ------------------
fi
# Launch the APP
exec java $JVM_ARGS $DEBUG -cp "$CLASSPATH" "$MAIN_CLASS" "${args[@]}"
@@ -0,0 +1,174 @@
/*
* Copyright (c) 2012, the authors.
*
* This file is part of 'Nextflow'.
*
* Nextflow is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Nextflow is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Nextflow. If not, see <http://www.gnu.org/licenses/>.
*/
apply plugin: 'groovy'
version = '0.1'
status = 'alpha'
repositories {
flatDir(dirs: file('lib'))
mavenCentral()
}
dependencies {
groovy module ('org.codehaus.groovy:groovy-all:2.1.1') {
transitive = true
}
compile (
'org.codehaus.gpars:gpars:1.0.0',
'org.slf4j:slf4j-api:1.7.2',
'org.slf4j:jcl-over-slf4j:1.7.2',
'org.slf4j:jul-to-slf4j:1.7.2',
'org.slf4j:log4j-over-slf4j:1.7.2',
'ch.qos.logback:logback-classic:1.0.9',
'ch.qos.logback:logback-core:1.0.9',
'commons-lang:commons-lang:2.6',
'commons-io:commons-io:2.4',
'com.google.guava:guava:13.0.1',
'com.beust:jcommander:1.30',
'jline:jline:2.9',
'org.fusesource.jansi:jansi:1.9'
)
testCompile ('org.spockframework:spock-core:0.7-groovy-2.0')
}
/*
* print out the runtime classpath
*/
task classpathRuntime(dependsOn: configurations.runtime) << {
String home = System.properties['user.home']
def libs = configurations.compile.collect {File file -> file.absolutePath ?.replace(home,'$HOME')}
println libs.join(':')
}
/*
* print out the compile classpath
*/
task classpathCompile(dependsOn: configurations.compile) << {
String home = System.properties['user.home']
def libs = configurations.compile.collect {File file -> file.absolutePath ?.replace(home,'$HOME')}
println libs.join(':')
}
/*
* Update the build timestamp in the source source file
*/
task buildInfo << {
def file = new File('./src/main/groovy/nextflow/Const.groovy')
def buildNum = 0
def src = file.text
src.find(/APP_BUILDNUM *= *([0-9]*)/) { buildNum = it[1]?.toInteger()+1 }
src = src.replaceAll('APP_VER *= *"[0-9\\.]+"', "APP_VER = \"${version}\"" as String)
src = src.replaceAll('APP_TIMESTAMP *= *[0-9]*', "APP_TIMESTAMP = ${System.currentTimeMillis()}" as String)
if( buildNum ) {
src = src.replaceAll('APP_BUILDNUM *= *[0-9]*', "APP_BUILDNUM = ${buildNum}" as String)
}
else {
println "WARN: Unable to find current build number"
}
file.text = src
}
/*
* Compile sources and copies all libs to target directory
*/
task compile(type: Copy) {
dependsOn buildInfo, compileJava, compileGroovy, processResources
into "$buildDir/dependency-libs"
from configurations.runtime
}
/*
* Create the distribution stage folder i.e. creates a folder containing everythinh
* have to be included in the distribution package
*/
task stage( type: Copy ) {
dependsOn jar, javadoc, groovydoc
// clean the target directory before create
def target = file("$buildDir/stage/nextflow-$version")
target.parentFile.deleteDir()
target.mkdirs()
destinationDir target
// // copy the bin scripts
// into('bin') {
// from ('./bin') { exclude 'circo' }
// rename { String fileName -> fileName.replace('circo.sh', 'circo') }
// }
// copy application - and - runtime dependencies jars
into('libs') {
from "$buildDir/libs/nextflow-${version}.jar"
from configurations.runtime
}
// still some stuff
into('conf') { from './src/main/resources' }
into('src') { from './src/main' }
into('docs') { from '$buildDir/docs/groovydoc/'}
}
/*
* Creates the Zip distribution file
*/
task distZip(type: Zip) {
dependsOn stage
from "$buildDir/stage/"
}
/*
* creates the Tar distribution file
*/
task distTar(type: Tar) {
dependsOn stage
compression = Compression.GZIP
from "$buildDir/stage/"
}
task dist() {
dependsOn distZip, distTar
}
/*
* Print the distribution file name when distXxx task completes
*/
gradle.taskGraph.afterTask { Task task, TaskState state ->
if (task == distTar && !state.failure) { println "\n** TAR: ${relativePath(distTar.archivePath)}\n\n"}
if (task == distZip && !state.failure) { println "\n** ZIP: ${relativePath(distZip.archivePath)}\n\n"}
}
@@ -0,0 +1,46 @@
def fasta='/Users/ptommaso/sample.fa'
def DB='/Users/ptommaso/tools/blast-db/pdb/pdb'
def sequences = task('split') {
input fasta:[fasta]
output 'seq_*'
"""
gcsplit $fasta '%^>%' '/^>/' '{*}' -f seq_
"""
}
def singleBlast = task('blast') {
input seq: sequences
output 'blast_result'
"""
blastp -db $DB -query $seq -outfmt 6 > blast_result
"""
}
def allBlast = merge {
input blast:singleBlast
output 'allBlast'
"""
cat $blast >> allBlast
"""
}
def result = task('sort') {
input result:allBlast
"""
sort $result
"""
}
println read(result)
@@ -0,0 +1,7 @@
env [ 'HELLO' ] = '1'
task {
echo true
"env | sort"
}
@@ -0,0 +1,5 @@
task {
"""
echo 'Hello world'
"""
}
@@ -0,0 +1,6 @@
x = 1
def y = 2
println "x: $x"
println "y: $y"
println "z: $z"
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/groovy" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/groovy" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="jsr166y-1.7.0" level="project" />
<orderEntry type="library" exported="" name="gpars-1.0.0" level="project" />
<orderEntry type="library" exported="" name="logback-classic-1.0.9" level="project" />
<orderEntry type="library" exported="" name="commons-lang-2.6" level="project" />
<orderEntry type="library" exported="" name="jline-2.9" level="project" />
<orderEntry type="library" exported="" name="jul-to-slf4j-1.7.2" level="project" />
<orderEntry type="library" exported="" name="groovy-all-2.1.1" level="project" />
<orderEntry type="library" exported="" name="jansi-1.9" level="project" />
<orderEntry type="library" exported="" name="jcl-over-slf4j-1.7.2" level="project" />
<orderEntry type="library" exported="" name="slf4j-api-1.7.2" level="project" />
<orderEntry type="library" scope="TEST" name="junit-dep-4.10" level="project" />
<orderEntry type="library" exported="" name="log4j-over-slf4j-1.7.2" level="project" />
<orderEntry type="library" exported="" name="guava-13.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="logback-core-1.0.9" level="project" />
<orderEntry type="library" scope="TEST" name="spock-core-0.7-groovy-2.0" level="project" />
<orderEntry type="library" exported="" name="jcommander-1.30" level="project" />
<orderEntry type="library" exported="" name="commons-io-2.4" level="project" />
</component>
</module>
Oops, something went wrong.

0 comments on commit c080150

Please sign in to comment.