from pathlib import Path
import hashlib


def file_md5_is_valid(fasta_file: Path, checksum: str) -> bool:
    """
    Checks if the FASTA file matches the MD5 checksum argument.

    Returns True if it matches and False otherwise.

    :param fasta_file: Path object for the FASTA file.
    :param checksum: MD5 checksum string.
    :return: boolean indicating if the file validates.
    """
    md5_hash = hashlib.md5()
    with fasta_file.open(mode="rb") as fh:
        # Read in small chunks to avoid memory overflow with large files.
        while chunk := fh.read(8192):
            md5_hash.update(chunk)
    return md5_hash.hexdigest() == checksum