Commit aab01bf5 authored by Yan's avatar Yan
Browse files

Support for timsTOF - pt3

* odd/even support seems fixed
* got rid of augCanvas.filename (broke things on the way probably)
* lost of things still broken
parent b5d06662
......@@ -65,11 +65,10 @@ def show_exception_and_exit(exc_type, exc_value, tb):
def load_file(parent, augCanvas, update, settings, loadthread, filename=None,
nothreading=True):
nothreading=False):
"""populates dataset and plots it"""
directory = augCanvas.ds.filename\
if not (isinstance(augCanvas.ds, list))\
else settings.value("open_folder")
directory = augCanvas.ds.filename if augCanvas.ds\
else settings.value("open_folder")
filename = filename or QtWidgets.QFileDialog.getOpenFileName(
caption="Open spectrum", directory=directory,
filter="All supported formats (*.raw *.RAW *.d);;"
......@@ -139,28 +138,10 @@ def print_graph(augCanvas):
def update_spectrum(augCanvas, config):
if augCanvas.filename:
if augCanvas.ds:
slims = [augCanvas.spectplot.get_xlim(),
augCanvas.spectplot.get_ylim()]
augCanvas.ds.clear()
[augCanvas.ds.append(dict(chrom_dat=i[0], masses=i[1], matrix=i[2]))
for i in load_raw(augCanvas.filename, config.value("tmp_location"))]
if autoparams:
try:
(augCanvas.ms['params'], rawheaders,
augCanvas.chrom['machtype']) = load_params(
augCanvas.filename, config.value("tmp_location"))
segments = [len(subset['chrom_dat'][0])
for subset in augCanvas.ds]
indicies = [sum(segments[:i+1])
for i in range(len(segments))]
augCanvas.ms['headers'] = np.split(
rawheaders, indicies)[:-1]
except Exception as pex:
QtWidgets.QMessageBox.critical(None,
"File is incompatible with the rawautoparams",
"no parameters loaded!\n\n"
"Error message:\n{}".format(pex))
augCanvas.ds.refresh()
gt.populate(augCanvas)
augCanvas.spectplot.set_xlim(slims[0])
augCanvas.spectplot.set_ylim(slims[1])
......@@ -211,6 +192,7 @@ def predictmz(form, augCanvas):
def oddeven_changed(augCanvas, config, oddevenact):
print("trigd")
config.setValue("view/oddeven", oddevenact.isChecked())
update_spectrum(augCanvas, config)
......@@ -242,15 +224,15 @@ def paint_override(self, augCanvas):
for i, line in enumerate(data)]
xtics = int(cf.settings().value(self.conftype.format("xtics")))
self.plot.locator_params(nbins=xtics, axis='x')
if augCanvas.filename not in (None, [None]):
if augCanvas.ds:
self.plot.set_title(Path(
*Path(augCanvas.filename).resolve().parts[-2:]), loc="right")
*Path(augCanvas.ds.filename).resolve().parts[-2:]), loc="right")
def key_pressed(event, augCanvas, config, update):
if event.key() == QtCore.Qt.Key_F5:
update_spectrum(augCanvas, config)
if augCanvas.filename:
if augCanvas.ds:
update.signal.emit()
if event.key() == QtCore.Qt.Key_C:
if event.modifiers().__int__() == QtCore.Qt.ControlModifier:
......@@ -317,7 +299,7 @@ def main():
main_window = QtWidgets.QMainWindow(windowTitle="Prasopes")
update.signal.connect(lambda: main_window.setWindowTitle(
"Prasopes - {}".format(os.path.basename(augCanvas.filename))))
"Prasopes - {}".format(os.path.basename(augCanvas.ds.filename))))
if QtGui.QIcon.themeName() == "":
QtGui.QIcon.setThemeName("TangoMFK")
......
......@@ -36,7 +36,7 @@ def specttostr(augCanvas, delim=" ", names=["mass","ion_count"], units=["m/z",""
def clip_spectstr(augCanvas):
description = ("{}_{:.4}-{:.4}_minutes_of_the_aquisition".format(
os.path.basename(augCanvas.filename),
os.path.basename(augCanvas.ds.filename),
augCanvas.chrom['t_start'], augCanvas.chrom['t_end']))
string = specttostr(augCanvas.spectplot, delim="\t", description=description)
QtWidgets.QApplication.clipboard().clear()
......
......@@ -120,9 +120,9 @@ def treeDockWidget(actionname, cfval, update, loadfnc, parent,
fileModel.directoryLoaded.connect(
lambda: treeview.resizeColumnToContents(0))
update.signal.connect(lambda: treeview.setCurrentIndex(fileModel.index(
augCanvas.filename)))
augCanvas.ds.filename)))
update.signal.connect(lambda: dirview.setRootIndex(fileModel.index(
path.dirname(path.realpath(augCanvas.filename)))))
path.dirname(path.realpath(augCanvas.ds.filename)))))
fileModel.layoutChanged.connect(scrolltoonce)
for i in [treeview.doubleClicked, dirview.doubleClicked, dirview.clicked]:
......
......@@ -543,7 +543,7 @@ def select_all_btn_up(ds, drls, drlspectrum, state=None):
def main_window(parent, augCanvas, update_signal):
"""constructs a dialog window"""
ds = augCanvas.ds
filename = augCanvas.filename
filename = augCanvas.ds.filename
cache = augCanvas.drlcache
def onclose(widget, event, buffer, drls,
......
......@@ -29,7 +29,7 @@ def get_save_filename(caption, fnfilter, suffix, parent):
def export_dial(augCanvas, main_window):
"""exports the chromatogram into the .dat file format"""
if not augCanvas.filename:
if not augCanvas.ds:
QtWidgets.QMessageBox.warning(
main_window, "Export spectrum",
"Nothing to export, cancelling request")
......@@ -38,7 +38,7 @@ def export_dial(augCanvas, main_window):
"Export spectrum", "dat table (*.dat)", "dat", main_window)
if exp_f_name != '':
description = ("{}_{:.4}-{:.4}_minutes_of_the_aquisition".format(
os.path.basename(augCanvas.filename),
os.path.basename(augCanvas.ds.filename),
augCanvas.chrom['t_start'], augCanvas.chrom['t_end']))
expf = open(exp_f_name, 'w')
expf.write(dt.specttostr(augCanvas.spectplot, description=description))
......
......@@ -26,8 +26,7 @@ class AugFigureCanvas(FigureCanvas):
self.figure = Figure(figsize=(5, 4), dpi=100, facecolor="None",
constrained_layout=True)
super().__init__(self.figure)
self.filename = ""
self.ds = []
self.ds = None
self.ms = dict(annotation=[], name="Spectrum", xlabel="m/z",
ylabel="ion count", xtics=20, predict=None,
params=[], headers=[], texts=[])
......
......@@ -86,7 +86,7 @@ def key_pressed(event, augCanvas, drls, grph, labels, parselect):
def export_dial(augCanvas, drls, grph, labels, parselect):
"""exports the reactivity into the .dat file format"""
if not augCanvas.filename:
if not augCanvas.ds:
QtWidgets.QMessageBox.warning(
None, "Export spectrum",
"Nothing to export, cancelling request")
......@@ -96,7 +96,7 @@ def export_dial(augCanvas, drls, grph, labels, parselect):
if exp_f_name != '':
names = ["pressure", "rel._intensity"]
units = ["mTorr", ""]
description = os.path.basename(augCanvas.filename) + " " +\
description = os.path.basename(augCanvas.ds.filename) + " " +\
" -- ".join([line._label for line in grph.get_lines()])
expf = open(exp_f_name, 'w')
expf.write(dt.specttostr(grph, " ", names, units, description))
......@@ -105,7 +105,7 @@ def export_dial(augCanvas, drls, grph, labels, parselect):
def update_parselect(augCanvas, parselect):
# Do not do anything when data set is not populated
if len(augCanvas.ds) == 0:
if not augCanvas.ds:
return
index = parselect.currentIndex()
if index == -1:
......@@ -126,7 +126,7 @@ def tab_changed(fnc, index):
def pop_dial(augCanvas, drls, graph, labels, parselect):
logger.debug("populating reactivity dialog")
# Do not do anything when data set is not populated
if len(augCanvas.ds) == 0:
if not augCanvas.ds:
return
def getconfval(name, type, parselect=parselect):
......
......@@ -19,9 +19,9 @@ logger = logging.getLogger('zceLogger')
def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
textfield, fn, parent):
textfield, parent):
logger.debug("populating ZCE dialog")
if fn is None:
if data_set is None:
QtWidgets.QMessageBox.warning(
parent, "ZCE calculation",
"No spectrum opened, nothing to display")
......@@ -148,7 +148,7 @@ def dialog(parent, augCanvas, update_signal):
def update_fnc():
pop_dial(coffspect, coffspect_grad, augCanvas.ds, coff, coffgrad,
textfield, augCanvas.filename, parent)
textfield, parent)
dial_widget = QtWidgets.QDialog(
parent, windowTitle='TSQ zero collision energy calculator')
......@@ -168,17 +168,17 @@ def dialog(parent, augCanvas, update_signal):
zce_export = QtWidgets.QPushButton("Export ZCE")
zce_export.clicked.connect(lambda: exp_zce(
coff, coffgrad, augCanvas.filename, parent))
coff, coffgrad, augCanvas.ds.filename, parent))
zce_print = QtWidgets.QPushButton("Print ZCE")
zce_print.clicked.connect(lambda: print_graph(
augCanvas.ds, coff, coffgrad, augCanvas.filename))
augCanvas.ds, coff, coffgrad))
zce_help = QtWidgets.QPushButton("Help")
zce_help.clicked.connect(lambda: help_msg(parent))
close_button = QtWidgets.QPushButton("Close")
close_button.clicked.connect(dial_widget.close)
dial_widget.keyPressEvent = lambda event: key_pressed(
event, augCanvas.ds, coff, coffgrad, augCanvas.filename)
event, augCanvas.ds, coff, coffgrad)
butt_layout = QtWidgets.QHBoxLayout()
butt_layout.addWidget(zce_help)
......@@ -196,4 +196,4 @@ def dialog(parent, augCanvas, update_signal):
dial_widget.setFocus()
dial_widget.show()
pop_dial(coffspect, coffspect_grad, augCanvas.ds, coff, coffgrad,
textfield, augCanvas.filename, parent)
textfield, parent)
Markdown is supported
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