[Biopython] not technically a biopython question

George Devaniranjan devaniranjan at gmail.com
Mon Oct 8 16:11:06 EDT 2012


Thank you very much, this is what I did and it seems to work.
I found the answer on stack overflow.

if nCatSeq not in potBasin:
    potBasin[nCatSeq] = (nBasinSeq,)
else:
    if nBasinSeq not in potBasin[nCatSeq]:
        potBasin[nCatSeq] = potBasin[nCatSeq] + (nBasinSeq,)



On Mon, Oct 8, 2012 at 3:59 PM, John Ladasky <blind.watchmaker at yahoo.com>wrote:

> Date: Mon, 8 Oct 2012 11:29:37 -0400 From: George Devaniranjan <
> devaniranjan at gmail.com> Subject: [Biopython] not technically a biopython
> question To: Biopython Mailing List <biopython at lists.open-bio.org>
> Message-ID: <CAFU65PcN8zvGEECm=zF2OHDRJ2fY**3Xvq8NRoANHWHnfm5fzv3w at mail.**
> gmail.com <zF2OHDRJ2fY3Xvq8NRoANHWHnfm5fzv3w at mail.gmail.com>>
>
>
>  I get the following as the answer for one nCatSeq,
>> '4241': ((('VUVV', 'DDRV'), 'DDVG'), 'VUVV')
>>
>>
>> what I want however is :
>>
>> '4241': ('VUVV', 'DDRV', 'DDVG', 'VUVV')
>>
>>
> What you want to do is to "flatten" a nested sequence object.  There are
> many Python recipes to do this.  Most of the solutions involve recursive
> function calls.  Here's a page that discusses several ways to get it done:
>
> http://stackoverflow.com/**questions/2158395/flatten-an-**
> irregular-list-of-lists-in-**python<http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python>
>
> If your list or tuple is VERY deeply nested (say, 256 parentheses), you
> may hit Python's recursion limit.  There are solutions on that page which
> don't require recursion, but they are frequently more difficult to
> understand.  I tend to prefer code that I can read at a glance, myself.
>
> I don't know why flattening lists and tuples isn't a standard library
> function in Python yet, it seems like everyone needs to do this at some
> time or another.
>
>
> ______________________________**_________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/**mailman/listinfo/biopython<http://lists.open-bio.org/mailman/listinfo/biopython>
>


More information about the Biopython mailing list