-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcytokine_array.py
More file actions
80 lines (63 loc) · 2.22 KB
/
cytokine_array.py
File metadata and controls
80 lines (63 loc) · 2.22 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from pathlib import Path
import sys
import pandas as pd
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QFileDialog
from gui.cytokine_array_gui import Ui_MainWindow
from Excel.excel import to_excel_error_barchart
class CytokineArrayGui(Ui_MainWindow):
def setupUi(self, MainWindow) -> None:
super().setupUi(MainWindow)
self.namesbutton.clicked.connect(self.getnames)
self.databutton.clicked.connect(self.getdata)
self.update(self.namesbutton)
self.update(self.databutton)
self.runbutton.clicked.connect(self.run)
self.dlg = QFileDialog()
self.dlg.setFileMode(QFileDialog.AnyFile)
self.dlg.setNameFilter("CSV files (*.csv)")
self.enter_filename.setText("untitled.xlsx")
def filesfound(self):
if not self.namesfile:
print("No namesfile found")
return False
if not Path(self.namesfile).exists():
print("names file does not exist")
return False
if not Path(self.datafile).exists():
print("Data file does not exist")
return False
if not self.datafile:
print("No datafile found")
return False
return True
def run(self):
if not self.filesfound():
return
df = pd.read_csv(self.datafile)
filename = self.enter_filename.toPlainText()
to_excel_error_barchart(df, filename=filename, xlabel="Cytokine", ylabel="Normalized Intensity")
self.runbutton.setText("Done!")
def getnames(self):
self.namesfile = self.getfile()
self.nameslabel.setText(self.namesfile)
self.update(self.nameslabel)
def getdata(self):
self.datafile = self.getfile()
self.datalabel.setText(self.datafile)
self.update(self.datalabel)
def getfile(self):
self.runbutton.setText("Run")
self.dlg.exec_()
return self.dlg.selectedFiles()[0]
def update(self, label):
label.adjustSize()
def main():
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = CytokineArrayGui()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()