-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevc.py
43 lines (31 loc) · 781 Bytes
/
revc.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import sys
def load_data(infile):
with open(infile, 'r', encoding='ISO-8859-1') as f:
dna = f.readline().rstrip()
return list(dna)
def write_data(outfile):
# not used
if os.path.exists(outfile):
os.remove(outfile)
f = open(outfile, 'a+')
#f.write('')
f.close()
def complementary_dna_string(dna):
cdna = list()
for i in dna[::-1]:
if i == 'C':
cdna.append('G')
elif i == 'G':
cdna.append('C')
elif i == 'A':
cdna.append('T')
else:
cdna.append('A')
return cdna
def main(argv):
dna = load_data(argv[0])
cdna = complementary_dna_string(dna)
print(''.join(cdna))
if __name__ == "__main__":
main(sys.argv[1:])