Commit c14eca65 authored by Yan's avatar Yan
Browse files

Parameters change support - pt5 + clip table

* spectrum can be now clipped as table by ctrl+shift+c
* exporting fixed
* drl still broken
parent 150c0147
......@@ -13,6 +13,7 @@ from rawprasslib import rawprasslib
from prasopes.predictmz import predict as getmzpattern
import numpy as np
import prasopes.config as cf
import prasopes.datatools as dt
import prasopes.drltools as drl
import prasopes.filetools as ft
import prasopes.graphtools as gt
......@@ -127,9 +128,12 @@ def oddeven_changed(chromatogram, spectrum, ds, ms, filename, chrom, config,
def key_pressed(event, chrom, spect, ds, ms_ds, fn, chrom_ds, config):
if event.key() == QtCore.Qt.Key_F5:
update_spectrum(chrom, spect, ds, ms_ds, fn, chrom_ds, config)
if event.key() == QtCore.Qt.Key_C\
and event.modifiers().__int__() == QtCore.Qt.ControlModifier:
imgt.clip_spect_img(ms_ds, spect)
if event.key() == QtCore.Qt.Key_C:
if event.modifiers().__int__() == QtCore.Qt.ControlModifier:
imgt.clip_spect_img(ms_ds, spect)
if event.modifiers().__int__() == QtCore.Qt.ControlModifier+\
QtCore.Qt.ShiftModifier:
dt.clip_spectstr(spect, chrom_ds, fn)
if event.key() in (QtCore.Qt.Key_Left, QtCore.Qt.Key_Right):
gt.shift_times(event, spect, chrom, ds, ms_ds, chrom_ds)
......@@ -204,7 +208,7 @@ def main():
"document-save-as"), "&Export...", None)
exportact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_E)
exportact.triggered.connect(lambda: ft.export_dial(
ms, chrom, filename, main_window))
spectrum, chrom, filename, main_window))
printact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"document-print"), "&Print", None)
printact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_P)
......
from PyQt5 import QtGui
from PyQt5 import QtWidgets
import numpy as np
import os.path
def argsubselect(array, minimum, maximum):
......@@ -11,3 +12,28 @@ def argsubselect(array, minimum, maximum):
aver = (minimum+maximum)/2
args = np.array([(np.abs(array - aver)).argmin()])
return args
def specttostr(spectrum, chrom_ds, fn, delim=" "):
lines = spectrum.get_lines()
setnum = len(lines)
names = delim.join(["mass ion_count" for i in range(setnum)])
units = (delim+delim).join(["m/z" for i in range(setnum)])
description = ("{}_{:.4}-{:.4}_minutes_of_the_aquisition\n".format(
os.path.basename(fn[0]),
chrom_ds['t_start'], chrom_ds['t_end']))
header = "\n".join([names, units, description])
strdata = []
for i in range(np.max([len(line.get_xdata()) for line in lines])):
pairs = [("{}"+delim+"{}").format(line.get_xdata()[i], line.get_ydata()[i]) if\
i < len(line.get_xdata()) else delim for line in lines]
strline = delim.join(pairs)+"\n"
strdata.append(strline)
strdata = "".join(strdata)
return "{}{}".format(header, strdata)
def clip_spectstr(spectrum, chrom_ds, fn):
string = specttostr(spectrum, chrom_ds, fn, delim="\t")
QtWidgets.QApplication.clipboard().setText(string)
from PyQt5 import QtWidgets
import prasopes.config as cf
import prasopes.datatools as dt
import os.path
......@@ -26,7 +27,7 @@ def get_save_filename(caption, fnfilter, suffix, parent):
return filename
def export_dial(mass_spec, chrom_spec, fn, main_window):
def export_dial(spectrum, chrom_spec, fn, main_window):
"""exports the chromatogram into the .dat file format"""
if fn[0] is None:
QtWidgets.QMessageBox.warning(
......@@ -37,12 +38,5 @@ def export_dial(mass_spec, chrom_spec, fn, main_window):
"Export spectrum", "dat table (*.dat)", "dat", main_window)
if exp_f_name is not '':
expf = open(exp_f_name, 'w')
expf.write("mass ion_count\n"
"m/z\n"
"{}_{:.4}-{:.4}_minutes_of_the_aquisition\n".format(
os.path.basename(fn[0]),
chrom_spec['t_start'], chrom_spec['t_end']))
for i in range(len(mass_spec['x'])):
expf.write("{} {}\n".format(
mass_spec['x'][i], mass_spec['y'][i]))
expf.close()
expf.write(dt.specttostr(spectrum, chrom_spec, fn))
expf.close
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