[Biopython] changing record attributes while iterating
Peter Cock
p.j.a.cock at googlemail.com
Thu Oct 27 08:35:24 UTC 2011
On Thu, Oct 27, 2011 at 2:14 AM, Mic <mictadlo at gmail.com> wrote:
> Thank you it is working.
> I would like to to put sequences id in a list in the following way:
>>>> c = (i.id for i in b)
> SyntaxError: invalid syntax
The above would be a generator expression, and requires
Python 2.4. It shouldn't cause a SyntaxError unless there is
some mistake I'm not seeing (or you missed something in
the copy & paste).
>>>> c[0]
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: 'generator' object is not subscriptable
> How is it possible to generate a list of sequence ids?
You need to create a list (e.g using a list comprehension)
rather than a generator, probably:
c = [i.id for i in b]
c[0] = "Fred"
Peter
More information about the Biopython
mailing list