Commit 37381649 authored by Yan's avatar Yan
Browse files

DRL table loading works

* better input sanitization will be needed someday in future
parent f22afd99
......@@ -83,7 +83,7 @@ def main():
tools_menu.addAction('&TSQ zce', lambda: zce.dialog(
main_window, ds, filename), QtCore.Qt.CTRL + QtCore.Qt.Key_T)
tools_menu.addAction('&DRL..', lambda: drl.dialog(
main_window, ds, filename, mass_selector, spectrum, drlcache),
main_window, ds, filename, drlcache),
QtCore.Qt.CTRL + QtCore.Qt.Key_D)
main_widget = QtWidgets.QWidget(main_window)
......@@ -151,7 +151,7 @@ def remove_rows(ptable, dtable):
def setDoubleCell(table,row,column):
def setDoubleCell(table, row, column):
"""populate table cell with float-validated posititve text"""
validator = QtGui.QDoubleValidator()
......@@ -164,7 +164,7 @@ def setDoubleCell(table,row,column):
return table.cellWidget(row,column)
def add_line(parent_widget, mass_selector, spectrum, ds, parenttable,
def add_line(parent_widget, ds, parenttable,
daughtertable, drlspectrum):
"""add parent ion to the table"""
ion_graph = Figure(figsize=(3, 1.5), dpi=100, facecolor="None")
......@@ -239,12 +239,48 @@ def iontable(labels, exp_col):
return table
def load_drlconfig(ptable, dtable):
#will be substituted with something that can vwork in future
if 0 == 1:
def load_drltables(parent, ptable, dtable, dataset, drlspectrum):
filename = QtWidgets.QFileDialog.getOpenFileName(
caption="Load DRL config tables",
filter="comma-separated values (*.csv)")[0]
if filename is not '':
names = []
start_masses = []
end_masses = []
states = []
corrected_to = []
corr_factors = []
with open(filename, 'r') as cfile:
rawdata =
for i in range(1,len(rawdata)):
if len(rawline) != 6 or int(rawline[3]) not in range(3) \
or int(rawline[4]) not in range(len(rawdata)):
parent, "Load DRL config tables",
"Config file corrupted on line {},"
" cancelling request".format(i+1))
for j, k in enumerate((names, start_masses, end_masses,
states, corrected_to, corr_factors)):
for row in reversed(range(ptable.rowCount())):
#first populate only parent table
for i in range(len(names)):
add_line(parent, dataset, ptable, dtable, drlspectrum)
ptable.cellWidget(i, 0).setText(names[i])
ptable.cellWidget(i, 1).setText(start_masses[i])
ptable.cellWidget(i, 2).setText(end_masses[i])
#and after that daughter table
for i in range(len(names)):
dtable.cellWidget(i, 2).setCurrentIndex(
dtable.cellWidget(i, 3).setText(corr_factors[i])
dtable.cellWidget(i, 1).setCheckState(int(states[i]))
def save_drlconfig(ptable, dtable, parent):
......@@ -267,6 +303,7 @@ def save_drlconfig(ptable, dtable, parent):
expf.write("{}\n".format((",".join(map(str, vals)))))
def export_drlspectrum(parent, fn, ptable, dtable, ds):
if fn[0] is None:
......@@ -288,8 +325,7 @@ def export_drlspectrum(parent, fn, ptable, dtable, ds):
def dialog(parent, ds, filename, mass_selector, spectrum, cache):
def dialog(parent, ds, filename, cache):
"""constructs a dialog window"""
def savecache(cache,pt,dt,canvas):
......@@ -330,17 +366,17 @@ def dialog(parent, ds, filename, mass_selector, spectrum, cache):
pt = iontable(["Name", "start (m/z)", "end (m/z)", "profile"], 2)
for i in range(5):
add_line(dial_widget, mass_selector, spectrum, ds, pt, dt,
add_line(dial_widget, ds, pt, dt, chromplot)
pt = cache[0]
dt = cache[1]
graph_canvas = cache[2]
btn_add.clicked.connect(lambda: add_line(
dial_widget, mass_selector, spectrum, ds, pt, dt, chromplot))
dial_widget, ds, pt, dt, chromplot))
btn_rem.clicked.connect(lambda: remove_rows(pt,dt))
drl_load.clicked.connect(lambda: load_drlconfig(pt, dt))
drl_load.clicked.connect(lambda: load_drltables(
dial_widget, pt, dt, ds, chromplot))
drl_save.clicked.connect(lambda: save_drlconfig(
pt, dt, dial_widget))
drl_export.clicked.connect(lambda: export_drlspectrum(
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment