def test_from_bash_check_io_array(hint, req, sec): tool = cwl.CommandLineTool.from_bash( 'echo $IN', inputs={'IN': cwl.Array(hint, required=req)}, outputs={'OUT': cwl.Array(hint, required=req)}, secondary_files={'IN': sec}) assert tool.inputs[0].type == TypeFactory.create( cwl.Array(hint, required=req), True) assert tool.outputs[0].type == TypeFactory.create( cwl.Array(hint, required=req), False) assert tool.inputs[0].secondary_files == sec
def test_outputs_from_f_arr(tool, hint): f = make_f(int, r={'y': cwl.Array(hint)}) outputs = tool._outputs_from_f(f) o = outputs[0] assert o['id'] == 'y' assert type(o['type']) == cwl.Array assert o['type'].val == hint
def test_inputs_from_f_arr(tool, hint): f = make_f(cwl.Array(hint)) inputs = tool._inputs_from_f(f) i = inputs[0] assert i['id'] == 'x' assert type(i['type']) == cwl.Array assert i['type'].val == hint
def inputs(): return dict( input_str=cwl.String(), input_int=cwl.Int(), input_bool=cwl.Bool(), input_float=cwl.Float(), input_enum=cwl.Enum(['a', 'b', 'c']), input_record=cwl.Record(dict(k1=cwl.String())), input_array=cwl.Array(cwl.Int()), input_no_type=cwl.Any(), input_union=cwl.Union([cwl.Int(), cwl.String()]), input_nonreq_primitive=cwl.String(), input_nonreq_none=cwl.String(), input_nonreq_object=cwl.Enum(['a', 'b', 'c']) )
from sbg import cwl with cwl.workflow('scatter_single.cwl', 'w') as wf: t1 = cwl.ExpressionTool('$({"out": inputs.word })', id='expr_tool1') t1.add_input(cwl.String(required=True), id='word', label='Word') t1.add_output(cwl.String(required=True), id='out', label='Word out') t2 = cwl.ExpressionTool( '$({"out": inputs.word.map(function(x){ return x.toLowerCase()}) })', id='expr_tool2') t2.add_input(cwl.Array(cwl.String(), required=True), id='word', label='Word') t2.add_output(cwl.Array(cwl.String(), required=True), id='out', label='Word out') wf.add_step(t1, expose=['word'], scatter=['word']) wf.add_step(t2, expose=['out']) wf.add_connection('expr_tool1.out', 'expr_tool2.word') wf.add_requirement(cwl.InlineJavascript()) wf.add_requirement(cwl.ScatterFeature())
def test_add_output_arr(cls, hint, required): obj = cls() t = cwl.Array(hint(), required=required) o = obj.add_output(t) assert o.type == TypeFactory.create(t, False)
def test_add_input_arr(cls, hint, required): obj = cls() t = cwl.Array(hint(), required=required) i = obj.add_input(t) assert i.type == TypeFactory.create(t, True)
Resource(), Docker(docker_pull='something'), InlineJavascript(), EnvVar(EnvironmentDef('foo', 'bar')), InitialWorkDir([Dirent('hello world', 'foo.txt')]), EnvVar(EnvironmentDef('foo', 'bar')) ]) def test_find_requirement(req, cls): obj = cls() obj.add_requirement(req) assert obj.find_requirement(req.class_) == req @pytest.mark.parametrize('cls', [CommandLineTool, Workflow]) @pytest.mark.parametrize('type', [ cwl.String(), cwl.Int(), cwl.Float(), cwl.Bool(), cwl.Record(), cwl.Enum(), cwl.Array(cwl.Int()) ]) def test_get_port(type, cls): obj = cls() i = obj.add_input(type, id='in') o = obj.add_output(type, id='out') assert obj.get_port('in') == i assert obj.get_port('out') == o @pytest.mark.parametrize('cls', [CommandLineTool, Workflow]) @pytest.mark.parametrize('type', [ cwl.String(), cwl.Int(), cwl.Float(), cwl.Bool(), cwl.Record(), cwl.Enum(), cwl.Array(cwl.Int()) ])
def outputs(): return dict( out_str=cwl.String(), out_glob_star=cwl.Array(cwl.File(), glob='*.txt'), out_glob=cwl.File(glob="some_name") )