def __init__(self, master): dm = DnaManager() rm = RnaManager() pm = ProteinManager() ps = ProteinSystem(dm, rm, pm) tk.Frame.__init__(self, master) tk.Label(self, text="Input DNA sequence without any spaces").pack(side="top", pady=20) entry = tk.Entry(self, width=50) entry.pack() label = ttk.Label(self, text="") label.pack() convert = tk.Button( self, text="Convert", command=lambda: [ label.config(text=ps.get_mrna(entry.get()), wraplengt=500), copied.config(text="") ]) convert.pack() copy = tk.Button(self, text="Copy", command=lambda: [ master.copy_to_clipboard(label.cget("text")), copied.config(text="Copied to Clipboard") ]) copy.pack() tk.Button(self, text="Return to main page", command=lambda: master.frame_switch(MainPage)).pack() copied = tk.Label(self, text="") copied.pack(pady=10)
def __init__(self, master): label_font = tk.font.Font(family="Courier New", size=8) dm = DnaManager() rm = RnaManager() pm = ProteinManager() ps = ProteinSystem(dm, rm, pm) tk.Frame.__init__(self, master) tk.Label(self, text="Input 1st protein sequence without any" " spaces").pack(side="top", pady=10) entry1 = tk.Entry(self, width=50) entry1.pack() tk.Label(self, text="Input 2nd protein sequence without any " "spaces").pack(side="top", pady=10) entry2 = tk.Entry(self, width=50) entry2.pack() label = ttk.Label(self, text="") label.pack(anchor='w') label.config(font=label_font) align = tk.Button(self, text="Align", command=lambda: [ label.config(text=ps.compare_protein( entry1.get(), entry2.get()), wraplengt=500) ]) align.pack() tk.Button(self, text="Return to main page", command=lambda: master.frame_switch(MainPage)).pack()
class ProteinSystem: _dm: DnaManager() _rm: RnaManager() _pm: ProteinManager() def __init__(self, dm, rm, pm): self._dm = dm self._rm = rm self._pm = pm def dna_pairing(self, sequence) -> str: """Acts in the Controller method in Clean Architecture to find complementary DNA pair of a given DNA sequence. :param sequence: DNA sequence input :return Complementary DNA sequence""" return self._dm.find_dna_pair(sequence) def get_mrna(self, sequence) -> str: """Acts in the Controller method in Clean Architecture to find complementary RNA pair of a given DNA sequence. :param sequence: DNA sequence input :return Complementary RNA sequence""" return self._dm.dna_to_rna_(sequence) def get_protein(self, sequence) -> str: """Acts in the Controller method in Clean Architecture to find the protein chain of a given RNA sequence. :param sequence: RNA sequence input :return matching protein chain""" sequence = sequence.upper() if self._dm.dna_to_rna_(sequence) != Presenter.print_invalid(): mrna = self._dm.dna_to_rna_(sequence) return self._rm.rna_to_protein(mrna) return Presenter.print_invalid() def get_dna(self, sequence) -> str: """Acts in the Controller method in Clean Architecture to find complementary DNA pair of a given RNA sequence. :param sequence: RNA sequence input :return Complementary DNA sequence""" return self._rm.rna_to_dna_pair(sequence) def compare_dna(self, seq1, seq2) -> str: if len(seq1) > 70 or len(seq2) > 70: return Presenter.print_sequence_max() if not self._dm.valid_dna_seq(seq1): return Presenter.print_invalid_seq1() if not self._dm.valid_dna_seq(seq2): return Presenter.print_invalid_seq2() return seq1.upper() + '\n' + align_helper(seq1, seq2) + '\n' + seq2.upper() def compare_rna(self, seq1, seq2) -> str: if len(seq1) > 70 or len(seq2) > 70: return Presenter.print_sequence_max() if not self._rm.valid_rna_seq(seq1): return Presenter.print_invalid_seq1() if not self._rm.valid_rna_seq(seq2): return Presenter.print_invalid_seq2() return seq1.upper() + '\n' + align_helper(seq1, seq2) + '\n' + seq2.upper() def compare_protein(self, seq1, seq2) -> str: if len(seq1) > 70 or len(seq2) > 70: return Presenter.print_sequence_max() if not self._pm.valid_protein_sequence(seq1): return Presenter.print_invalid_seq1() if not self._pm.valid_protein_sequence(seq2): return Presenter.print_invalid_seq2() return seq1.upper() + '\n' + align_helper(seq1, seq2) + '\n' + seq2.upper()