Commit 920d1332 authored by 3Yan's avatar 3Yan
Browse files

Changed DRL export behaviour - now making folders

parent e2c5efe6
......@@ -339,11 +339,12 @@ def load_drltables(parent, ptable, dtable, dataset, drlspectrum):
dtable.cellWidget(i, 0).setCheckState(int(states[i]))
def save_drlconfig(ptable, dtable, parent):
def save_drlconfig(ptable, dtable, parent, exp_f_name=None):
"""safe DRL table layout so it can be summoned when needed"""
exp_f_name = ft.get_save_filename(
"Save DRL table layout", "comma-separated values (*.csv)",
"csv", parent)
if exp_f_name == None:
exp_f_name = ft.get_save_filename(
"Save DRL table layout", "comma-separated values (*.csv)",
"csv", parent)
if exp_f_name is not '':
expf = open(exp_f_name, 'w')
expf.write("#ion_name, start m/z, end m/z, visible,"
......@@ -362,15 +363,25 @@ def save_drlconfig(ptable, dtable, parent):
def export_drlspectrum(parent, fn, ptable, dtable, ds):
if fn[0] is None:
QtWidgets.QMessageBox.warning(
parent, "Export DRL dataset",
None, "Export DRL dataset",
"Nothing to export, cancelling request")
return
names, times, intensities = get_daughterset(ptable, dtable, ds)
pnames, ptimes, pintensities = get_parentset(ptable, dtable, ds)
fname = ft.get_save_filename(
"Export DRL data", "comma-separated values (*.csv)", "csv", parent)
exp_f_name = ["{}-raw.csv".format(fname[:-4]),
"{}-corrected.csv".format(fname[:-4])]
if names == []:
QtWidgets.QMessageBox.warning(
None, "Export DRL dataset",
"Nothing to export, cancelling request")
return
fname = QtWidgets.QFileDialog.getSaveFileName(
None,"Export DRL data",
options=(QtWidgets.QFileDialog.DontConfirmOverwrite |
QtWidgets.QFileDialog.HideNameFilterDetails))[0]
if fname is '':
return
exp_f_name = list(map(lambda x: "{}/{}-{}.csv".format(
fname, os.path.basename(fname), x),
["raw", "corrected", "input"]))
for name in exp_f_name:
if os.path.isfile(name):
quest = QtWidgets.QMessageBox.warning(
......@@ -381,25 +392,20 @@ def export_drlspectrum(parent, fn, ptable, dtable, ds):
QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
if quest == QtWidgets.QMessageBox.No:
return
if fname is not '':
expf = open(exp_f_name[0], 'w')
expf.write("times, {}\n".format((",".join(pnames))))
for i in range(len(times)):
dataset = list()
dataset.append(times[i])
for intensity in pintensities:
dataset.append(intensity[i])
expf.write("{}\n".format((",".join(map(str, dataset)))))
expf.close()
expf = open(exp_f_name[1], 'w')
expf.write("times, {}\n".format((",".join(names))))
for i in range(len(times)):
if not os.path.exists(fname):
os.makedirs(fname)
for i, table in enumerate([[pnames, pintensities],
[names, intensities]]):
expf = open(exp_f_name[i], 'w')
expf.write("times, {}\n".format((",".join(table[0]))))
for j in range(len(times)):
dataset = list()
dataset.append(times[i])
for intensity in intensities:
dataset.append(intensity[i])
dataset.append(times[j])
for intensity in table[1]:
dataset.append(intensity[j])
expf.write("{}\n".format((",".join(map(str, dataset)))))
expf.close()
save_drlconfig(ptable, dtable, parent, exp_f_name[2])
def print_graph(labels, ptable, dtable, ds):
......
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