[Tutor] Faster procedure to filter two lists . Please help
kumar s
ps_python at yahoo.com
Sat Jan 15 00:28:07 CET 2005
Hi group:
I have two lists a. 'my_report' and b. 'what'.
In list 'what', I want to take 6649 (element1:
164:623\t6649) and write to a new list ( although I
printed the result, my
intension is to list.append(result).
I took column 1 value of element 1 in what, which is
164:623 and checked in column 1 value in list
my_report, if it matches
I asked it to write the all columns of my_report along
with column 2 value in what list.
(with my explanation, I feel I made it complex).
Here is what I did:
>>> what[0:4]
['164:623\t6649', '484:11\t6687', '490:339\t6759',
'247:57\t6880', '113:623\t6901']
>>>my_report[0:4]
['164:623\tTCATGGCTGACAACCCATCTTGGGA\t200000_s_at',
'484:11\tATTATCATCACATGCAGCTTCACGC\t200000_s_at',
'490:339\tGAATGGGGCCGCCAGAACACAGACA\t200000_s_at',
'247:57\tAGTCCTCGTGGAACTACAACTTCAT\t200000_s_at',
'113:623\tTCATGGGTGTTCGGCATGACCCCAA\t200000_s_at']
>>>for i in range(len(what)):
ele = split(what[i],'\t')
cor1 = ele[0]
for k in range(len(my_report)):
cols = split(my_report[k],'\t')
cor = cols[0]
if cor1 == cor:
print cor+'\t'+ele[1]+'\t'+cols[1]+'\t'+cols[2]
164:623 6649 TCATGGCTGACAACCCATCTTGGGA
484:11 6687 ATTATCATCACATGCAGCTTCACGC
490:339 6759 GAATGGGGCCGCCAGAACACAGACA
247:57 6880 AGTCCTCGTGGAACTACAACTTCAT
113:623 6901 TCATGGGTGTTCGGCATGACCCCAA
PROBLEM:
This process is very very slow. I have 249502 elements
in each list. The process has been running for over 30
min. Could
any one suggest a better fast procedure, to save time.
Thank you in advance.
K
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
More information about the Tutor
mailing list