<commit_before>#!/usr/bin/env python3

"""exfi.io.fasta_to_dict.py: submodule to convert a fasta file into a dict"""

from Bio.SeqIO.FastaIO import \
    SimpleFastaParser

from exfi.classes import FastaDict

def fasta_to_dict(filename: str) -> FastaDict:
    """Fast Fasta to dict via SimpleFastaParser

    :param filename: str: Path to the fasta file

    """
    with open(filename, "r") as handle:
        return FastaDict(SimpleFastaParser(handle))<commit_msg>Bugfix: SimpleFastaParser uses the entire header as identifier!<commit_after>#!/usr/bin/env python3

"""exfi.io.fasta_to_dict.py: submodule to convert a fasta file into a dict"""

from Bio.SeqIO.FastaIO import \
    SimpleFastaParser

from exfi.classes import FastaDict

def fasta_to_dict(filename: str) -> FastaDict:
    """Fast Fasta to dict via SimpleFastaParser

    :param filename: str: Path to the fasta file

    """
    with open(filename, "r") as handle:
        return FastaDict(
            (identifier.split(" ")[0], sequence)
            for identifier, sequence in SimpleFastaParser(handle)
        )
{'fraction_non_alphanumeric': 0.09898242368177614, 'fraction_numerical': 0.0027752081406105457, 'mean_word_length': 3.623931623931624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2065523', 'n_tokens_mistral': 348, 'n_tokens_neox': 340, 'n_words': 104}