<commit_before>from Bio import Seq
from Bio.Alphabet import IUPAC

from collections import defaultdict

from ..util import xmlwriter

def to_seq(s):
    if isinstance(s, Seq.Seq):
        return s

    t = str(s).upper()
    if all(n in IUPAC.unambiguous_dna.letters for n in t):
        return Seq.Seq(t,IUPAC.unambiguous_dna)
    elif all(n in IUPAC.ambiguous_dna.letters for n in t):<commit_msg>allow spaces in sequence<commit_after>from Bio import Seq
from Bio.Alphabet import IUPAC

from collections import defaultdict

from ..util import xmlwriter

seqfilter = str.maketrans({' ':None, '-':None})

def to_seq(s):
    if isinstance(s, Seq.Seq):
        return s

    t = str(s).upper().translate(seqfilter)
    if all(n in IUPAC.unambiguous_dna.letters for n in t):
        return Seq.Seq(t,IUPAC.unambiguous_dna)
    elif all(n in IUPAC.ambiguous_dna.letters for n in t):
{'fraction_non_alphanumeric': 0.09920182440136831, 'fraction_numerical': 0.0, 'mean_word_length': 3.5492227979274613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7125320', 'n_tokens_mistral': 318, 'n_tokens_neox': 309, 'n_words': 92}