Пример #1
0
    def constructor(self):
        self.input("mystring", Optional[str], value="")
        self.input("mystring_backup", Optional[str])

        self.step(
            "print",
            EchoTestTool(inp=If(IsDefined(self.mystring), self.mystring,
                                self.mystring_backup)),
        )

        self.output("out", source=self.print)
Пример #2
0
    def test_array_step_input(self):
        wf = WorkflowBuilder("cwl_test_array_step_input")
        wf.input("inp1", Optional[str])
        wf.input("inp2", Optional[str])

        wf.step(
            "print",
            ArrayTestTool(
                inps=[
                    If(IsDefined(wf.inp1), wf.inp1, "default1"),
                    If(IsDefined(wf.inp2), wf.inp2 + "_suffix", ""),
                ]
            ),
        ),

        wf.output("out", source=wf.print)

        ret, _, _ = wf.translate("cwl", allow_empty_container=True, to_console=False)
        self.maxDiff = None
        self.assertEqual(cwl_arraystepinput, ret)
Пример #3
0
 def arguments(self):
     return [
         ToolArgument(
             StringFormatter(
                 "-Xmx{memory}G {compression} {otherargs}",
                 memory=MemorySelector() * 3 / 4,
                 compression=If(
                     IsDefined(InputSelector("compression_level")),
                     "-Dsamjdk.compress_level=" +
                     InputSelector("compression_level"),
                     "",
                 ),
                 otherargs=JoinOperator(
                     FirstOperator([InputSelector("javaOptions"), []]),
                     " "),
             ),
             prefix="--java-options",
             position=-1,
         )
     ]
Пример #4
0
    def test_basic(self):
        w = WorkflowBuilder("my_conditional_workflow")

        w.input("inp", String(optional=True))

        w.step(
            "print_if_has_value",
            TestTool(testtool=w.inp),
            # only print if the input "inp" is defined.
            when=IsDefined(w.inp),
        )

        w.output("out", source=w.print_if_has_value)

        inputs_dict = {"inp": ToolInput("inp", str)}

        c = cwl.translate_step_node(w.print_if_has_value, inputs_dict=inputs_dict)[0]

        self.assertEqual("$((inputs.__when_inp != null))", c.when)
        extra_input: cwlgen.WorkflowStepInput = c.in_[-1]
        self.assertEqual("__when_inp", extra_input.id)
Пример #5
0
 def arguments(self):
     return [
         # CADD
         ToolArgument(
             If(
                 IsDefined(InputSelector("caddReference")),
                 "--plugin CADD,"
                 + JoinOperator(
                     InputSelector("caddReference").assert_not_null(), ","
                 ),
                 "",
             ),
             shell_quote=False,
         ),
         # Condel
         ToolArgument(
             If(
                 IsDefined(InputSelector("condelConfig")),
                 "--plugin "
                 + StringFormatter(
                     "Condel,{condelconfig},b",
                     condelconfig=InputSelector("condelConfig").assert_not_null(),
                 ),
                 "",
             ),
             shell_quote=False,
         ),
         # dbNSFP
         ToolArgument(
             If(
                 AndOperator(
                     IsDefined(InputSelector("dbnspReference")),
                     IsDefined(InputSelector("dbsnpColumns")),
                 ),
                 "--plugin "
                 + StringFormatter(
                     "dbNSFP,{ref},{cols}",
                     ref=InputSelector("dbnspReference").assert_not_null(),
                     cols=JoinOperator(
                         InputSelector("dbsnpColumns").assert_not_null(), ","
                     ),
                 ),
                 "",
             ),
             shell_quote=False,
         ),
         # REVEL
         ToolArgument(
             If(
                 IsDefined(InputSelector("revelReference")),
                 "--plugin "
                 + StringFormatter(
                     "REVEL,{ref}",
                     ref=InputSelector("revelReference").assert_not_null(),
                 ),
                 "",
             ),
             shell_quote=False,
         ),
         # CUSTOM 1
         ToolArgument(
             If(
                 AndOperator(
                     IsDefined(InputSelector("custom1Reference")),
                     IsDefined(InputSelector("custom1Columns")),
                 ),
                 "--custom "
                 + StringFormatter(
                     "{ref},{cols}",
                     ref=InputSelector("custom1Reference").assert_not_null(),
                     cols=JoinOperator(
                         InputSelector("custom1Columns").assert_not_null(), ","
                     ),
                 ),
                 "",
             ),
             shell_quote=False,
         ),
         # CUSTOM 2
         ToolArgument(
             If(
                 AndOperator(
                     IsDefined(InputSelector("custom2Reference")),
                     IsDefined(InputSelector("custom2Columns")),
                 ),
                 "--custom "
                 + StringFormatter(
                     "{ref},{cols}",
                     ref=InputSelector("custom2Reference").assert_not_null(),
                     cols=JoinOperator(
                         InputSelector("custom2Columns").assert_not_null(), ","
                     ),
                 ),
                 "",
             ),
             shell_quote=False,
         ),
     ]
Пример #6
0
    def is_not_null(self):
        from janis_core.operators.logical import IsDefined

        return IsDefined(self)