toil.wdl.versions.v1

Module Contents

Classes

AnalyzeV1WDL

AnalyzeWDL implementation for the 1.0 version using ANTLR4.

Functions

is_context(ctx, classname)

Returns whether an ANTLR4 context object is of the precise type classname.

Attributes

logger

toil.wdl.versions.v1.logger
toil.wdl.versions.v1.is_context(ctx, classname)

Returns whether an ANTLR4 context object is of the precise type classname.

Parameters
  • ctx – An ANTLR4 context object.

  • classname (Union[str, tuple]) – The class name(s) as a string or a tuple of strings. If a tuple is provided, this returns True if the context object matches one of the class names.

Return type

bool

class toil.wdl.versions.v1.AnalyzeV1WDL(wdl_file)

Bases: toil.wdl.wdl_analysis.AnalyzeWDL

digraph inheritancef102f78e53 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AnalyzeV1WDL" [URL="#toil.wdl.versions.v1.AnalyzeV1WDL",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="AnalyzeWDL implementation for the 1.0 version using ANTLR4."]; "AnalyzeWDL" -> "AnalyzeV1WDL" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AnalyzeWDL" [URL="../../wdl_analysis/index.html#toil.wdl.wdl_analysis.AnalyzeWDL",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An interface to analyze a WDL file. Each version corresponds to a subclass that"]; }

AnalyzeWDL implementation for the 1.0 version using ANTLR4.

See: https://github.com/openwdl/wdl/blob/main/versions/1.0/SPEC.md

https://github.com/openwdl/wdl/blob/main/versions/1.0/parsers/antlr4/WdlV1Parser.g4

Parameters

wdl_file (str) –

property version: str

Returns the version of the WDL document as a string.

Return type

str

analyze()

Analyzes the WDL file passed into the constructor and generates the two intermediate data structures: self.workflows_dictionary and self.tasks_dictionary.

visit_document(ctx)

Root of tree. Contains version followed by an optional workflow and any number of `document_element`s.

visit_document_element(ctx)

Contains one of the following: ‘import_doc’, ‘struct’, or ‘task’.

visit_workflow(ctx)

Contains an ‘identifier’ and an array of `workflow_element`s.

visit_workflow_input(ctx)

Contains an array of ‘any_decls’, which can be unbound or bound declarations. Example:

input {

String in_str = “twenty” Int in_int

}

Returns a list of tuple=(name, type, expr).

visit_workflow_output(ctx)

Contains an array of ‘bound_decls’ (unbound_decls not allowed). Example:

output {

String out_str = “output”

}

Returns a list of tuple=(name, type, expr).

visit_inner_workflow_element(ctx)

Returns a tuple=(unique_key, dict), where dict contains the contents of the given inner workflow element.

visit_call(ctx)

Pattern: CALL call_name call_alias? call_body? Example WDL syntax: call task_1 {input: arr=arr}

Returns a dict={task, alias, io}.

visit_scatter(ctx)

Pattern: SCATTER LPAREN Identifier In expr RPAREN LBRACE inner_workflow_element* RBRACE Example WDL syntax: scatter ( i in items) { … }

Returns a dict={item, collection, body}.

visit_conditional(ctx)

Pattern: IF LPAREN expr RPAREN LBRACE inner_workflow_element* RBRACE Example WDL syntax: if (condition) { … }

Returns a dict={expression, body}.

visit_task(ctx)

Root of a task definition. Contains an identifier and an array of `task_element`s.

visit_task_input(ctx)

Contains an array of ‘any_decls’, which can be unbound or bound declarations. Example:

input {

String in_str = “twenty” Int in_int

}

Returns a list of tuple=(name, type, expr)

visit_task_output(ctx)

Contains an array of ‘bound_decls’ (unbound_decls not allowed). Example:

output {

String out_str = read_string(stdout())

}

Returns a list of tuple=(name, type, expr)

visit_task_command(ctx)

Parses the command section of the WDL task.

