[BangPypers] nested list question

Shashwat Anand anand.shashwat at gmail.com
Wed Jul 14 05:42:23 CEST 2010


On Wed, Jul 14, 2010 at 9:01 AM, Shashwat Anand <anand.shashwat at gmail.com>wrote:

>
>
> On Tue, Jul 13, 2010 at 8:00 PM, Vikram <kpguy at rediffmail.com> wrote:
>
>> Suppose you have two nested lists, X and Y.
>> A sample element of X is:
>> ['NM_032291', '67000041', '67000051', 'chr1', '+']
>>
>> Another sample element of X is:
>> ['NM_001097', '51183080', '51183635', 'chr22', '+']
>>
>>
>> A sample element of Y is:
>> ['chr1', '67000046']
>>
>> Another sample element of Y is:
>> ['chrY', '59033300']
>>
>> The objective is to identify whether the second element of an element of Y
>> (e.g. 67000046) lies between the the second and third elements of an element
>> of X (e.g. 67000041 and 67000051).
>>
>> Eventually, one should end up with a modified version of Y, let us say
>> modY, which is a filtered version of Y in which the second element of an
>> element of modY is contained within the second and third elements of an
>> element of X.
>>
>> Any suggestions on how i should be going about implementing this?
>>
>
> >>> modY = [y for y in Y for x in X if x[1] < y[1] < x[2]]
>

Also make sure you remove duplicates.



>
>
>>
>> Thanking you,
>> Vikram
>> _______________________________________________
>> BangPypers mailing list
>> BangPypers at python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>
>


More information about the BangPypers mailing list