-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq6.py
More file actions
34 lines (33 loc) · 744 Bytes
/
q6.py
File metadata and controls
34 lines (33 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
f = open('rosalind_gc.txt','r');
l = f.readlines();
list1 = [];
d = {};
for a in l: # to strip '\n' from the list elements contaning.
a = a.strip();
list1.append(a);
index = ''
for i in list1:
if 'Rosalind' in i:
index = i
d[index] = ''
else:
d[index] += i
#print d;
maxkey = d.keys()[0]
maxvalue = d.values()[0]
maxg = maxvalue.count('G')
maxc = maxvalue.count('C')
length = len(maxvalue)
maxcount = (float((maxc+maxg)/float(length))*100)
finalkey = '';
finalvalue = '';
finalcount = 0;
vc = 0;
for key,value in d.iteritems():
vc = (float((value.count('C')+value.count('G'))/float(len(value)))*100);
if vc > maxcount:
maxkey = key;
maxvalue = value;
maxcount = vc;
print maxkey.strip('>')
print round(maxcount,7)