Commit b5900f09 authored by Yan's avatar Yan
Browse files

Now exporting also parent ions, minor fixes

* fixed load_drl to accept unsetted QComboBox
* simplified update_profile function
parent 1f3d66d3
......@@ -41,20 +41,15 @@ def update_profile(pt, row, dataset):
if isinstance(dataset['masses'], type(None)):
return
start = floatize(pt, row, 1)
end = floatize(pt, row, 2)
spectrum = pt.cellWidget(row, 3).figure.get_axes()[0]
masses = dataset['masses']
massargs = dt.argsubselect(masses, start, end)
massargs = dt.argsubselect(
masses, floatize(pt, row, 1), floatize(pt, row, 2))
yshape = np.mean(dataset['matrix'], axis=0)
spectrum.clear()
dots_x = masses
dots_y = yshape
full_x = masses[massargs]
full_y = yshape[massargs]
spectrum.plot(dots_x, dots_y, ':', color='gray')
spectrum.plot(full_x, full_y, 'r')
xex = (masses[massargs[-1]]-masses[massargs[0]])*0.25
spectrum.plot(masses, yshape, ':', color='gray')
spectrum.plot(masses[massargs], yshape[massargs], 'r')
xex = max((masses[massargs[-1]]-masses[massargs[0]])*0.25, 0.20)
spectrum.set_xlim(masses[massargs[0]]-xex,
masses[massargs[-1]]+xex)
ymax = max(yshape[massargs])
......@@ -82,6 +77,7 @@ def get_daughterset(ptable, dtable, ds):
intensity = get_intensity(row, ptable, dtable, ds)
cor = dtable.cellWidget(row, 1).currentIndex() - 1
# TODO: check if cor still produce the mess or it started to behave
# testing in this alpha stage
if cor not in (-2, -1):
factor = floatize(dtable, row, 2)
correction = get_intensity(cor, ptable, dtable, ds)\
......@@ -95,6 +91,26 @@ def get_daughterset(ptable, dtable, ds):
return names, times, intensities
def get_parentset(ptable, dtable, ds):
names = []
times = ds['chrom_dat'][0, :]
intensities = []
# TODO: resolve intensities trouble
rowlist = []
for row in range(dtable.rowCount()):
if dtable.cellWidget(row, 0).checkState() == 2:
rowlist.append(row)
if dtable.cellWidget(row, 1).currentIndex() > 0\
and floatize(dtable, row, 2) != 0:
rowlist.append(
dtable.cellWidget(row, 1).currentIndex()-1)
for row in set(rowlist):
intensity = get_intensity(row, ptable, dtable, ds)
intensities.append(intensity)
names.append(dtable.item(row, 0).text())
return names, times, intensities
def update_drlspectrum(ptable, dtable, ds, drlspectrum):
# Dont do anything when the dataset is not populated
if isinstance(ds['masses'], type(None)):
......@@ -294,8 +310,9 @@ def load_drltables(parent, ptable, dtable, dataset, drlspectrum):
rawdata = cfile.read().splitlines()
for i in range(1, len(rawdata)):
rawline = rawdata[i].split(",")
# TODO: rawline[4] can be -1 - decide if accept this behaviour
if len(rawline) != 6 or int(rawline[3]) not in range(3) \
or int(rawline[4]) not in range(len(rawdata)):
or int(rawline[4]) not in range(-1,len(rawdata)):
QtWidgets.QMessageBox.warning(
parent, "Load DRL config tables",
"Config file corrupted on line {},"
......@@ -307,13 +324,13 @@ def load_drltables(parent, ptable, dtable, dataset, drlspectrum):
for row in reversed(range(ptable.rowCount())):
dtable.removeRow(row)
ptable.removeRow(row)
# first populate only parent table
# first populate only the parent table
for i in range(len(names)):
add_line(dataset, ptable, dtable, drlspectrum)
ptable.item(i, 0).setText(names[i])
ptable.item(i, 1).setText(start_masses[i])
ptable.item(i, 2).setText(end_masses[i])
# and after that daughter table
# and after that the daughter table
for i in range(len(names)):
dtable.cellWidget(i, 1).setCurrentIndex(
int(corrected_to[i]))
......@@ -348,8 +365,12 @@ def export_drlspectrum(parent, fn, ptable, dtable, ds):
"Nothing to export, cancelling request")
return
names, times, intensities = get_daughterset(ptable, dtable, ds)
pnames, ptimes, pintensities = get_parentset(ptable, dtable, ds)
exp_f_name = ft.get_save_filename(
"Export DRL data", "comma-separated values (*.csv)", "csv", parent)
names.append(" ")
for name in pnames:
names.append(name)
if exp_f_name is not '':
expf = open(exp_f_name, 'w')
expf.write("times, {}\n".format((",".join(names))))
......@@ -358,6 +379,9 @@ def export_drlspectrum(parent, fn, ptable, dtable, ds):
dataset.append(times[i])
for intensity in intensities:
dataset.append(intensity[i])
dataset.append(" ")
for intensity in pintensities:
dataset.append(intensity[i])
expf.write("{}\n".format((",".join(map(str, dataset)))))
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