Commit 3aae324a authored by Yan's avatar Yan
Browse files

Added tmp folder settings and F5 update

* tmp folder now can be set in GUI, so rawprasslib functionality of
reading of the spectra during acquisition is implemented
* file is reloaded and the figures are refreshed upon F5
parent fbfb7a17
......@@ -5,24 +5,38 @@ from matplotlib.figure import Figure
from matplotlib.widgets import SpanSelector
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from rawprasslib import load_raw
import prasopes.graphtools as gt
import prasopes.filetools as ft
import prasopes.zcetools as zce
import prasopes.drltools as drl
import prasopes.config as cf
import sys
import matplotlib
import logging
matplotlib.use("Qt5Agg")
def load_file(chrom_plot, spc, d_set, ms_s, fn, chrom_s):
def load_file(chrom_plot, spc, d_set, ms_s, fn, chrom_s, settings):
"""populates dataset and plots it"""
lf = ft.open_dial(d_set)
lf = ft.open_dial(d_set, settings)
if lf is not None:
gt.populate(chrom_plot, spc, d_set, ms_s, chrom_s)
fn[0] = lf
def update_spectrum(event, chromatogram, spect, ds,
ms, fn, chrom, config):
if fn[0] is not None and event.key is "f5":
slims = [spect.get_xlim(), spect.get_ylim()]
ds['chrom_dat'], ds['masses'], ds['matrix'] \
= load_raw(fn[0], config.value("tmp_location"))
gt.populate(chromatogram, spect, ds, ms, chrom)
spect.set_xlim(slims[0])
spect.set_ylim(slims[1])
spect.get_figure().canvas.draw()
def main():
# ds for data_set, ms for mass_spec_dataset, chrom for chrom_dataset
......@@ -36,6 +50,8 @@ def main():
filename = [None]
drlcache = [None, None, None]
config = cf.settings()
p_logger = logging.getLogger('parseLogger')
logging.basicConfig()
p_logger.setLevel("WARN")
......@@ -72,11 +88,13 @@ def main():
file_menu = QtWidgets.QMenu('&File', main_window)
main_window.menuBar().addMenu(file_menu)
file_menu.addAction('&Open..', lambda: load_file(
chromatogram, spectrum, ds, ms, filename, chrom),
chromatogram, spectrum, ds, ms, filename, chrom, config),
QtCore.Qt.CTRL + QtCore.Qt.Key_O)
file_menu.addAction('&Export..', lambda: ft.export_dial(
ms, chrom, filename, main_window),
QtCore.Qt.CTRL + QtCore.Qt.Key_E)
file_menu.addAction('Settings', lambda: cf.dial(
main_window))
file_menu.addAction('&Quit', main_window.close,
QtCore.Qt.CTRL + QtCore.Qt.Key_Q)
tools_menu = QtWidgets.QMenu('&Tools', main_window)
......@@ -94,10 +112,16 @@ def main():
layout.addWidget(mpl_canvas)
mpl_canvas.setFocus()
mpl_canvas.mpl_connect('key_press_event',lambda event:
update_spectrum(event, chromatogram, spectrum, ds, ms,
filename, chrom, config))
if len(sys.argv) == 2:
raw_file = sys.argv[1]
filename[0] = raw_file
ds['chrom_dat'], ds['masses'], ds['matrix'] = load_raw(raw_file)
ds['chrom_dat'], ds['masses'], ds['matrix'] = load_raw(
raw_file, config.value("tmp_location"))
gt.populate(chromatogram, spectrum, ds, ms, chrom)
else:
gt.pop_plot(spectrum, ms)
......
#!/usr/bin/env python3
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
def settings():
settings = QtCore.QSettings("Yansoft","Prasopes")
return settings
def tmp_dial(tmp_text, config):
filename = QtWidgets.QFileDialog.getExistingDirectory()
if filename is not '':
tmp_text.setText(filename)
config.setValue("tmp_location", filename)
def dial(parent):
"""constructs a dialog window"""
dialog = QtWidgets.QDialog(
parent, windowTitle='Settings')
dialog.resize(600,-1)
config = settings()
tmp_text = QtWidgets.QLineEdit(config.value("tmp_location"))
tmp_text.editingFinished.connect(lambda: config.setValue(
"tmp_location", tmp_text.text()))
browse_button = QtWidgets.QPushButton("Browse..")
browse_button.clicked.connect(lambda: tmp_dial(tmp_text, config))
close_button = QtWidgets.QPushButton("Close")
close_button.clicked.connect(dialog.close)
layout = QtWidgets.QVBoxLayout(dialog)
butt_layout = QtWidgets.QHBoxLayout()
tmp_layout = QtWidgets.QHBoxLayout()
tmp_layout.addWidget(QtWidgets.QLabel("Acquisition temp folder:"))
tmp_layout.addWidget(tmp_text)
tmp_layout.addWidget(browse_button)
butt_layout.addWidget(close_button)
butt_layout.addStretch(1)
layout.addLayout(tmp_layout)
layout.addStretch(1)
layout.addLayout(butt_layout)
dialog.show()
......@@ -3,14 +3,14 @@ from rawprasslib import load_raw
import os.path
def open_dial(d_set):
def open_dial(d_set, settings):
"""Populates dataset, returns filename"""
filename = QtWidgets.QFileDialog.getOpenFileName(
caption="Open spectrum",
filter="Finnigan RAW files (*.raw, *.RAW)")[0]
if filename is not '':
d_set['chrom_dat'], d_set['masses'], d_set['matrix'] \
= load_raw(filename)
= load_raw(filename, settings.value("tmp_location"))
return filename
else:
return None
......
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