<div dir="ltr"><div>Hello biopython group, </div><div><br></div><div>I'm using biopython 1.78 on a Ubuntu 18.04 LTS system with python 3.6.9 and I am trying to reformat a spades mutli-fasta output file (contigs) so I can then use BRIG. BRIG is expecting only one header per fasta so I'm attempting to concatenate all of the Seq records under one header and write it to a new file. From the traceback I think it is telling me that it doesn't like the new fasta header name however I don't know why.</div><div> </div><div>Any help would be appreciated, thank you.</div><div><br></div><div>Sean Brimer</div><div><br></div>This is my Code:<div><br><div><i>import glob<br>from Bio.SeqRecord import SeqRecord<br>from Bio.Seq import Seq<br>from Bio import SeqIO<br><br>## Looking for fasta files <br><br>fa_list = [i for i in glob.glob("*.fasta")]<br><br>## New file for the contigs for BRIG<br><br>for i in fa_list:<br>    handle = i.rpartition(".")[0]+"_brig.fasta"<br>    with open(handle,"w"):<br>    fa_seq = []<br>    new_head = i.rpartition(".")[0]<br>        for record in SeqIO.parse(i,"fasta"):<br>             fa_seq.append(record.seq)<br>             new_rec = SeqRecord(fa_seq, id = new_head, description = "")</i></div><div><i>SeqIO.write(new_rec, handle, "fasta")</i><br><div><br></div><div><br></div><div>This is the Error(s) I am getting:</div><div><br></div><div><i>Traceback (most recent call last):<br>  File "/home/sean/.local/lib/python3.6/site-packages/Bio/File.py", line 73, in as_handle<br>    yield fp<br>  File "/home/sean/.local/lib/python3.6/site-packages/Bio/SeqIO/__init__.py", line 524, in write<br>    fp.write(format_function(record))<br>  File "/home/sean/.local/lib/python3.6/site-packages/Bio/SeqIO/FastaIO.py", line 389, in as_fasta<br>    data = _get_seq_string(record)  # Catches sequence being None<br>  File "/home/sean/.local/lib/python3.6/site-packages/Bio/SeqIO/Interfaces.py", line 109, in _get_seq_string<br>    raise TypeError("SeqRecord (id=%s) has an invalid sequence." % <a href="http://record.id">record.id</a>)<br>TypeError: SeqRecord (id=LS22-4780-2.4) has an invalid sequence.<br><br>During handling of the above exception, another exception occurred:<br><br>Traceback (most recent call last):<br>  File "brig_fa_formatter.py", line 24, in <module><br>    SeqIO.write(new_rec, handle, "fasta")<br>  File "/home/sean/.local/lib/python3.6/site-packages/Bio/SeqIO/__init__.py", line 525, in write<br>    count += 1<br>  File "/usr/lib/python3.6/contextlib.py", line 126, in __exit__<br>    raise RuntimeError("generator didn't stop after throw()")<br>RuntimeError: generator didn't stop after throw()</i><br></div></div></div></div>