from pathlib import Path
from viennaptm.gromacs.gromacs_command import GromacsCommand


class EditConf(GromacsCommand):
    """
    Wrapper for the GROMACS ``editconf`` command.

    This class constructs and executes a ``gmx editconf`` command to
    center a structure, define a cubic simulation box, and apply a
    fixed distance between the solute and the box edge.

    The command is built using the configured GROMACS binary and
    produces a single output ``.gro`` file.

    :param input_gro:
        Path to the input GRO structure file.
    :type input_gro: pathlib.Path
    :param output_gro:
        Path to the output GRO structure file.
    :type output_gro: pathlib.Path
    :param kwargs:
        Additional keyword arguments forwarded to
        :class:`GromacsCommand`.
    :type kwargs: dict
    """

    def __init__(self, input_gro: Path, output_gro: Path, **kwargs):
        self.input_gro = input_gro
        self.output_gro = output_gro
        super().__init__(**kwargs)

    def build_gromacs_cmd(self):
        """
        Construct the ``gmx editconf`` command invocation.

        The generated command centers the input structure, places it
        in a cubic simulation box, and enforces a fixed distance
        between the solute and the box boundary.

        :return:
            Command-line argument list suitable for execution.
        :rtype: list[str]
        """

        return [
            self.gmx_bin, "editconf",
            "-f", str(self.input_gro),
            "-o", str(self.output_gro),
            "-c",
            "-d", "1.0",
            "-bt", "cubic"
        ]

    def expected_outputs(self):
        """
        Declare the files expected to be generated by this command.

        This method is typically used by workflow or execution
        managers to validate successful command completion.

        :return:
            List containing the path to the generated output GRO file.
        :rtype: list[pathlib.Path]
        """

        return [self.output_gro]
