from pathlib import Path
from typing import List
from typing import Tuple


def parse_combinations_file(filepath: Path) -> List[Tuple[int, int, int, int, int]]:
    """
    Parse a text file to extract reaction information.

    Args:
       filepath (Path)

    Return:
        reactions (List[Tuple[int, int, int, int, int]]): List of reactions. The five elements
            in each reaction are, in order:
                molecule_1_index
                atom_1_index
                molecule_2_index
                atom_2_index
                product_index

    """
    with open(filepath.as_posix()) as combo_file:
        lines = combo_file.readlines()

        reactions = list()
        # Skip first line - header
        for line in lines[1:]:
            line_parsed = [int(x) for x in line.strip().split("\t")]
            reactions.append(tuple(line_parsed))

        return reactions