[Tutor] Printing two elements in a list
Kent Johnson
kent37 at tds.net
Tue Dec 7 21:57:22 CET 2004
kumar,
Looking at the quantity and structure of your data I think the search you are doing is going to be
pretty slow - you will be doing 4504 * 398169 = 1,793,353,176 string searches.
Where does the seq data come from? Could you consolidate the pairs of lines into a single record? If
you do that and extract the '399:559' portion, you could build a dict that maps '399:559' to the
full record. Looking up '399:559' in the dictionary would be much, much faster than searching the
entire list.
If you have multiple entries for '399:559' you could have the dict map to a list.
Kent
kumar s wrote:
>
>>>>len(x)
>
> 4504
>
>>>>x[1:10]
>
> ['454:494', '319:607', '319:608', '322:289',
> '322:290', '183:330', '183:329', '364:95', '364:96']
>
>>>>len(seq)
>
> 398169
>
>>>>seq[0:4]
>
> ['>probe:HG-U95Av2:1000_at:399:559;
> Interrogation_Position=1367; Antisense;',
> 'TCTCCTTTGCTGAGGCCTCCAGCTT',
> '>probe:HG-U95Av2:1000_at:544:185;
> Interrogation_Position=1379; Antisense;',
> 'AGGCCTCCAGCTTCAGGCAGGCCAA']
>
>
>
>>>>for ele1 in x:
>
> for ele2 in seq:
> if ele1 in ele2:
> print ele2
>
>
>
>>probe:HG-U95Av2:31358_at:454:493;
>
> Interrogation_Position=132; Antisense;
>
>>probe:HG-U95Av2:31358_at:319:607;
>
> Interrogation_Position=144; Antisense;
>
>
>
>
>
>
> How Do I WANT:
>
> I want to print get an output like this:
>
>
>
>>probe:HG-U95Av2:1000_at:399:559;
>
> Interrogation_Position=1367; Antisense;'
> TCTCCTTTGCTGAGGCCTCCAGCTT
>
>
>>probe:HG-U95Av2:1000_at:544:185;
>
> Interrogation_Position=1379; Antisense;
> AGGCCTCCAGCTTCAGGCAGGCCAA
>
>
> can any one please suggest what is going wrong in my
> statements and how can I get it.
>
> Thank you.
> Kumar
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 250MB free storage. Do more. Manage less.
> http://info.mail.yahoo.com/mail_250
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list