So, I’m stuck with separating the multiple loops. The first cycle works fine. And the second one too. But not the two last ones. When I’m trying to type the DNA or Protein, it only gives an answer: Restart? Y \ N
My code:
while True:
A = (input())
if A == ("Start"):
print ("What type of the data you want to process?")
print ("DNA", "RNA", "Protein", sep="\n")
break
else:
print ("Incorrect input")
continue
break
while True:
X = (input())
if X == ("RNA"):
print ("What you want to do with RNA?", "RNA to DNA? RNA to Protein? seqRNA length?", sep="\n?")
continue
break
else:
print("Restart?", "Y \ N", sep="\n")
continue
break
while True:
Y = (input())
if Y == ("DNA"):
print ("What you want to do with DNA?", "DNA to RNA? seqDNA length?", sep="\n")
continue
break
else:
print("Anything else?", "Yes No", sep="\n")
continue
break
while True:
Z = (input())
if Z == ("Protein"):
print ("What you want to do with Protein?", "Protein to RNA? protein Name?", sep="\n")
continue
break
else:
print("Anything else?", "Yes No", sep="\n")
continue
break
I’m already tried to delete one of these cycles and tried to run it, but the results were the same. I had searched for the examples of using break, while and if, but found answers only for just the only one loop, not multiple. I find it quite dissapointing, because I’ve wanted to do this for a better understanding of the python. And not just using a BioPython library. But ironically, just the process of the transcription, reverse transcription, translation, translation to RNA, or sequence length calculation is not a big problem. It’s all needs just a one line of the code.
while True:
print("What type of the data you want to process?", "RNA? DNA?", sep = "\n")
A = input("")
if A == "RNA":
print("What you want to do with RNA?", "(a1)RNA to Protein? (a2)RNA to DNA? (a3)RNA Length? (a4)RNA Splicing? (a5)RNA nucleotides (a6)ratio? RNAi? ", sep = "\n")
break
if A == "DNA":
print("What you want to do with DNA", "(b1)DNA to RNA? (b2)DNA length? (b3)DNA nucleotides ratio? (b4)Complimentary DNA chain?", sep = "\n")
break
else:
print("Nope") #TF2 references
continue
while A == "RNA":
X = input("")
if X == "a1":
print("Input RNA")
import ptranslation #Written by myself module for RNA translation
RNA_translation = input("")
print (RNA_translation)
break
if X == "a2":
print("Input RNA")
RNA_seq = input("")
DNA_seq = RNA_seq.replace("U", "T")
print (DNA_seq)
break
if X == "a3":
print ("Input RNA")
RNA = input("")
RNAo = int (len(RNA)//2)
print(RNAo)
break
if X == "a4":
print ("Input RNA")
import re
RNA = input("")
regex = r"GU(?:\w{0,}?)AG" #regex black magic Uga-Buga, still need to undestand it better
exons = re.sub(regex, '', RNA)
print(exons)
break
if X == ("a5"):
print("Input RNA")
RNAn = input ("")
X = (RNAn.count("A")) + (RNAn.count("U")) + (RNAn.count("C")) + (RNAn.count ("G"))
A = (RNAn.count("A")/X)
U = (RNAn.count("U")/X)
G = (RNAn.count("G")/X)
C = (RNAn.count("C")/X)
print ("A =", A, "U =", U, "G =", G, "C =", C)
break
if X == ("a6"):
print("Input RNA")
N = input("")
print(N.translate(str.maketrans({"A": "U", "G": "C", "U": "A", "C": "G"})))
break
else:
print("NOPE! Input correct option!")
continue
break
while A == "DNA":
Y = input("")
if Y == "b1":
print ("Input DNA ")
DNA_seq = input("")
RNA_seq = DNA_seq.replace("T", "U")
print (RNA_seq)
break
if Y == ("b2"):
print("Input DNA")
DNA = input("")
DNAo = int (len(DNA)//2)
print(DNAo)
break
if Y == ("b3"):
print("Input DNA")
DNAn = input ("")
X = (DNAn.count("A")) + (DNAn.count("T")) + (DNAn.count("C")) + (DNAn.count ("G"))
A = (DNAn.count("A")/X)
T = (DNAn.count("T")/X)
G = (DNAn.count("G")/X)
C = (DNAn.count("C")/X)
print ("A =", A, "T =", T, "G =", G, "C =", C)
break
if Y == ("b4"):
print("Input DNA")
Nd = input("")
print(Nd.translate(str.maketrans({"A": "T", "G": "C", "T": "A", "C": "G"})))
break
else:
print("NOPE! Input correct option!")
continue
break
#psyhological support in process of the coding - M.Kashtanov