Hello,

I am trying to write a dictionary object to a FASTA file however I have problems with writing it.
I could not achieve doing it without using the library or with the library (Biopython).

I tried converting my dictionary to list using "dict.items()" then writing it with SeqIOand error is:

"AttributeError: 'tuple' object has no attribute 'id'"

I would appreciate any kind of help.
Thanks in advance!

WM

The error is clear. Your dictionary is missing the `id` attribute, which is the required parameter to use `SeqIO.write`. Typically, you'd provide a `SeqRecord` object to it, which includes a `Seq` object with parameters like `id` and `description`. You can definitely turn your dictionary into a list of `SeqRecord` objects and everything else should work.

There are quite a few other ways to convert dictionary to the many formats `SeqIO` supports. The easiest (and the least programming experience required) is to simply write your dictionary into a tab-delimited file and use `SeqIO.convert`.

See below for an example.

    from Bio import SeqIO

    a = {'myseq1':'acgt', 'myseq2': 'gctc'}

    # try writing your own code to turn this dictionary into a tab-delimited file (seq.tab), i.e
    # myseq1  acgt
    # myseq2  gctc

    SeqIO.convert('seq.tab', 'tab', 'seq.fa', 'fasta')