[Biopython] Generator expression for SeqIO
Mic
mictadlo at gmail.com
Tue Nov 29 02:06:58 UTC 2011
Hello,
How is it possible to use generator expression for the following code?
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
a = {'a': 'AAA', 1: 'ATC', 3: 'CCT', 2: 'TCT'}
order = [1, 2, 3, 'a']
records = (SeqRecord(Seq(seq), id=str(ref), description="") for ref_name in
order: for ref, seq in a[ref_name].items())
output_handle = open('a.fasta', 'w')
SeqIO.write(records, output_handle, "fasta")
output_handle.close()
Error message:
$ python x.py
File "x.py", line 7
records = (SeqRecord(Seq(seq), id=str(ref), description="") for
ref_name in order: for ref, seq in a[ref_name].items())
^
SyntaxError: invalid syntax
Thank you in advance.
More information about the Biopython
mailing list