[Biopython] fasta fail

Peter biopython at maubp.freeserve.co.uk
Wed Dec 1 15:44:42 UTC 2010


On Wed, Dec 1, 2010 at 3:13 PM, Liam Thompson <dejmail at gmail.com> wrote:
> hi everyone
>
> I have a list of sequences that I want to write to file in fasta format.
> This is easy enough, however I keep getting an error which I can't fix.
>
> SeqIO.write(final_seq, out_handle, "fasta")
> ...
> TypeError: SeqRecord (id=FN545840.1) has an invalid sequence.
>
> There is nothing wrong with the record, as far as I can see as I have
> written to and extraced from it numerous times as a fasta entry There is
> definitely sequence and other basic information on the record, which I can
> see from a simple print(final_seq[x].seq) The list of sequences is a "list"
> as opposed to a "SeqRecord", so I thought this could be problem ? Is there a
> way to convert a list to a SeqRecord or is this not necessary ?

What is your final_seq object?

You should have a list of SeqRecord objects (or in recent versions
of Biopython you can also give SeqIO.write a single SeqRecord).
Each SeqRecord's seq property should be a Seq object (or similar).

Peter



More information about the Biopython mailing list