Contains a string_part plus any number of `expr_with_string`s. The following example command:

‘echo ${var1} ${var2} > output_file.txt’

Has 3 parts:
  1. string_part: ‘echo ‘

  2. expr_with_string, which has two parts:
    • expr_part: ‘var1’

    • string_part: ‘ ‘

  1. expr_with_string, which has two parts:
    • expr_part: ‘var2’

    • string_part: ‘ > output_file.txt’

Returns a list=[] of strings representing the parts of the command.

e.g. [string_part, expr_part, string_part, …]

visit_task_command_string_part(ctx)

Returns a string representing the string_part.

visit_task_command_expr_with_string(ctx)

Returns a tuple=(expr_part, string_part).

visit_task_command_expr_part(ctx)

Contains the expression inside ${expr}. Same function as self.visit_string_expr_part().

Returns the expression.

visit_task_runtime(ctx)

Contains an array of `task_runtime_kv`s.

Returns a dict={key: value} where key can be ‘docker’, ‘cpu’, ‘memory’, ‘cores’, or ‘disks’.

visit_any_decls(ctx)

Contains a bound or unbound declaration.

visit_unbound_decls(ctx)

Contains an unbound declaration. E.g.: String in_str.

Returns a tuple=(name, type, expr), where expr is None.

visit_bound_decls(ctx)

Contains a bound declaration. E.g.: String in_str = “some string”.

Returns a tuple=(name, type, expr).

visit_wdl_type(ctx)

Returns a WDLType instance.

visit_primitive_literal(ctx)

Returns the primitive literal as a string.

visit_number(ctx)

Contains an IntLiteral or a FloatLiteral.

visit_string(ctx)

Contains a string_part followed by an array of `string_expr_with_string_part`s.

visit_string_expr_with_string_part(ctx)

Contains a string_expr_part and a string_part.

visit_string_expr_part(ctx)

Contains an array of expression_placeholder_option`s and an `expr.

visit_string_part(ctx)

Returns a string representing the string_part.

visit_expression_placeholder_option(ctx)

Expression placeholder options.

Can match one of the following:

BoolLiteral EQUAL (string | number) DEFAULT EQUAL (string | number) SEP EQUAL (string | number)

See https://github.com/openwdl/wdl/blob/main/versions/1.0/SPEC.md#expression-placeholder-options

e.g.: ${sep=”, ” array_value} e.g.: ${true=”–yes” false=”–no” boolean_value} e.g.: ${default=”foo” optional_value}

Returns a tuple=(key, value)

visit_expr(ctx)

Expression root.

visit_infix0(ctx)

Expression infix0 (LOR).

visit_lor(ctx)

Logical OR expression.

visit_infix1(ctx)

Expression infix1 (LAND).

visit_land(ctx)

Logical AND expresion.

visit_infix2(ctx)

Expression infix2 (comparisons).

visit_infix3(ctx)

Expression infix3 (add/subtract).

visit_infix4(ctx)

Expression infix4 (multiply/divide/modulo).

visit_infix5(ctx)

Expression infix5.

visit_expr_core(expr)

Expression core.

visit_apply(ctx)

A function call. Pattern: Identifier LPAREN (expr (COMMA expr)*)? RPAREN

visit_array_literal(ctx)

Pattern: LBRACK (expr (COMMA expr)*)* RBRACK

visit_pair_literal(ctx)

Pattern: LPAREN expr COMMA expr RPAREN

visit_ifthenelse(ctx)

Ternary expression. Pattern: IF expr THEN expr ELSE expr

visit_expression_group(ctx)

Pattern: LPAREN expr RPAREN

visit_at(ctx)

Array or map lookup. Pattern: expr_core LBRACK expr RBRACK

visit_get_name(ctx)

Member access. Pattern: expr_core DOT Identifier

visit_negate(ctx)

Pattern: NOT expr

visit_unarysigned(ctx)

Pattern: (PLUS | MINUS) expr

visit_primitives(ctx)

Expression alias for primitive literal.