I have a problem in my code where I have the following:
import random
Probabilities={'AA':0.2,"TT":0.2, "GG":0.1, "CC":0.1, "AT":0.4}
lst=[]
klist=[]
for i in Probabilities:
lst.append(Probabilities[i])
lst.sort()
for i in lst:
for j in Probabilities:
if Probabilities[j]==i:
klist.append(j)
jist=list(set(klist))
#klist.append(i)
cist=[]
cist.append(lst[0])
for i in range(1,len(lst)):
k=lst[i]+cist[i-1]
cist.append(k)
p=random.uniform(0, 1)
print (p)
print(lst)
print(cist)
print(klist)
print (jist)
When I run this I get something like
0.9939409413693211
[0.1, 0.1, 0.2, 0.2, 0.4]
[0.1, 0.2, 0.4, 0.6000000000000001, 1.0]
['CC', 'GG', 'CC', 'GG', 'TT', 'AA', 'TT', 'AA', 'AT']
['TT', 'AT', 'CC', 'AA', 'GG']
The part I need to fix is to change the last list printed to not only remove the duplicates, but keep the order of the previous list
So basically instead of
['TT', 'AT', 'CC', 'AA', 'GG']
I want
['CC', 'GG','TT', 'AA','AT']
when I do
jist=list(set(klist))
Thanks, A
PS. I am new to Stack Overflow, sorry for anything I may have not made clear/ improper etiqutte, etc.