コード例 #1
0
 def test_inputs_generator_secondary_files(self):
     w = WorkflowBuilder("tst")
     w.input("wsec", TestTypeWithSecondary, default="test.ext")
     # w._add_input(Input("wsec", TestTypeWithSecondary(), value="test.ext"))
     inpsdict = WdlTranslator().build_inputs_file(w, merge_resources=False)
     self.assertEqual("test.ext", inpsdict.get("tst.wsec"))
     self.assertEqual("test.txt", inpsdict.get("tst.wsec_txt"))
コード例 #2
0
    def test_add_non_scatter(self):
        w = WorkflowBuilder("scatterededge")
        inp = w.input("inp", str)
        stp = w.step("stp", SingleTestTool(inputs=inp))

        e = first_value(w.stp.sources["inputs"].source_map)
        self.assertIsNone(stp.scatter)
コード例 #3
0
 def test_simple(self):
     w = WorkflowBuilder("test_add_single_to_array_edge")
     w.step("ech", SingleTestTool(input1="Hello"), doc="Print 'Hello'")
     c = CwlTranslator.translate_workflow_to_all_in_one(
         w, allow_empty_container=True
     )
     print(CwlTranslator.stringify_translated_workflow(c))
コード例 #4
0
 def test_input_in_input_novalue_nooptional_nodefault(self):
     wf = WorkflowBuilder(
         "test_cwl_input_in_input_novalue_nooptional_nodefault")
     wf.input("inpId", String())
     # included because no value, no default, and not optional
     self.assertDictEqual({"inpId": None},
                          self.translator.build_inputs_file(wf))
コード例 #5
0
    def test_input_in_input_value_optional_default(self):
        wf = WorkflowBuilder("test_input_in_inputfile")
        wf.input("inpId", String(optional=True), default="1")

        self.assertDictEqual(
            {"test_input_in_inputfile.inpId": "1"},
            self.translator.build_inputs_file(wf),
        )
コード例 #6
0
ファイル: test_workflow.py プロジェクト: xinzhel97/janis-core
    def test_check_explicit_inputs(self):
        w = WorkflowBuilder("wf")

        d = w.forward_inputs_from_tool(SingleTestTool,
                                       inputs_to_forward=["input1"])

        self.assertEqual(1, len(d))
        self.assertEqual(d["input1"].id(), "input1")
コード例 #7
0
    def test_add_non_scatter_fail(self):
        w = WorkflowBuilder("scatterededge")
        w.input("inp", Array(str))
        stp = w.step("stp", SingleTestTool(inputs=w.inp))

        e = first_value(w.stp.sources["inputs"].source_map)

        self.assertFalse(e.compatible_types)
コード例 #8
0
    def test_add_scatter_incompatible(self):
        w = WorkflowBuilder("scatterededge")
        w.input("inp", Array(int))
        stp = w.step("stp", SingleTestTool(inputs=w.inp), scatter="inputs")

        e = first_value(w.stp.sources["inputs"].source_map)

        self.assertTrue(e.scatter)
        self.assertFalse(e.compatible_types)
コード例 #9
0
    def test_add_scatter(self):
        w = WorkflowBuilder("scatterededge")
        w.input("inp", Array(str))
        stp = w.step("stp", SingleTestTool(inputs=w.inp), scatter="inputs")

        e = first_value(w.stp.sources["inputs"].source_map)

        self.assertTrue(e.compatible_types)
        self.assertListEqual(["inputs"], stp.scatter.fields)
コード例 #10
0
    def test_input_in_input_novalue_optional_default(self):
        wf = WorkflowBuilder("test_input_in_inputfile")
        wf.input("inpId", String(optional=True), default="2")

        # new interpretation: defaults appear in inputs
        self.assertDictEqual(
            {"test_input_in_inputfile.inpId": "2"},
            self.translator.build_inputs_file(wf),
        )
コード例 #11
0
    def test_add_scatter_nested_arrays_incompatible(self):
        w = WorkflowBuilder("scatterededge")
        w.input("inp", Array(Array(int)))
        stp = w.step("stp", ArrayTestTool(inputs=w.inp), scatter="inputs")

        e = first_value(w.stp.sources["inputs"].source_map)

        self.assertFalse(e.compatible_types)
        self.assertListEqual(["inputs"], stp.scatter.fields)
