-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine.py
More file actions
69 lines (56 loc) · 2.41 KB
/
engine.py
File metadata and controls
69 lines (56 loc) · 2.41 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from engine_ui import Ui_MainWindow
from PyQt5 import QtWidgets
from BioSeq import *
import sys
class DNAENGINE:
def __init__(self, *args, **kwargs):
"""Creating accessible window we can 'talk' to"""
super().__init__(*args, **kwargs)
self.app = QtWidgets.QApplication(sys.argv) # QApplication constructor accessing arugments
self.MainWindow = QtWidgets.QMainWindow() # Window constructor
def setup(self):
"""Load Ui file that we generated"""
self.ui = Ui_MainWindow()
self.ui.setupUi(self.MainWindow)
self.ui.pushButton.clicked.connect(self.DNA_analysis)
def DNA_analysis(self):
"""
run and display everything from Bio_Seq functions after processing.
\n - need codon frequency option
"""
input_sequence = self.ui.textEdit.toPlainText().replace("\n", "").strip().upper()
if not input_sequence:
self.ui.textBrowser.setText("No sequence entered")
return
seq = BioSeq(input_sequence)
if not seq.validate(): # some error handling in case user puts in something non biotype related like "error_test"
error_message = (f"{"=" * 60} \n"
"Sequence is Invalid\n"
"Check for anything other than these characters -> [ATCG]\n"
f"{"=" * 60} \n")
self.ui.textBrowser.setText(error_message)
else:
info = (
f"{"=" * 60} \n"
f"{seq.get_seq_info()}\n"
f"{"=" * 60} \n"
f"[Nucleotide Frequency]: {seq.nuc_freq()}\n"
f"[RNA Transcribe]: {seq.transcription()}\n"
f"[Reverse Complement]: {seq.reverse_complement()}\n"
f"{"=" * 60} \n"
f"[GC Content]: {seq.gc_content()}\n"
f"[GC Subsection Content (k=20)]: {seq.gc_subsec()}\n"
f"{"=" * 60} \n"
f"[AA Chain]:\n{seq.translate_seq()}\n"
f"[All Open Reading Frames]:\n{seq.gen_reading_frames()}\n"
f"{"=" * 60} \n"
f"[All Possible Proteins]:\n{"\n".join(seq.all_orf_proteins())}\n"
f"{"=" * 60} \n"
)
self.ui.textBrowser.setText(info)
def run(self):
"""Event loop. Listens to inputs and whatever comes from OS"""
sys.exit(self.app.exec_())
def display(self):
"""Renders window on screen"""
self.MainWindow.show()