forked from jwschroeder3/504GitExercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.py
29 lines (25 loc) · 744 Bytes
/
code.py
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
def count_occurances(a):
'''
Counts the number of times each letter occurs in the input string. Returns
a dictionary with names of each nucleotide with the number of off occurances
for each nucleotide.
Parameters:
a (str): a string of nucleotides
Returns:
b (dict): dictionary of counts. keys are nucleotides.
'''
b = dict()
for c in a:
if c not in b:
b[c] = 1
else:
b[c] += 1
return b
def count_to_prop(a):
print('freqs')
total = float(sum([a[b] for b in a.keys()]))
for b in a.keys():
print(b + ':' + str(a[b]/total))
counts = count_occurances('ATCTGACGCGCGCCGC')
prop = count_to_prop(counts)
prop