コード例 #12
0
ファイル: test_workflow.py プロジェクト: xinzhel97/janis-core
    def test_add_scatter_nested_arrays(self):
        w = WorkflowBuilder("scatterededge")
        w.input("inp", Array(Array(str)))
        stp = w.step("stp", ArrayTestTool(inps=w.inp), scatter="inps")

        e = w.stp.sources["inps"].source_map[0]

        self.assertTrue(e.compatible_types)
        self.assertListEqual(["inps"], stp.scatter.fields)
コード例 #13
0
 def test_invalid_scatter_field_list(self):
     w = WorkflowBuilder("scatterededge")
     w.input("inp", Array(String()))
     self.assertRaises(
         Exception,
         w.step,
         identifier="stp",
         tool=ArrayTestTool(inputs=w.inp),
         scatter=["inputs", "randomfield"],
     )
コード例 #14
0
    def process_subpipeline(**connections):
        w = WorkflowBuilder("split_bam_subpipeline")

        w.input("bam", BamBai)
        w.input("intervals", Bed(optional=True))
        w.step("split_bam",
               gatk4.Gatk4SplitReads_4_1_3(bam=w.bam, intervals=w.intervals))
        w.output("out", source=w.split_bam.out)

        return w(**connections)
コード例 #15
0
    def WorkflowBuilder(self):
        w = WorkflowBuilder("test_add_node")
        inp = w.input("inp", str)
        stp = w.step("stp", SingleTestTool(), ignore_missing=True)

        self.assertEqual(len(w.input_nodes), 1)
        self.assertEqual(len(w.step_nodes), 1)
        self.assertEqual(len(w.output_nodes), 0)
        self.assertEqual(w.nodes["inp"].id(), inp.id())
        self.assertEqual(w.nodes["stp"].id(), stp.id())
コード例 #16
0
ファイル: test_workflow.py プロジェクト: xinzhel97/janis-core
    def test_add_qualified_edge(self):
        w = WorkflowBuilder("test_add_edge")
        inp = w.input("inp", str).input_node
        stp = w.step("stp", SingleTestTool(input1=w.inp))

        e = stp.sources["input1"].source_map[0]

        self.assertEqual(e.source.input_node.id(), inp.id())
        self.assertEqual(e.finish.id(), stp.id())
        self.assertEqual(e.ftag, first_value(stp.inputs()).id())
コード例 #17
0
ファイル: test_workflow.py プロジェクト: xinzhel97/janis-core
    def test_check_implicit_inputs(self):
        w = WorkflowBuilder("wf")

        Tool = SingleTestTool()

        d = w.forward_inputs_from_tool(SingleTestTool,
                                       inputs_to_ignore=["input1"])

        self.assertEqual(len(Tool.tool_inputs()) - 1, len(d))
        self.assertNotIn("input1", d)
コード例 #18
0
    def test_dot_4(self):
        w = WorkflowBuilder("sbmf")
        w.input("inp", Array(str))
        w.input("inp2", Array(str))
        w.input("inp3", Array(str))
        w.input("inp4", Array(str))

        step = w.step(
            "dotTool",
            SingleTestTool(inputs=w.inp, input2=w.inp2, input3=w.inp3, input4=w.inp4),
            scatter=ScatterDescription(
                fields=["inputs", "input2", "input3", "input4"],
                method=ScatterMethods.dot,
            ),
        )

        outp = wdl.translate_step_node(
            step, "A.SingleTestTool", {}, {"inp", "inp2", "inp3", "inp4"}
        )
        expected = """\
scatter (Q in zip(inp, zip(inp2, zip(inp3, inp4)))) {
   call A.SingleTestTool as dotTool {
    input:
      inputs=Q.left,
      input2=Q.right.left,
      input3=Q.right.right.left,
      input4=Q.right.right.right
  }
}"""
        self.assertEqual(expected, outp.get_string(indent=0))
コード例 #19
0
    def test_overrided_input_optional_default(self):
        wf = WorkflowBuilder("test_input_in_inputfile")
        wf.input("inpId", String(optional=True), default="2")

        ad = {"inpId": "4"}

        # new interpretation: defaults appear in inputs
        self.assertDictEqual(
            {"test_input_in_inputfile.inpId": "4"},
            self.translator.build_inputs_file(wf, additional_inputs=ad),
        )
コード例 #20
0
    def test_add_qualified_edge(self):
        w = WorkflowBuilder("test_add_edge")
        inp = w.input("inp", str)
        stp = w.step("stp", SingleTestTool(inputs=w.inp))

        e = first_value(stp.sources["inputs"].source_map)

        self.assertEqual(e.start.id(), inp.id())
        self.assertEqual(e.finish.id(), stp.id())
        self.assertIsNone(e.stag)
        self.assertEqual(e.ftag, first_value(stp.inputs()).id())
