-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayUpload.py
More file actions
159 lines (120 loc) · 5.95 KB
/
arrayUpload.py
File metadata and controls
159 lines (120 loc) · 5.95 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#! python
import sys
import xlrd
import os
from natsort import natsorted
from PyQt5.QtWidgets import QTableWidget, QApplication, QMainWindow, QTableWidgetItem, QFileDialog, QComboBox,QDialog
from PyQt5.QtCore import QDateTime
from PyQt5.QtCore import QSettings
from dataComboBox import DataCombo
#from excelComboBox import ExcelCombo
from preferences import Preferences
from gui.mainWindow_ui import Ui_MainWindow
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
self.tableWidget_dropzone.setColumnCount(6)
self.tableWidget_dropzone.setRowCount(9)
self.tableWidget_dropzone.setAcceptDrops(True)
self.tableWidget_dropzone.setColumnWidth(0, 128)
self.tableWidget_dropzone.setColumnWidth(1, 64)
self.tableWidget_dropzone.setColumnWidth(2, 128)
self.tableWidget_dropzone.setColumnWidth(3, 64)
self.tableWidget_dropzone.setColumnWidth(4, 128)
self.tableWidget_dropzone.setColumnWidth(5, 64)
self.tableWidget_dropzone.setHorizontalHeaderLabels(['A1 Sample IDs', 'Gender', 'A2 Sample IDs', 'Gender',
'A3 Sample IDs', 'Gender'])
self.tableWidget_dropzone.setVerticalHeaderLabels(['', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8'])
self.tableWidget_dropzone.setSpan(0, 0, 1, 2)
self.tableWidget_dropzone.setSpan(0, 2, 1, 2)
self.tableWidget_dropzone.setSpan(0, 4, 1, 2)
# populate stuff
# arrayUpload_settings = QSettings('vll', 'arrayUpload')
# path_array_data_folder = arrayUpload_settings.value('path_array_data_folder', type=str)
# dataComboBox1 = DataCombo(path_array_data_folder)
# dataComboBox2 = DataCombo(path_array_data_folder)
# dataComboBox3 = DataCombo(path_array_data_folder)
#
# self.tableWidget_dropzone.setCellWidget(0, 0, dataComboBox1)
# self.tableWidget_dropzone.setCellWidget(0, 2, dataComboBox2)
# self.tableWidget_dropzone.setCellWidget(0, 4, dataComboBox3)
self.populateExcelComboBox()
self.populateDataComboBoxes()
self.populateInvestigators()
# other settings
self.dateEdit.setDateTime(QDateTime.currentDateTime())
# actions
self.actionPreferences.triggered.connect(self.show_preferences)
self.load_samples_comboBox.activated.connect(self.loadExcel)
def repopulate(self):
self.populateExcelComboBox()
self.populateDataComboBoxes()
self.populateInvestigators()
def populateInvestigators(self):
arrayUpload_settings = QSettings('vll', 'arrayUpload')
investigators_list = arrayUpload_settings.value('investigators', type=list)
investigators_list.insert(0, " -- none selected -- ")
self.comboBox_investigator.clear()
for i in investigators_list:
self.comboBox_investigator.addItem(i)
def populateDataComboBoxes(self):
arrayUpload_settings = QSettings('vll', 'arrayUpload')
path_array_data_folder = arrayUpload_settings.value('path_array_data_folder', type=str)
dataComboBox1 = DataCombo(path_array_data_folder)
dataComboBox2 = DataCombo(path_array_data_folder)
dataComboBox3 = DataCombo(path_array_data_folder)
self.tableWidget_dropzone.setCellWidget(0, 0, dataComboBox1)
self.tableWidget_dropzone.setCellWidget(0, 2, dataComboBox2)
self.tableWidget_dropzone.setCellWidget(0, 4, dataComboBox3)
def populateExcelComboBox(self):
self.load_samples_comboBox.clear()
arrayUpload_settings = QSettings('vll', 'arrayUpload')
path_sample_excel_files_folder = arrayUpload_settings.value('path_sample_excel_files_folder', type=str)
files = os.listdir(path=path_sample_excel_files_folder)
files_xls = []
for f in files:
if f.endswith(".xls"):
files_xls.append(f)
sfiles_xls = natsorted(files_xls)
sfiles_xls.insert(0, " -- none selected -- ")
for f in sfiles_xls:
if f[0] != '$':
self.load_samples_comboBox.addItem(f)
def loadExcel(self):
arrayUpload_settings = QSettings('vll', 'arrayUpload')
path_sample_excel_files_folder = arrayUpload_settings.value('path_sample_excel_files_folder', type=str)
self.tableWidget_XLS.clear()
cexcel = self.load_samples_comboBox.currentText()
cexcel_path = path_sample_excel_files_folder + "/" + cexcel
if cexcel != " -- none selected -- ":
book = xlrd.open_workbook(cexcel_path, 'r')
sheet = book.sheet_by_index(0)
self.tableWidget_XLS.setColumnCount(sheet.ncols + 10)
self.tableWidget_XLS.setRowCount(sheet.nrows + 10)
self.check_change = False
for row_index in range(0, sheet.nrows):
for col_index in range(0, sheet.ncols):
content = sheet.cell(row_index, col_index).value
item = QTableWidgetItem(content)
self.tableWidget_XLS.setItem(row_index, col_index, item)
self.tableWidget_XLS.setDragEnabled(True)
self.check_change = True
def load_samples(self):
files = os.listdir("C:/Users/parla/Documents/")
sfiles = natsorted(files)
sfiles.insert(0, " -- none selected -- ")
for f in sfiles:
# print(f)
if f.endswith('.xls') or f.endswith(' -- none selected -- '):
self.load_samples_comboBox.addItem(f)
def show_preferences(self):
self.p = Preferences(self)
self.p.show()
def main():
app = QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()