from pathlib import Path
from typing import List


def read_fasta(path: Path) -> List[tuple]:
    """Parse the FASTA file at `path` and return its content as a `list` of tuples containing the header and sequence.

    :param path: the path to the FASTA file
    :return: the FASTA content

    """
    data = list()

    with open(path, "r") as f:
        header = None
        seq = []

        for line in f:
            if line[0] == ">":
                if header:
                    data.append((header, "".join(seq)))

                header = line.rstrip().replace(">", "")
                seq = []
                continue

            if header:
                seq.append(line.rstrip())
                continue

            raise IOError(f"Illegal FASTA line: {line}")

        if header:
            data.append((header, "".join(seq)))

    return data