def test_two_similar_tools(self): w = WorkflowBuilder("testTwoToolsWithSameId") w.input("inp", str) w.step("stp1", TestTool(testtool=w.inp)) w.step("stp2", TestToolV2(testtool=w.inp)) wf_wdl, _ = WdlTranslator.translate_workflow(w) expected = """\ version development import "tools/TestTranslationtool.wdl" as T import "tools/TestTranslationtool_v0_0_2.wdl" as T2 workflow testTwoToolsWithSameId { input { String inp } call T.TestTranslationtool as stp1 { input: testtool=inp } call T2.TestTranslationtool as stp2 { input: testtool=inp } }""" self.assertEqual(expected, wf_wdl.get_string())
def test_switch(self): from janis_unix import Echo, Cat w = WorkflowBuilder("switchTest") w.input("inp", int, value=2) w.input("inp1", str, value="Hello") w.input("inp2", str, value="Hi there") w.conditional( "echoswitch", [ (w.inp > 1, Echo(inp=w.inp1)), (w.inp.equals(1), Echo(inp="tasy case")), Echo(inp=w.inp2), ], ) w.output("out", source=w.echoswitch) _, wdl_tools = WdlTranslator.translate_workflow(w) expected = """\ version development import "echo_v1_0_0.wdl" as E workflow echoswitch { input { Int cond_inp String switch_case_1_inp String? switch_case_2_inp = "tasy case" String switch_case_3_inp } if ((cond_inp > 1)) { call E.echo as switch_case_1 { input: inp=switch_case_1_inp } } if (((cond_inp == 1) && !((cond_inp > 1)))) { call E.echo as switch_case_2 { input: inp=select_first([switch_case_2_inp, "tasy case"]) } } if (!(((cond_inp > 1) || (cond_inp == 1)))) { call E.echo as switch_case_3 { input: inp=switch_case_3_inp } } output { File out = select_first([switch_case_1.out, switch_case_2.out, switch_case_3.out]) } }""" echoswitch = wdl_tools["echoswitch"].get_string() self.assertEqual(expected, echoswitch)