Permalink
Browse files

Merge branch 'dev'

Conflicts:
	README.md
  • Loading branch information...
2 parents 3c87c2b + 94f8e04 commit f9b810ba06610a453e042b7ef7d9dd31d7e82d63 @scottfrazer scottfrazer committed with Scott Frazer Sep 23, 2013
Showing with 15,828 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 .travis.yml
  3. +267 −3 README.md
  4. +20 −0 build.xml
  5. +18 −0 examples/CopyNumberQC.wdl
  6. +27 −0 examples/MutSig.wdl
  7. +28 −0 grammars/composite_task.zgr
  8. +59 −0 pom.xml
  9. +27 −0 src/main/java/org/broadinstitute/compositetask/AnsiColorizer.java
  10. +9 −0 src/main/java/org/broadinstitute/compositetask/ColorTheme.java
  11. +407 −0 src/main/java/org/broadinstitute/compositetask/CompositeTask.java
  12. +10 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskColorizer.java
  13. +35 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskEdge.java
  14. +8 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskEdgeFactory.java
  15. +68 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskForLoop.java
  16. +364 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskGraph.java
  17. +9 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskNode.java
  18. +9 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskScope.java
  19. +98 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCode.java
  20. +80 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCodeFormatter.java
  21. +65 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskStep.java
  22. +42 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskStepInput.java
  23. +51 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskStepOutput.java
  24. +37 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskSubTask.java
  25. +7 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskToDotCompiler.java
  26. +56 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskVariable.java
  27. +3 −0 src/main/java/org/broadinstitute/compositetask/CompositeTaskVertex.java
  28. +108 −0 src/main/java/org/broadinstitute/compositetask/DirectedGraph.java
  29. +67 −0 src/main/java/org/broadinstitute/compositetask/EdgeFactory.java
  30. +435 −0 src/main/java/org/broadinstitute/compositetask/Graph.java
  31. +27 −0 src/main/java/org/broadinstitute/compositetask/HtmlColorizer.java
  32. +121 −0 src/main/java/org/broadinstitute/compositetask/Lexer.java
  33. +112 −0 src/main/java/org/broadinstitute/compositetask/Main.java
  34. +27 −0 src/main/java/org/broadinstitute/compositetask/NullColorizer.java
  35. +102 −0 src/main/java/org/broadinstitute/compositetask/WdlSyntaxErrorFormatter.java
  36. +48 −0 src/main/java/org/broadinstitute/parser/Ast.java
  37. +22 −0 src/main/java/org/broadinstitute/parser/AstList.java
  38. +7 −0 src/main/java/org/broadinstitute/parser/AstNode.java
  39. +3 −0 src/main/java/org/broadinstitute/parser/AstTransform.java
  40. +26 −0 src/main/java/org/broadinstitute/parser/AstTransformNodeCreator.java
  41. +14 −0 src/main/java/org/broadinstitute/parser/AstTransformSubstitution.java
  42. +1,363 −0 src/main/java/org/broadinstitute/parser/CompositeTaskParser.java
  43. +5 −0 src/main/java/org/broadinstitute/parser/ExpressionParser.java
  44. +19 −0 src/main/java/org/broadinstitute/parser/NonTerminal.java
  45. +161 −0 src/main/java/org/broadinstitute/parser/ParseTree.java
  46. +8 −0 src/main/java/org/broadinstitute/parser/ParseTreeNode.java
  47. +6 −0 src/main/java/org/broadinstitute/parser/Parser.java
  48. +12 −0 src/main/java/org/broadinstitute/parser/SourceCode.java
  49. +7 −0 src/main/java/org/broadinstitute/parser/SyntaxError.java
  50. +15 −0 src/main/java/org/broadinstitute/parser/SyntaxErrorFormatter.java
  51. +53 −0 src/main/java/org/broadinstitute/parser/Terminal.java
  52. +6 −0 src/main/java/org/broadinstitute/parser/TerminalIdentifier.java
  53. +8 −0 src/main/java/org/broadinstitute/parser/TerminalMap.java
  54. +57 −0 src/main/java/org/broadinstitute/parser/TokenStream.java
  55. +83 −0 src/main/java/org/broadinstitute/parser/Utility.java
  56. +85 −0 src/test/java/org/broadinstitute/compositetask/ApiTest.java
  57. +222 −0 src/test/java/org/broadinstitute/compositetask/ParsingTest.java
  58. +74 −0 src/test/java/org/broadinstitute/compositetask/SyntaxErrorTest.java
  59. +15 −0 test-files/api/0.wdl
  60. +198 −0 test-files/parsing/0/ast
  61. +19 −0 test-files/parsing/0/formatted
  62. +81 −0 test-files/parsing/0/graph
  63. +383 −0 test-files/parsing/0/parsetree
  64. +24 −0 test-files/parsing/0/source.wdl
  65. +128 −0 test-files/parsing/0/tokens
  66. +215 −0 test-files/parsing/1/ast
  67. +24 −0 test-files/parsing/1/formatted
  68. +89 −0 test-files/parsing/1/graph
  69. +426 −0 test-files/parsing/1/parsetree
  70. +30 −0 test-files/parsing/1/source.wdl
  71. +143 −0 test-files/parsing/1/tokens
  72. +14 −0 test-files/parsing/10/ast
  73. +6 −0 test-files/parsing/10/formatted
  74. +5 −0 test-files/parsing/10/graph
  75. +36 −0 test-files/parsing/10/parsetree
  76. +1 −0 test-files/parsing/10/source.wdl
  77. +14 −0 test-files/parsing/10/tokens
  78. +198 −0 test-files/parsing/11/ast
  79. +19 −0 test-files/parsing/11/formatted
  80. +81 −0 test-files/parsing/11/graph
  81. +383 −0 test-files/parsing/11/parsetree
  82. +8 −0 test-files/parsing/11/source.wdl
  83. +128 −0 test-files/parsing/11/tokens
  84. +170 −0 test-files/parsing/12/ast
  85. +18 −0 test-files/parsing/12/formatted
  86. +69 −0 test-files/parsing/12/graph
  87. +354 −0 test-files/parsing/12/parsetree
  88. +18 −0 test-files/parsing/12/source.wdl
  89. +119 −0 test-files/parsing/12/tokens
  90. +35 −0 test-files/parsing/13/ast
  91. +10 −0 test-files/parsing/13/formatted
  92. +39 −0 test-files/parsing/13/graph
  93. +89 −0 test-files/parsing/13/parsetree
  94. +4 −0 test-files/parsing/13/source.wdl
  95. +39 −0 test-files/parsing/13/tokens
  96. +193 −0 test-files/parsing/14/ast
  97. +13 −0 test-files/parsing/14/formatted
  98. +76 −0 test-files/parsing/14/graph
  99. +368 −0 test-files/parsing/14/parsetree
  100. +27 −0 test-files/parsing/14/source.wdl
  101. +126 −0 test-files/parsing/14/tokens
  102. +4 −0 test-files/parsing/15/ast
  103. +2 −0 test-files/parsing/15/formatted
  104. +5 −0 test-files/parsing/15/graph
  105. +14 −0 test-files/parsing/15/parsetree
  106. +4 −0 test-files/parsing/15/source.wdl
  107. +6 −0 test-files/parsing/15/tokens
  108. +18 −0 test-files/parsing/16/ast
  109. +4 −0 test-files/parsing/16/formatted
  110. +6 −0 test-files/parsing/16/graph
  111. +44 −0 test-files/parsing/16/parsetree
  112. +11 −0 test-files/parsing/16/source.wdl
  113. +15 −0 test-files/parsing/16/tokens
  114. +96 −0 test-files/parsing/17/ast
  115. +12 −0 test-files/parsing/17/formatted
  116. +42 −0 test-files/parsing/17/graph
  117. +199 −0 test-files/parsing/17/parsetree
  118. +10 −0 test-files/parsing/17/source.wdl
  119. +68 −0 test-files/parsing/17/tokens
  120. +96 −0 test-files/parsing/18/ast
  121. +12 −0 test-files/parsing/18/formatted
  122. +42 −0 test-files/parsing/18/graph
  123. +199 −0 test-files/parsing/18/parsetree
  124. +11 −0 test-files/parsing/18/source.wdl
  125. +68 −0 test-files/parsing/18/tokens
  126. +305 −0 test-files/parsing/2/ast
  127. +32 −0 test-files/parsing/2/formatted
  128. +93 −0 test-files/parsing/2/graph
  129. +592 −0 test-files/parsing/2/parsetree
  130. +39 −0 test-files/parsing/2/source.wdl
  131. +197 −0 test-files/parsing/2/tokens
  132. +4 −0 test-files/parsing/3/ast
  133. +2 −0 test-files/parsing/3/formatted
  134. +5 −0 test-files/parsing/3/graph
  135. +14 −0 test-files/parsing/3/parsetree
  136. +1 −0 test-files/parsing/3/source.wdl
  137. +6 −0 test-files/parsing/3/tokens
  138. +205 −0 test-files/parsing/4/ast
  139. +22 −0 test-files/parsing/4/formatted
  140. +76 −0 test-files/parsing/4/graph
  141. +417 −0 test-files/parsing/4/parsetree
  142. +28 −0 test-files/parsing/4/source.wdl
  143. +138 −0 test-files/parsing/4/tokens
  144. +211 −0 test-files/parsing/5/ast
  145. +24 −0 test-files/parsing/5/formatted
  146. +89 −0 test-files/parsing/5/graph
  147. +432 −0 test-files/parsing/5/parsetree
  148. +30 −0 test-files/parsing/5/source.wdl
  149. +146 −0 test-files/parsing/5/tokens
  150. +237 −0 test-files/parsing/6/ast
  151. +28 −0 test-files/parsing/6/formatted
  152. +89 −0 test-files/parsing/6/graph
  153. +482 −0 test-files/parsing/6/parsetree
  154. +33 −0 test-files/parsing/6/source.wdl
  155. +160 −0 test-files/parsing/6/tokens
  156. +89 −0 test-files/parsing/7/ast
  157. +11 −0 test-files/parsing/7/formatted
  158. +46 −0 test-files/parsing/7/graph
  159. +183 −0 test-files/parsing/7/parsetree
  160. +12 −0 test-files/parsing/7/source.wdl
  161. +63 −0 test-files/parsing/7/tokens
  162. +123 −0 test-files/parsing/8/ast
  163. +16 −0 test-files/parsing/8/formatted
  164. +60 −0 test-files/parsing/8/graph
  165. +250 −0 test-files/parsing/8/parsetree
  166. +18 −0 test-files/parsing/8/source.wdl
  167. +87 −0 test-files/parsing/8/tokens
  168. +18 −0 test-files/parsing/9/ast
  169. +4 −0 test-files/parsing/9/formatted
  170. +6 −0 test-files/parsing/9/graph
  171. +44 −0 test-files/parsing/9/parsetree
  172. +1 −0 test-files/parsing/9/source.wdl
  173. +15 −0 test-files/parsing/9/tokens
  174. +9 −0 test-files/syntax-error/0/errors
  175. +24 −0 test-files/syntax-error/0/source.wdl
  176. +9 −0 test-files/syntax-error/1/errors
  177. +12 −0 test-files/syntax-error/1/source.wdl
  178. +9 −0 test-files/syntax-error/2/errors
  179. +12 −0 test-files/syntax-error/2/source.wdl
  180. +9 −0 test-files/syntax-error/3/errors
  181. +12 −0 test-files/syntax-error/3/source.wdl
  182. +5 −0 test-files/syntax-error/4/errors
  183. +4 −0 test-files/syntax-error/4/source.wdl
  184. +6 −0 test-files/syntax-error/5/errors
  185. +1 −0 test-files/syntax-error/5/source.wdl
