Commit bd500ff9 authored by Yan's avatar Yan
Browse files

Reactivitytools - fix

* still many things broken
parent f2adb015
......@@ -210,7 +210,7 @@ def paint_override(self, augCanvas):
self.plot.set_ylim(augCanvas.spectplot.get_ylim())
data = [line.get_data() for line in augCanvas.spectplot.lines]
texts = copy.copy(augCanvas.ms)
if augCanvas.ds and augCanvas.ds.headers != []:
if augCanvas.ds and augCanvas.ds.headers:
legend = augCanvas.spectplot.get_legend().get_texts()
[gt.pop_plot(*line, self.plot, texts, i, legend[i].get_text(),
not (cf.settings().value(
......
......@@ -22,8 +22,8 @@ class Dataset():
self.filename = rawfile
self.chromatograms = []
self.dataset = []
self.headers = []
self.params = []
self.headers = None
self.params = None
self.mintime = -np.inf
self.maxtime = np.inf
......
......@@ -28,8 +28,7 @@ class AugFigureCanvas(FigureCanvas):
super().__init__(self.figure)
self.ds = None
self.ms = dict(annotation=[], name="Spectrum", xlabel="m/z",
ylabel="ion count", xtics=20, predict=None,
params=[], headers=[], texts=[])
ylabel="ion count", xtics=20, predict=None, texts=[])
self.chrom = dict(
x=[0], y=[0], t_start=None, t_end=None, machtype=None,
name="Chromatogram", xlabel="time(min)", ylabel="total ion count",
......@@ -250,7 +249,7 @@ def plot_subtime(augCanvas):
augCanvas.spectplot.set_xlim(slims[0])
if not cf.settings().value("view/autozoomy", type=bool):
augCanvas.spectplot.set_ylim(slims[1])
if not augCanvas.ds.headers == []:
if augCanvas.ds.headers:
for ax in (augCanvas.spectplot, augCanvas.chromplot):
ax.legend(loc=2)
ax.get_legend().set_in_layout(False)
......@@ -451,7 +450,8 @@ def populate(augCanvas):
chromxy = augCanvas.ds.chromatograms
msxy = augCanvas.ds.get_spectra()
for i in range(len(msxy)):
if len(augCanvas.ds.headers) == len(augCanvas.ds.chromatograms):
if augCanvas.ds.headers and\
len(augCanvas.ds.headers) == len(augCanvas.ds.chromatograms):
legend = legendize(augCanvas.ds.headers[i], augCanvas)
else:
legend = None
......@@ -459,7 +459,7 @@ def populate(augCanvas):
pop_plot(chromxy[i][0], chromxy[i][1], augCanvas.chromplot,
augCanvas.chrom, i, legend)
for ax in (augCanvas.spectplot, augCanvas.chromplot):
if not augCanvas.ds.headers == []:
if augCanvas.ds.headers:
ax.legend(loc=2)
ax.get_legend().set_in_layout(False)
ax.get_legend().set_visible(
......@@ -471,7 +471,7 @@ def populate(augCanvas):
def update_paramstable(augCanvas):
if augCanvas.ds.params == []:
if not augCanvas.ds.params:
augCanvas.paramstable.setRowCount(0)
return
elif len(augCanvas.ds.params[0]) == augCanvas.paramstable.rowCount():
......
......@@ -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.ds:
if not augCanvas.ds or not augCanvas.ds.params:
QtWidgets.QMessageBox.warning(
None, "Export spectrum",
"Nothing to export, cancelling request")
......@@ -105,13 +105,13 @@ def export_dial(augCanvas, drls, grph, labels, parselect):
def update_parselect(augCanvas, parselect):
# Do not do anything when data set is not populated
if not augCanvas.ds:
if not augCanvas.ds or not augCanvas.ds.params:
return
index = parselect.currentIndex()
if index == -1:
index = settings.value("reactivity/index", type=int)
parlist = [": ".join([str(i), j]) for i, j in
enumerate(augCanvas.ms['params'][0])]
enumerate(augCanvas.ds.params[0])]
parselect.clear()
parselect.addItems(parlist)
if index <= len(parlist):
......@@ -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 not augCanvas.ds:
if not augCanvas.ds or not augCanvas.ds.params or not augCanvas.ds.headers:
return
def getconfval(name, type, parselect=parselect):
......
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