コード例 #21
0
ファイル: test_workflow.py プロジェクト: xinzhel97/janis-core
    def test_add_edge_later(self):
        w = WorkflowBuilder("test_add_edge")
        inp = w.input("inp", str)
        stp = w.step("stp", SingleTestTool(), ignore_missing=True)

        stp["input1"] = inp

        e: Edge = stp.sources["input1"].source_map[0]
        input_node: InputNodeSelector = e.source
        self.assertEqual(input_node.input_node.id(), inp.input_node.id())
        self.assertEqual(e.finish.id(), stp.id())
        self.assertEqual(e.ftag, first_value(stp.inputs()).id())
コード例 #22
0
    def test_add_edge_later(self):
        w = WorkflowBuilder("test_add_edge")
        inp = w.input("inp", str)
        stp = w.step("stp", SingleTestTool(), ignore_missing=True)

        stp["inputs"] = inp

        e = first_value(stp.sources["inputs"].source_map)

        self.assertEqual(e.start.id(), inp.id())
        self.assertEqual(e.finish.id(), stp.id())
        self.assertIsNone(e.stag)
        self.assertEqual(e.ftag, first_value(stp.inputs()).id())
コード例 #23
0
    def test_expression_default(self):

        wf = WorkflowBuilder("test_expression_defaults")
        wf.input("inp", Optional[str])

        wf.step(
            "echo",
            EchoTestTool(inp="Hello, " +
                         If(IsDefined(wf.inp), wf.inp, ", Michael!")),
        )

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

        wf.translate("cwl")
コード例 #24
0
    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())
コード例 #25
0
ファイル: test_workflow.py プロジェクト: rlupat/janis-core
    def setUpClass(cls):
        wf = WorkflowBuilder("test_workflow_input_collection")

        cls.inmap = {
            "user": InputQualityType.user,
            "static": InputQualityType.static,
            "configuration": InputQualityType.configuration,
            "none": None,
        }

        for i, itype in cls.inmap.items():
            wf.input(i, str, doc=InputDocumentation(None, quality=itype))

        cls.wf = wf
コード例 #26
0
 def test_alias_selector(self):
     w = WorkflowBuilder("wf")
     w.input("inp", str)
     w.step("echo", EchoTestTool(inp=w.inp.as_type(str)))
     w.output("out", source=w.echo.out)
     sn: List[cwlgen.WorkflowStep] = cwl.translate_step_node(
         w.step_nodes["echo"], inputs_dict={"inp": ToolInput("inp", str)}
     )
     self.assertEqual("inp", sn[0].in_[0].source)
コード例 #27
0
    def test_output_name_and_folder(self):
        w = WorkflowBuilder("wf")
        w.input("inp", str)
        w.step("print", Echo(inp=w.inp))
        w.output("out", source=w.print, output_name=w.inp, output_folder=[w.inp])

        inputs = {"inp": ["test1", "test2"]}
        modifier = BatchPipelineModifier(BatchRunRequirements(["inp"], "inp"))
        new_workflow = modifier.tool_modifier(w, inputs, {})
        print(new_workflow)
コード例 #28
0
    def test_workflow_string_not_null(self):
        w = WorkflowBuilder("wf")
        w.input("inp", Optional[str])
        w.output("out", source=w.inp.assert_not_null())

        cwltool = w.translate("cwl", allow_empty_container=True, to_console=False)[0]
        print(cwltool)
コード例 #29
0
    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_cwl, _ = CwlTranslator.translate_workflow(w)
        stps = {stp.id: stp for stp in wf_cwl.steps}

        self.assertEqual("tools/TestTranslationtool.cwl", stps["stp1"].run)
        self.assertEqual("tools/TestTranslationtool_v0_0_2.cwl", stps["stp2"].run)
コード例 #30
0
    def test_read_contents(self):
        w = WorkflowBuilder("wf")
        w.input("inp", str)
        w.step("stp", EchoTestTool(inp=w.inp))
        w.output("out", source=w.stp.out.contents())

        w_cwl = cwl.CwlTranslator().translate_workflow(w, with_container=False)[0]

        self.assertEqual(2, len(w_cwl.steps))
        self.assertEqual(
            "${return {out: inputs._stpout.contents }}", w_cwl.steps[1].run.expression
        )
        self.assertTrue(w_cwl.steps[1].run.inputs[0].loadContents)