View
@@ -0,0 +1 @@
+tags
View
@@ -0,0 +1,2 @@
+language: java
+script: ant test
View
270 README.md
@@ -1,4 +1,268 @@
-wdl
-===
+Workflow Description Language (wdl)
+===================================
-Workflow Description Language
+The Workflow Description Language is a language for describing dependency trees of tasks (algorithms) in a concise and clear syntax.
+
+Installation
+============
+
+Generating the JAR
+------------------
+
+To build the JAR file, run:
+
+```
+$ mvn package
+```
+
+Which will create a file target/Wdl-${version}.jar as an executable JAR. To invoke the CLI:
+
+```
+$ java -jar target/Wdl-0.0.1.jar examples/0.wdl ast
+```
+
+Generating the parser code
+--------------------------
+
+Use the Hermes parser generator (http://github.com/scottfrazer/hermes). From the root of this repository, run:
+
+```
+$ hermes generate grammars/composite_task.zgr --directory=src/main/java/org/broadinstitute/compositetask --language=java --java-package=org.broadinstitute.compositetask
+```
+
+Or, run the Ant target `generate-parser` which will run the command above:
+
+```
+$ ant generate-parser
+```
+
+Usage
+=====
+
+Java API
+--------
+
+From Java code, the main interface is the CompositeTask, which can be used in this example to print out the immediate children nodes of this composite task:
+
+```java
+CompositeTask ct = new CompositeTask(new File(args[0]));
+for ( CompositeTaskNode entry : ct.getNodes() ) {
+ System.out.println("Node: " + entry);
+}
+```
+
+Command-line Interface
+----------------------
+
+The data file we'll use is:
+
+```
+$ cat examples/7.wdl
+composite_task test {
+ step s0[version=0] {
+ output: File("abc") as foo;
+ }
+
+ for (I in L) {
+ for (J in M) {
+ step s1[version=0] {
+ input: p0=I, p1=J, p2=foo;
+ output: File("def") as bar;
+ }
+ }
+ }
+
+ step s2[version=0] {
+ input: p0=bar;
+ }
+}
+```
+
+Get the abstract syntax tree:
+
+```
+$ java -jar dist/Wdl-0.0.1.jar examples/7.wdl ast
+(CompositeTask:
+ body=[
+ (Step:
+ body=[
+ (StepOutputList:
+ outputs=[
+ (StepFileOutput:
+ as=(Variable:
+ member=None,
+ name=identifier
+ ),
+ file=string
+ )
+ ]
+ )
+ ],
+ task=(Task:
+ attributes=[
+ (TaskAttribute:
+ value=number,
+ key=identifier
+ )
+ ],
+ name=identifier
+ ),
+ name=None
+ ),
+ (ForLoop:
+ body=[
+ (ForLoop:
+ body=[
+ (Step:
+ body=[
+ (StepInputList:
+ inputs=[
+ (StepInput:
+ parameter=identifier,
+ value=(Variable:
+ member=None,
+ name=identifier
+ )
+ ),
+ (StepInput:
+ parameter=identifier,
+ value=(Variable:
+ member=None,
+ name=identifier
+ )
+ ),
+ (StepInput:
+ parameter=identifier,
+ value=(Variable:
+ member=None,
+ name=identifier
+ )
+ )
+ ]
+ ),
+ (StepOutputList:
+ outputs=[
+ (StepFileOutput:
+ as=(Variable:
+ member=None,
+ name=identifier
+ ),
+ file=string
+ )
+ ]
+ )
+ ],
+ task=(Task:
+ attributes=[
+ (TaskAttribute:
+ value=number,
+ key=identifier
+ )
+ ],
+ name=identifier
+ ),
+ name=None
+ )
+ ],
+ item=identifier,
+ collection=identifier
+ )
+ ],
+ item=identifier,
+ collection=identifier
+ ),
+ (Step:
+ body=[
+ (StepInputList:
+ inputs=[
+ (StepInput:
+ parameter=identifier,
+ value=(Variable:
+ member=None,
+ name=identifier
+ )
+ )
+ ]
+ )
+ ],
+ task=(Task:
+ attributes=[
+ (TaskAttribute:
+ value=number,
+ key=identifier
+ )
+ ],
+ name=identifier
+ ),
+ name=None
+ )
+ ],
+ name=identifier
+)
+```
+
+Get a view of the graph
+
+```
+$ java -jar dist/Wdl-0.0.1.jar examples/7.wdl graph
+VERTICIES
+---------
+[Step: name=s1]
+[Variable: name=J]
+[Variable: name=M]
+[Variable: name=I]
+[Variable: name=L]
+[Variable: name=foo]
+[Step: name=s0]
+[Variable: name=bar]
+[Step: name=s2]
+[CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1]
+[CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1]
+
+EDGES
+-----
+[Edge
+ from: [Step: name=s1]
+ to: [Variable: name=bar]
+]
+[Edge
+ from: [Variable: name=L]
+ to: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1]
+]
+[Edge
+ from: [Variable: name=bar]
+ to: [Step: name=s2]
+]
+[Edge
+ from: [Variable: name=foo]
+ to: [Step: name=s1]
+]
+[Edge
+ from: [Step: name=s0]
+ to: [Variable: name=foo]
+]
+[Edge
+ from: [CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1]
+ to: [Variable: name=J]
+]
+[Edge
+ from: [Variable: name=J]
+ to: [Step: name=s1]
+]
+[Edge
+ from: [Variable: name=M]
+ to: [CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1]
+]
+[Edge
+ from: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1]
+ to: [Step: name=s2]
+]
+[Edge
+ from: [Variable: name=I]
+ to: [Step: name=s1]
+]
+[Edge
+ from: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1]
+ to: [Variable: name=I]
+]
+```
View
@@ -0,0 +1,20 @@
+<project name="wdl">
+ <target name="generate-parser" description="Generate the parser from grammar file">
+ <property name="parser.dir" value="src/main/java/org/broadinstitute/parser" />
+ <property name="parser.package" value="org.broadinstitute.parser" />
+ <property name="parser.grammar" value="grammars/composite_task.zgr" />
+
+ <exec executable="hermes">
+ <arg value="--version" />
+ </exec>
+ <echo message="Generating parser in ${parser.dir}" />
+ <mkdir dir="${parser.dir}" />
+ <exec executable="hermes">
+ <arg value="generate" />
+ <arg value="${parser.grammar}" />
+ <arg value="--directory=${parser.dir}" />
+ <arg value="--language=java" />
+ <arg value="--java-package=${parser.package}" />
+ </exec>
+ </target>
+</project>
View
@@ -0,0 +1,18 @@
+composite_task CopyNumberQC {
+ step LaneBlackList[version=6] {
+ output: File("lane_blacklist.txt") as lane_blacklist;
+ }
+ for ( sample in samples ) {
+ step RegionCovPerLane[version=16] {
+ input: bam_file=sample.bam, sample_id=sample.id;
+ output: File("${sample.id}.rcl") into rcl;
+ }
+ step MakeLaneList[version=11] {
+ input: bam_file=sample.bam, sample_id=sample.id;
+ output: File("${sample.id}.lanelist") into lanelist;
+ }
+ }
+ step CopyNumberQC[version=25] {
+ input: lanes_list=lanelist, rcl_list=rcl, lane_blacklist=lane_blacklist;
+ }
+}
View
@@ -0,0 +1,27 @@
+/* inputs:
+ * 1) MutSigPreprocess.{individual_set_id, maf1, maf2, maf3, maf4, maflabel1, maflabel2, maflabel3, maflabel4, wig1, wig2, wig3, wig4, build, context65_dir, build_dir, num_categories, target_list, paramfile}
+ * 2) ProcessCoverageForMutSig has no variables. All inputs come from prior step.
+ * 3) MutSigRun.{individual_set_id, gene_list, build, geneset_file, cosmic_file, refseq_file, build_dir, param_file, jobcount}
+ */
+
+composite_task MutSig {
+
+ step MutSigPreprocess[version=86] {
+ output: File("coverage.prepare.txt") as coverage_prepare_file,
+ File("patients.txt") as patient_list,
+ File("${individual_set_id}.maf") as mutation_list,
+ File("mutation_preprocessing_report.txt") as mutation_preprocessing_report;
+ }
+
+ step ProcessCoverageForMutSig[version=75] {
+ input: coverage=coverage_prepare_file, patients=patient_list, mutations=mutation_list;
+ output: File("coverage.mat") as coverage_file,
+ File("mutcategs.txt") as category_file;
+ }
+
+ step MutSigRun[version=157] as MutSig {
+ input: mutation_list=mutation_list, coverage_file=coverage_file, patients=patient_list, category_file=category_file, mutation_preprocessing_report=foobar;
+ output: File("bargraphs.png") as graphs;
+ }
+
+}
@@ -0,0 +1,28 @@
+{
+ "ll1": {
+ "start": "wdl",
+ "rules": [
+ "wdl := list(wdl_entity)",
+ "wdl_entity := composite_task",
+ "composite_task := 'composite_task' + 'identifier' + 'lbrace' + list(composite_task_entity) + 'rbrace' -> CompositeTask( name=$1, body=$3 )",
+ "composite_task_entity := step | for_loop | composite_task",
+ "for_loop := 'for' + 'lparen' + 'identifier' + 'in' + 'identifier' + 'rparen' + 'lbrace' + list(composite_task_entity) + 'rbrace' -> ForLoop( collection=$4, item=$2, body=$7 )",
+ "step := 'step' + task_identifier + optional(step_name) + 'lbrace' + list(step_attr) + 'rbrace' -> Step( task=$1, name=$2, body=$4 )",
+ "task_identifier := 'identifier' + optional(task_attrs) -> Task(name=$0, attributes=$1)",
+ "task_attrs := 'lsquare' + list(task_attr) + 'rsquare' -> $1",
+ "task_attr := 'identifier' + 'assign' + task_attr_value -> TaskAttribute(key=$0, value=$2)",
+ "task_attr_value := 'identifier' | 'string' | 'number'",
+ "step_name := 'as' + 'identifier' -> $1",
+ "step_attr := step_input_list | step_output_list",
+ "step_input_list := 'input' + 'colon' + list(step_input, 'comma') + 'semi' -> StepInputList( inputs=$2 )",
+ "step_input := 'identifier' + 'assign' + variable -> StepInput(parameter=$0, value=$2)",
+ "step_output_list := 'output' + 'colon' + list(step_output, 'comma') + 'semi' -> StepOutputList( outputs=$2 )",
+ "step_output := step_output_mode + 'lparen' + 'string' + 'rparen' + step_output_location -> StepOutput( mode=$0, expression=$2, var=$4 )",
+ "step_output_mode := 'file' | 'first_line'",
+ "step_output_location := 'as' + variable -> OutputVariable( var=$1 )",
+ "step_output_location := 'into' + variable -> OutputListAppend( var=$1 )",
+ "variable := 'identifier' + optional(variable_member) -> Variable(name=$0, member=$1)",
+ "variable_member := 'dot' + 'identifier -> $1"
+ ]
+ }
+}
Oops, something went wrong.

0 comments on commit f9b810b

Please sign in to comment.