# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *

WBSPARSE_MERGE_DENSE_METADATA = Metadata(
    id="678d6e48841edbd3b84295894b5e17d9b4f6d090.boutiques",
    name="wbsparse-merge-dense",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


WbsparseMergeDenseWbsparseParameters = typing.TypedDict('WbsparseMergeDenseWbsparseParameters', {
    "@type": typing.NotRequired[typing.Literal["wbsparse"]],
    "wbsparse_in": str,
})
WbsparseMergeDenseWbsparseParametersTagged = typing.TypedDict('WbsparseMergeDenseWbsparseParametersTagged', {
    "@type": typing.Literal["wbsparse"],
    "wbsparse_in": str,
})


WbsparseMergeDenseParameters = typing.TypedDict('WbsparseMergeDenseParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/wbsparse-merge-dense"]],
    "direction": str,
    "wbsparse_out": str,
    "wbsparse": typing.NotRequired[list[WbsparseMergeDenseWbsparseParameters] | None],
})
WbsparseMergeDenseParametersTagged = typing.TypedDict('WbsparseMergeDenseParametersTagged', {
    "@type": typing.Literal["workbench/wbsparse-merge-dense"],
    "direction": str,
    "wbsparse_out": str,
    "wbsparse": typing.NotRequired[list[WbsparseMergeDenseWbsparseParameters] | None],
})


def wbsparse_merge_dense_wbsparse_params(
    wbsparse_in: str,
) -> WbsparseMergeDenseWbsparseParametersTagged:
    """
    Build parameters.
    
    Args:
        wbsparse_in: a wbsparse file to merge.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "wbsparse",
        "wbsparse_in": wbsparse_in,
    }
    return params


def wbsparse_merge_dense_wbsparse_cargs(
    params: WbsparseMergeDenseWbsparseParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-wbsparse")
    cargs.append(params.get("wbsparse_in", None))
    return cargs


class WbsparseMergeDenseOutputs(typing.NamedTuple):
    """
    Output object returned when calling `WbsparseMergeDenseParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def wbsparse_merge_dense_params(
    direction: str,
    wbsparse_out: str,
    wbsparse: list[WbsparseMergeDenseWbsparseParameters] | None = None,
) -> WbsparseMergeDenseParametersTagged:
    """
    Build parameters.
    
    Args:
        direction: which dimension to merge along, ROW or COLUMN.
        wbsparse_out: output - the output wbsparse file.
        wbsparse: specify an input wbsparse file.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/wbsparse-merge-dense",
        "direction": direction,
        "wbsparse_out": wbsparse_out,
    }
    if wbsparse is not None:
        params["wbsparse"] = wbsparse
    return params


def wbsparse_merge_dense_cargs(
    params: WbsparseMergeDenseParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("wb_command")
    cargs.append("-wbsparse-merge-dense")
    cargs.append(params.get("direction", None))
    cargs.append(params.get("wbsparse_out", None))
    if params.get("wbsparse", None) is not None:
        cargs.extend([a for c in [wbsparse_merge_dense_wbsparse_cargs(s, execution) for s in params.get("wbsparse", None)] for a in c])
    return cargs


def wbsparse_merge_dense_outputs(
    params: WbsparseMergeDenseParameters,
    execution: Execution,
) -> WbsparseMergeDenseOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = WbsparseMergeDenseOutputs(
        root=execution.output_file("."),
    )
    return ret


def wbsparse_merge_dense_execute(
    params: WbsparseMergeDenseParameters,
    runner: Runner | None = None,
) -> WbsparseMergeDenseOutputs:
    """
    wbsparse-merge-dense
    
    Merge wbsparse files along dense dimension.
    
    The input wbsparse files must have matching mappings along the direction not
    specified, and the mapping along the specified direction must be brain
    models.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `WbsparseMergeDenseOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(WBSPARSE_MERGE_DENSE_METADATA)
    params = execution.params(params)
    cargs = wbsparse_merge_dense_cargs(params, execution)
    ret = wbsparse_merge_dense_outputs(params, execution)
    execution.run(cargs)
    return ret


def wbsparse_merge_dense(
    direction: str,
    wbsparse_out: str,
    wbsparse: list[WbsparseMergeDenseWbsparseParameters] | None = None,
    runner: Runner | None = None,
) -> WbsparseMergeDenseOutputs:
    """
    wbsparse-merge-dense
    
    Merge wbsparse files along dense dimension.
    
    The input wbsparse files must have matching mappings along the direction not
    specified, and the mapping along the specified direction must be brain
    models.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        direction: which dimension to merge along, ROW or COLUMN.
        wbsparse_out: output - the output wbsparse file.
        wbsparse: specify an input wbsparse file.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `WbsparseMergeDenseOutputs`).
    """
    params = wbsparse_merge_dense_params(
        direction=direction,
        wbsparse_out=wbsparse_out,
        wbsparse=wbsparse,
    )
    return wbsparse_merge_dense_execute(params, runner)


__all__ = [
    "WBSPARSE_MERGE_DENSE_METADATA",
    "WbsparseMergeDenseOutputs",
    "wbsparse_merge_dense",
    "wbsparse_merge_dense_execute",
    "wbsparse_merge_dense_params",
    "wbsparse_merge_dense_wbsparse_params",
]
