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

import typing
import pathlib
from styxdefs import *

FOCI_GET_PROJECTION_VERTEX_METADATA = Metadata(
    id="9698c37ae8d619d4e10d7f0fad13430ab0600e96.workbench",
    name="foci-get-projection-vertex",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_FociGetProjectionVertexParamsDictNoTag = typing.TypedDict('_FociGetProjectionVertexParamsDictNoTag', {
    "foci": InputPathType,
    "surface": InputPathType,
    "metric-out": str,
    "name": typing.NotRequired[str | None],
})
FociGetProjectionVertexParamsDictTagged = typing.TypedDict('FociGetProjectionVertexParamsDictTagged', {
    "@type": typing.Literal["workbench/foci-get-projection-vertex"],
    "foci": InputPathType,
    "surface": InputPathType,
    "metric-out": str,
    "name": typing.NotRequired[str | None],
})
FociGetProjectionVertexParamsDict = _FociGetProjectionVertexParamsDictNoTag | FociGetProjectionVertexParamsDictTagged


class FociGetProjectionVertexOutputs(typing.NamedTuple):
    """
    Output object returned when calling `FociGetProjectionVertexParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    metric_out: OutputPathType
    """the output metric file"""


def foci_get_projection_vertex_params(
    foci: InputPathType,
    surface: InputPathType,
    metric_out: str,
    name: str | None = None,
) -> FociGetProjectionVertexParamsDictTagged:
    """
    Build parameters.
    
    Args:
        foci: the foci file.
        surface: the surface related to the foci file.
        metric_out: the output metric file.
        name: select a focus by name\
            \
            the name of the focus.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/foci-get-projection-vertex",
        "foci": foci,
        "surface": surface,
        "metric-out": metric_out,
    }
    if name is not None:
        params["name"] = name
    return params


def foci_get_projection_vertex_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `FociGetProjectionVertexParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("foci", None) is None:
        raise StyxValidationError("`foci` must not be None")
    if not isinstance(params["foci"], (pathlib.Path, str)):
        raise StyxValidationError(f'`foci` has the wrong type: Received `{type(params.get("foci", None))}` expected `InputPathType`')
    if params.get("surface", None) is None:
        raise StyxValidationError("`surface` must not be None")
    if not isinstance(params["surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`surface` has the wrong type: Received `{type(params.get("surface", None))}` expected `InputPathType`')
    if params.get("metric-out", None) is None:
        raise StyxValidationError("`metric-out` must not be None")
    if not isinstance(params["metric-out"], str):
        raise StyxValidationError(f'`metric-out` has the wrong type: Received `{type(params.get("metric-out", None))}` expected `str`')
    if params.get("name", None) is not None:
        if not isinstance(params["name"], str):
            raise StyxValidationError(f'`name` has the wrong type: Received `{type(params.get("name", None))}` expected `str | None`')


def foci_get_projection_vertex_cargs(
    params: FociGetProjectionVertexParamsDict,
    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.extend([
        "wb_command",
        "-foci-get-projection-vertex"
    ])
    cargs.append(execution.input_file(params.get("foci", None)))
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(params.get("metric-out", None))
    if params.get("name", None) is not None:
        cargs.extend([
            "-name",
            params.get("name", None)
        ])
    return cargs


def foci_get_projection_vertex_outputs(
    params: FociGetProjectionVertexParamsDict,
    execution: Execution,
) -> FociGetProjectionVertexOutputs:
    """
    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 = FociGetProjectionVertexOutputs(
        root=execution.output_file("."),
        metric_out=execution.output_file(params.get("metric-out", None)),
    )
    return ret


def foci_get_projection_vertex_execute(
    params: FociGetProjectionVertexParamsDict,
    runner: Runner | None = None,
) -> FociGetProjectionVertexOutputs:
    """
    GET PROJECTION VERTEX FOR FOCI.
    
    For each focus, a column is created in <metric-out>, and the vertex with the
    most influence on its projection is assigned a value of 1 in that column,
    with all other vertices 0. If -name is used, only one focus will be used.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FociGetProjectionVertexOutputs`).
    """
    foci_get_projection_vertex_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(FOCI_GET_PROJECTION_VERTEX_METADATA)
    params = execution.params(params)
    cargs = foci_get_projection_vertex_cargs(params, execution)
    ret = foci_get_projection_vertex_outputs(params, execution)
    execution.run(cargs)
    return ret


def foci_get_projection_vertex(
    foci: InputPathType,
    surface: InputPathType,
    metric_out: str,
    name: str | None = None,
    runner: Runner | None = None,
) -> FociGetProjectionVertexOutputs:
    """
    GET PROJECTION VERTEX FOR FOCI.
    
    For each focus, a column is created in <metric-out>, and the vertex with the
    most influence on its projection is assigned a value of 1 in that column,
    with all other vertices 0. If -name is used, only one focus will be used.
    
    Args:
        foci: the foci file.
        surface: the surface related to the foci file.
        metric_out: the output metric file.
        name: select a focus by name\
            \
            the name of the focus.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FociGetProjectionVertexOutputs`).
    """
    params = foci_get_projection_vertex_params(
        foci=foci,
        surface=surface,
        metric_out=metric_out,
        name=name,
    )
    return foci_get_projection_vertex_execute(params, runner)


__all__ = [
    "FOCI_GET_PROJECTION_VERTEX_METADATA",
    "FociGetProjectionVertexOutputs",
    "FociGetProjectionVertexParamsDict",
    "FociGetProjectionVertexParamsDictTagged",
    "foci_get_projection_vertex",
    "foci_get_projection_vertex_execute",
    "foci_get_projection_vertex_params",
]
