-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinvertFunction.py
More file actions
39 lines (33 loc) · 1.11 KB
/
invertFunction.py
File metadata and controls
39 lines (33 loc) · 1.11 KB
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
def invert(nucleotide_mapping):
x = input("First Sequence: ").upper()
print("Second Sequence: ", end="")
for char in x:
try:
print(nucleotide_mapping[char], end="")
except KeyError:
print(char, end="")
# def specialInvert(codon_mapping):
# x = input("First Sequence: ").upper()
# print("Second Sequence: ", end="")
# x+=" "
# nucleotides = "AUCG"
# currentcodon=""
# for z in x:
# if len(currentcodon) < 3:
# if z in nucleotides:
# currentcodon += z
# else:
# print(codon_mapping[currentcodon],end=" ")
# currentcodon=""
# x+=" "
def specialInvert(codon_mapping):
x = input("First Sequence: ").upper()
print("Second Sequence: ", end="")
nucleotides = "AUCG"
currentcodon = ""
for z in x:
if z in nucleotides:
currentcodon += z
if len(currentcodon) == 3:
print(codon_mapping.get(currentcodon, "?"), end=" ") # Using get to avoid KeyErrors
currentcodon = "" # Reset for the next codon