Commit 6287aa50 authored by Yan's avatar Yan
Browse files

Fixing copying as texts

parent a3983aab
......@@ -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.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,13 +22,13 @@ class Dataset():
self.dataset = []
self.headers = []
self.params = []
self.timemin = -np.inf
self.timemax = np.inf
self.mintime = -np.inf
self.maxtime = np.inf
def get_chromargs(self):
times = dt.argsubselect(np.concatenate(
[subset[0] for subset in self.chromatograms]),
self.timemin, self.timemax)
self.mintime, self.maxtime)
args = []
for subset in self.chromatograms:
goodtimes = np.where((times < len(subset[0])) & ~(times < 0))[0]
......@@ -56,10 +56,10 @@ class ThermoRawDataset(Dataset):
self.refresh()
def refresh(self):
self.dataset = load_raw(self.filename,
self.dataset = load_raw(self.filename,
cf.settings().value("tmp_location"))
self.chromatograms = self.get_chromatograms()
self.timemin, self.timemax = [self.chromatograms[i][0][i]
self.mintime, self.maxtime = [self.chromatograms[i][0][i]
for i in (0,-1)]
if autoparams:
try:
......@@ -112,7 +112,7 @@ class BrukerTimsDataset(Dataset):
else:
self.dataset = OpenTIMS(pathlib.Path(os.path.dirname(self.filename)))
self.chromatograms = self.get_chromatograms()
self.timemin, self.timemax = [self.chromatograms[i][0][i]
self.mintime, self.maxtime = [self.chromatograms[i][0][i]
for i in (0,-1)]
def get_chromatograms(self):
......@@ -124,7 +124,7 @@ class BrukerTimsDataset(Dataset):
return [[times,intensities]]
def get_spectra(self):
massints = self.dataset.rt_query(self.timemin*60, self.timemax*60,
massints = self.dataset.rt_query(self.mintime*60, self.maxtime*60,
columns=('mz', 'intensity'))
sortmasses = np.sort(massints['mz'])
masssteps = sortmasses[1:] - sortmasses[:-1]
......
......@@ -17,9 +17,8 @@ def argsubselect(array, minimum, maximum):
def specttostr(augCanvas, delim=" ", names=["mass","ion_count"], units=["m/z",""], description = ""):
lines = augCanvas.get_lines()
setnum = len(lines)
formnames = delim.join([delim.join(names) for i in range(setnum)])
formunits = (delim).join([delim.join(units) for i in range(setnum)])
formnames = delim.join([delim.join(names) for i in range(len(lines))])
formunits = (delim).join([delim.join(units) for i in range(len(lines))])
header = "\n".join([formnames, formunits, description])+"\n"
strdata = []
......@@ -37,7 +36,7 @@ def specttostr(augCanvas, delim=" ", names=["mass","ion_count"], units=["m/z",""
def clip_spectstr(augCanvas):
description = ("{}_{:.4}-{:.4}_minutes_of_the_aquisition".format(
os.path.basename(augCanvas.ds.filename),
augCanvas.chrom['t_start'], augCanvas.chrom['t_end']))
augCanvas.ds.mintime, augCanvas.ds.maxtime))
string = specttostr(augCanvas.spectplot, delim="\t", description=description)
QtWidgets.QApplication.clipboard().clear()
[QtWidgets.QApplication.clipboard().setText(string, i) for i in range(2)]
......
......@@ -267,8 +267,8 @@ def plot_subtime(augCanvas):
def pick_times(x_min, x_max, augCanvas):
"""subselect part of the chromatogram and plot it"""
augCanvas.ds.timemin = x_min
augCanvas.ds.timemax = x_max
augCanvas.ds.mintime = x_min
augCanvas.ds.maxtime = x_max
plot_subtime(augCanvas)
......@@ -424,7 +424,7 @@ def legendize(rawlegend, augCanvas):
np.unique(np.array(rawlegend), axis=0, return_index=True)
strdata = [translate(i) for i in rawlegend[np.sort(uniqindexs[1])]]
strtext = " and\n".join(strdata) + "; t = {:.2f}-{:.2f} min".format(
augCanvas.ds.timemin, augCanvas.ds.timemax)
augCanvas.ds.mintime, augCanvas.ds.maxtime)
return strtext
......@@ -488,8 +488,8 @@ def update_paramstable(augCanvas):
augCanvas.paramstable.cellWidget(row, 0).setCheckState(states[row])
augCanvas.paramstable.item(row, 1).setText(paramname)
vals = [param[row] for param in augCanvas.ds.params[1]
if (param[0] >= augCanvas.ds.timemin and
param[0] <= augCanvas.ds.timemax)]
if (param[0] >= augCanvas.ds.mintime and
param[0] <= augCanvas.ds.maxtime)]
if len(vals) == 0:
text = ""
elif all([type(val) in [np.float32, np.float64] for val in vals]):
......
......@@ -126,7 +126,6 @@ def print_graph(ds, coff, coffgrad):
def key_pressed(event, ds, coff, coffgrad):
print("trigged")
if event.key() == QtCore.Qt.Key_C:
if event.modifiers().__int__() == QtCore.Qt.ControlModifier:
painter = imgt.ImagePainter("zcespec")
......
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