[Baypiggies] nested lists problem

Brent Pedersen bpederse at gmail.com
Tue Jul 13 16:49:49 CEST 2010


On Tue, Jul 13, 2010 at 7:33 AM, 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?
>
> Thanking you,
> Vikram
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies

hi vikram,
there's an interval tree in bx-python genomics library that's
specifically for this type of query:
http://bitbucket.org/james_taylor/bx-python/src/d9c88c9359a0/lib/bx/intervals/intersection.pyx

you can just put your X elements in the tree and then query with the Y
points (SNPs?) -- after converting them from string to ints
there's an example use here:
http://biostar.stackexchange.com/questions/617/post-your-prefered-bioinformatics-short-code/637#637
and bx-python is on pypi: http://pypi.python.org/pypi/bx-python/0.6.0

-brent


More information about the Baypiggies mailing list