Beispiel #1
0
    def test_commandtool_string(self):

        t = CommandToolBuilder(
            tool="id",
            base_command=None,
            inputs=[ToolInput("inp", Optional[str])],
            outputs=[
                ToolOutput("out", str, glob=InputSelector("inp").assert_not_null())
            ],
            version=None,
            container=None,
        )

        cwltool = t.translate("cwl", allow_empty_container=True, to_console=False)
        print(cwltool)
Beispiel #2
0
def from_container(
    container: str,
    basecommand: List[str],
    helpcommand="-h",
    containersoftware="docker",
    optionsmarker: Optional[str] = None,
    name: Optional[str] = None,
    version: Optional[str] = None,
    type: ToolTemplateType = ToolTemplateType.base,
):
    helpstr = get_help_from_container(
        container=container,
        basecommand=basecommand,
        help_param=helpcommand,
        containersoftware=containersoftware,
    )
    tooldoc, args = parse_str(helpstr, option_marker=optionsmarker)

    if not version:
        comps = container.split(":")
        version = comps[-1] if len(comps) > 1 else "Latest"

    if not version:
        version = get_version_from_container(
            container,
            basecommand,
            versionparam="-v",
            containersoftware=containersoftware,
        )

    tool_id = name or basecommand
    if isinstance(tool_id, list):
        tool_id = "".join(s.title() for s in tool_id)
    else:
        tool_id = tool_id[0].upper() + tool_id[1:]

    t = CommandToolBuilder(
        tool=tool_id,
        base_command=basecommand,
        inputs=args,
        outputs=[],
        metadata=ToolMetadata(documentation=tooldoc) if tooldoc else None,
        version=version,
        container=container,
    )

    return t.translate("janis", to_console=False), helpstr