from pathlib import Path
from typing import Dict
from typing import Any
from typing import Iterable


def compose_trimming_command(
        output_path: Path,
        trimming_parameters: Dict[str, Any],
        number_of_processes: int,
        input_paths: Iterable[Path]
):
    """
    Compose a shell command to run skewer on the reads located by read_paths.

    :param output_path: The Path to a directory where the output from skewer should be stored
    :param trimming_parameters: The trimming parameters
        (see virtool_workflow.analysis.trimming_parameters)
    :param number_of_processes: The number of allowable processes to be used by skewer
    :param input_paths: The paths to the reads data
        (see virtool_workflow.analysis.reads_path)
    """
    command = [
        "skewer",
        "-r", str(trimming_parameters["max_error_rate"]),
        "-d", str(trimming_parameters["max_indel_rate"]),
        "-m", str(trimming_parameters["mode"]),
        "-l", str(trimming_parameters["min_length"]),
        "-q", str(trimming_parameters["end_quality"]),
        "-Q", str(trimming_parameters["mean_quality"]),
        "-t", str(number_of_processes),
        "-o", str(output_path/"reads"),
        "-n",
        "-z",
        "--quiet",
    ]

    if trimming_parameters["max_length"]:
        command += [
            "-L", str(trimming_parameters["max_length"]),
            "-e"
        ]

    command += [str(path) for path in input_paths]

    return command