-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_BRACNAC.py
100 lines (96 loc) · 4.96 KB
/
main_BRACNAC.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PyQt5 import QtWidgets,QtGui,QtCore
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import QThread
##,QObject,pyqtSlot,pyqtSignal
import mainwindow
import bracnac
class BRACNACmain(QtWidgets.QMainWindow, mainwindow.Ui_BRACNAC):
def __init__(self):
super().__init__()
self.setupUi(self)
self.show()
self.input_file_button.clicked.connect(self.input_file_button_onClick)
self.amplicon_file_button.clicked.connect(self.amplicon_file_button_onClick)
self.patients_table_button.clicked.connect(self.patients_table_button_onClick)
self.output_file_button.clicked.connect(self.output_file_button_onClick)
self.start_button.clicked.connect(self.start_button_onClick)
self.progressBar.setEnabled(False)
## p=QPixmap(self.size())
## self.render(p)
## p.save('/home/andrey/image.png',quality=3000)
def input_file_button_onClick(self):
dialog=QtWidgets.QFileDialog()
self.input_file_path=dialog.getOpenFileName(self,'Select directory with amplicon coverages files')
self.input_file_text.setText(self.input_file_path[0])
def amplicon_file_button_onClick(self):
dialog=QtWidgets.QFileDialog()
self.amplicon_file_path=dialog.getOpenFileName(self,'Select file with amplicon coordinates')
self.amplicon_file_text.setText(self.amplicon_file_path[0])
def patients_table_button_onClick(self):
dialog=QtWidgets.QFileDialog()
self.patients_table_path=dialog.getOpenFileName(self,'Select file with patient table')
self.patients_table_text.setText(self.patients_table_path[0])
def output_file_button_onClick(self):
dialog=QtWidgets.QFileDialog()
self.output_file_path=dialog.getOpenFileName(self,'Select output file')
self.output_file_text.setText(self.output_file_path[0])
def start_button_onClick(self):
self.thread=QThread()
self.input_file_button.setEnabled(False)
self.amplicon_file_button.setEnabled(False)
self.patients_table_button.setEnabled(False)
self.output_file_button.setEnabled(False)
self.start_button.setEnabled(False)
self.reference_version_box.setEnabled(False)
self.clust_box.setEnabled(False)
self.progressBar.setEnabled(True)
self.bracnacObject=bracnac.BRACNAC(self.input_file_text.text(),
self.amplicon_file_text.text(),
self.patients_table_text.text(),
self.output_file_text.text(),
self.reference_version_box.currentText(),
self.clust_box.isChecked(),
float(self.Hscores_threshold_text.text()),
float(self.Hpvalue_text.text()),
float(self.minimal_score_text.text()),
float(self.maximal_p_value_text.text()),
int(self.minimal_median_coverage_text.text()),
int(self.permutations_number_text.text()),
int(self.exonCoveredWhole_text.text()),
float(self.exonCoveredPart_text.text()),
int(self.exonNonCovered_text.text()),
float(self.delTh1_text.text()),
float(self.delTh2_text.text()),
float(self.duplTh1_text.text()),
float(self.duplTh2_text.text()))
self.bracnacObject.moveToThread(self.thread)
self.thread.started.connect(self.bracnacObject.run)
self.bracnacObject.finished.connect(self.thread.quit)
self.bracnacObject.done_percent.connect(self.progressBar.setValue)
self.bracnacObject.finished.connect(self.bracnacObject.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
self.thread.finished.connect(self.returnStartState)
print('Starting thread...')
self.thread.start()
def returnStartState(self):
try:
self.thread.wait()
except RuntimeError:
pass
print('\nReturning start state of buttons and labels...')
self.input_file_button.setEnabled(True)
self.amplicon_file_button.setEnabled(True)
self.patients_table_button.setEnabled(True)
self.output_file_button.setEnabled(True)
self.start_button.setEnabled(True)
self.reference_version_box.setEnabled(True)
self.clust_box.setEnabled(True)
def main():
app = QtWidgets.QApplication(sys.argv)
window = BRACNACmain()
app.exec_()
if __name__ == '__main__':
main()