-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplementary_strand
43 lines (33 loc) · 1.12 KB
/
complementary_strand
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
'''This program intends to produce a
DNA complementary string, taking into
account the translation and 5' 3' inversion.
'''
def compl_dna(sequence):
sequence = sequence.upper()
seq = sequence[::-1] #inverted sequence
seq = list(seq)
i = 0
for nuc in seq:
if seq[i] == 'G':
seq[i] = 'C'
elif seq[i] == 'C':
seq[i] = 'G'
elif seq[i] == 'T':
seq[i] = 'A'
elif seq[i] == 'A':
seq[i] = 'T'
i += 1
print(f'{seq}')
#starting the program
print('Welcome! This program will give you the complementary DNA strand to your data. ')
#asking the user
choice = int(input('Type 1 to enter the .txt file pathway or 2 to paste your sequence: '))
if choice == 1:
dir_pathway = input('Type the file pathway. If it is already on this program file, just type <filename.txt>: ')
file = open(f"{dir_pathway}", 'r')
sequence_nuc = file.read()
elif choice == 2:
sequence_nuc = input('Paste your sequence here: ')
compl_dna(sequence_nuc)
if choice == 1:
file.close()