def fasta(sequences):
    """Builds a FASTA record of extracted sequences.

    This function expects either a list of Synthase objects (mode='synthase')
    or a dictionary of extracted domains, keyed on synthase header (mode='domains').
    """
    # Entire Synthase objects were extracted
    if isinstance(sequences, list):
        return "\n".join(s.to_fasta() for s in sequences)

    # Domain sequences were extracted
    if isinstance(sequences, dict):
        return "\n".join(
            f">{header}_{index}\n{sequence}"
            for header, sequences in sequences.items()
            for index, sequence in enumerate(sequences)
        )