-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdna.py
More file actions
42 lines (33 loc) · 749 Bytes
/
Copy pathdna.py
File metadata and controls
42 lines (33 loc) · 749 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
35
36
37
38
39
40
41
42
import os
import sys
def load_data(infile):
with open(infile, 'r', encoding='ISO-8859-1') as f:
dna = f.readline().rstrip()
return dna
def write_data(outfile):
# not used
if os.path.exists(outfile):
os.remove(outfile)
f = open(outfile, 'a+')
#f.write('')
f.close()
def count_nucleotides(dna):
A = 0
C = 0
G = 0
T = 0
for i in dna:
if i == 'A':
A += 1
elif i == 'C':
C += 1
elif i == 'G':
G += 1
else:
T += 1
print(str(A) + ' ' + str(C) + ' ' + str(G) + ' ' + str(T))
def main(argv):
dna = load_data(argv[0])
count_nucleotides(dna)
if __name__ == "__main__":
main(sys.argv[1:])