Location: /app/helpers.py (i.e., create a Python module named helpers with this API)
What to implement
Provide two functions with the following signatures and behaviors:
parse_fasta(path: str) -> list[dict[str, str]]
Purpose: Read a FASTA-formatted file and return a structured representation of its sequences.
Behavior:
The FASTA file may contain multiple records. Each record starts with a header line beginning with '>' followed by an ID (the portion after '>').
The lines after a header belong to the sequence for that record and may be spread across multiple lines.
Return a list of dictionaries, each with:
'id': the header ID string (trim whitespace, exclude the leading '>').
'dna': the concatenated sequence string formed by joining all sequence lines for that record, with all whitespace removed.
Preserve the order of records as they appear in the file.
If a header has no subsequent sequence lines, its 'dna' should be an empty string.
If the file does not exist, raise FileNotFoundError.
Ignore empty lines between records.
Input validation: path must be a string; raise TypeError if not.
output_path(source_file: str) -> str
Purpose: Provide a deterministic path for output associated with a given source file.
Behavior:
Return a path to a file named "output.txt" located in the same directory as the provided source_file.
If the directory cannot be determined from source_file, raise ValueError.
Do not perform file writing; this function only computes and returns the path.
Additional requirements
Use clear, type-annotated Python code with appropriate docstrings.
The module should be importable as from helpers import parse_fasta, output_path and should be usable by the existing tests (including the main script if run).
The implementation goes in /app/helpers.py (or /app/helpers/init.py if you choose to implement it as a package). Ensure the exports are accessible as described.
Maintain compatibility with Python 3.8+ (type hints are fine; avoid using features unavailable in that range).