-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrosalind_counting_DNA_nucleotides.py
29 lines (21 loc) · 1.52 KB
/
rosalind_counting_DNA_nucleotides.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 countBases(text):
# Create an empty hash table
symbolCounts = {'A':0,'C':0, 'G':0, 'T':0}
# Go over each letter in the sequence
for x in xrange(len(text)):
ch = text[x]
# Increment count
if (ch in symbolCounts):
symbolCounts[ch] = symbolCounts[ch] + 1
else:
symbolCounts[ch] = 1
A_count= symbolCounts['A']
C_count= symbolCounts['C']
G_count= symbolCounts['G']
T_count= symbolCounts['T']
space= ' '
result = str(A_count) + space + str(C_count) + space + str(G_count) + space + str(T_count)
# Return counts
return (result)
string = 'CCGTTGCAGTTTGAACGGATTCCCGCGCACCGCGTCGATGGTAGCCTGTAGAAGCCTCGTAGTCCCAGATTGTTAAAGTAAGCTTGCTTATTACCGATTAGTACGTTCCGGGTGCTGGCCCATAAGGTGGGATACACGGACTTATGGCTGCGACATGTGACATTAGCCACACAGCCAGTGCTAAGGCTCTACTATAGTTAACAGAGACAAAACGAGACGTTGGGGGAGCACCCGAACACACCATCGAGCCCGAGCTGGGAAAACAGAGCACCTCTACAAGTGTAGTTACCAGTGACTAAAACTGACTTGCATCCCACAATTTATTACATCACGAGCCGCAGGCCGGTTTAGGACGTTCTACGTGTGTTTGTTTACCGGTATTTACCAACCGGGTGATGTTTCTTCCCGGCCTGGCAGTTCTGTTGCCGAAACTTACTTACAGTTTCTGCATTTCTAGAGGACCGATAGCTACTTGTCTCGCTCTTAGACTTGATTGAGTCAGAGCGATCGGTCTCCGCTCTCGCCATTCTGCTTCTAGGCCACAGCACCGCTCAGTACGCGGGGCCGACTTACTAAGCATCGTTGCACTCGCTGGATGCCTTTCAAGAAATCTAGGAAGTATAGCTTAGCCCTAGCGCGGAGGCGCGGTATAAGTGGGACCTTAGGCATATTTATTGGAAATAGTCATGCCGAACGGGCCAATTCGGCGAGATGATACACCTAAGAATGGACGAAAAAATGTGACACTACAGGATTATTGGCCATTACATGATATAGGCTCGGACGTTGTTGTTATCTTTTCGTAAACAAATTACCTATTGTGTCAGAGGCATGTCATGTAGACCTACTGCAACTCGCTGAAATTATGTCATTCCATCCTCT'
print countBases(string)