Commit 316e81af authored by Yan's avatar Yan
Browse files

Parameters change support - pt2

* odd/even fixed
* arrow moving fixed
* times argument now purged when loading new file
* fix colors during odd/even times sub-selection
* drl and zce still broken
* exporting/clipping/printing functions probably broken too
parent 2a0f8818
......@@ -44,6 +44,7 @@ def load_file(parent, chrom_plot, spc, d_set, ms_s, fn, chrom_s,
if filename is not '' and os.path.isfile(filename):
try:
d_set.clear()
chrom_s['timesarg'].clear()
[d_set.append(dict(chrom_dat=i[0], masses=i[1], matrix=i[2])) for i
in load_raw(filename, settings.value("tmp_location"))]
except rawprasslib.ParsingException as pex:
......@@ -129,6 +130,8 @@ def key_pressed(event, 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() in (QtCore.Qt.Key_Left, QtCore.Qt.Key_Right):
gt.shift_times(event, spect, chrom, ds, ms_ds, chrom_ds)
def about(parent):
......
......@@ -53,7 +53,7 @@ def zoom_factory(axis, base_scale, plot_data=None):
def pan_factory(axis, plot=None):
"""pan spectrum when you press a button"""
def pan_fun(event, ax, pd):
# rescale to origin if doubleclicked
# re-scale to origin if doubleclicked
if event.dblclick and event.inaxes == ax:
ax.get_figure()
ax.autoscale(True)
......@@ -109,27 +109,27 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
for i,subset in enumerate(ds):
if cf.settings().value("view/oddeven", type=bool):
for i in range(2):
msx = subset['masses'][i::2]
msy = np.mean(subset['matrix'], axis=0)[i::2]
print("panic")
"""for i in ((mpl_spectrum, ms_data), (mpl_chromatogram, chrom_data)):
for j in range(2):
spect = i[1].copy()
if i[1] == ms_data:
spect['y'] = np.mean(
ds['matrix'][chrom_data['timesarg'][j::2]],
axis=0)
else:
spect['x'], spect['y'] = [i[1][k[0]][k[1]::2] for k in
(('x',j),('y',j))]
pop_plot(i[0], spect)
styles = ("blue", "orange")
for i,j in enumerate(styles):
dots_x = ds['chrom_dat'][0, chrom_data['timesarg']][i::2]
dots_y = ds['chrom_dat'][1, chrom_data['timesarg']][i::2]
mpl_chromatogram.plot(dots_x, dots_y, linestyle=None,
marker='.', color=j)"""
chromx = subset['chrom_dat'][0, :][j::2]
chromy = subset['chrom_dat'][1, :][j::2]
pop_plot(chromx, chromy, mpl_chromatogram, chrom_data,
colornum=i*2+j)
if not np.array_equal(chrom_data['timesarg'][i][j::2], []):
if not chrom_data['timesarg'][i][0] % 2 == 0:
k=1-j
else:
k=j
ms_x = subset['masses']
ms_y = np.mean(subset['matrix'][
chrom_data['timesarg'][i][j::2]],
axis=0)
pop_plot(ms_x, ms_y, mpl_spectrum, ms_data, colornum=i*2+k)
dots_x = subset['chrom_dat'][
0, chrom_data['timesarg'][i][j::2]]
dots_y = subset['chrom_dat'][
1, chrom_data['timesarg'][i][j::2]]
mpl_chromatogram.plot(dots_x, dots_y, '.', color=(
colors[(i*2+k) % len(colors)]/255))
else:
chromx = subset['chrom_dat'][0, :]
chromy = subset['chrom_dat'][1, :]
......@@ -150,8 +150,8 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
else:
autozoomy(mpl_spectrum)
ann_spec(mpl_spectrum, ms_data)
mpl_chromatogram.set_ylim(chlims[1])
mpl_chromatogram.set_xlim(chlims[0])
mpl_chromatogram.set_ylim(chlims[1])
mpl_chromatogram.get_figure().canvas.draw()
......@@ -171,23 +171,23 @@ def pick_times(x_min, x_max, mpl_spectrum, data_set, mpl_chromatogram,
chrom_spect)
def arrow_factory(spectrum, chromatogram, ds, mass_spect,
chrom_spect):
def arrow_fun(event, mpl_spectrum, mpl_chromatogram, data_set,
mass_spect, chrom_spect):
arrows = dict(left=-1, right=+1)
if event.key in arrows.keys() and not isinstance(
chrom_spect['timesarg'], type(None)):
times = np.arange(len(data_set['chrom_dat'][0]))
chrom_spect['timesarg'] = dt.argsubselect(
times, chrom_spect['timesarg'][0]+arrows[event.key],
chrom_spect['timesarg'][-1]+arrows[event.key])
plot_subtime(mpl_spectrum, mpl_chromatogram, data_set,
mass_spect, chrom_spect)
fig = chromatogram.get_figure()
fig.canvas.mpl_connect('key_press_event', lambda event: arrow_fun(
event, spectrum, chromatogram, ds, mass_spect, chrom_spect))
def shift_times(event, spect, chrom, ds, ms_ds, chrom_ds):
"""shifts times when arrow is pressed"""
if event.key() == QtCore.Qt.Key_Left:
move = -1
elif event.key() == QtCore.Qt.Key_Right:
move = +1
else:
return
if not np.array_equal(chrom_ds['timesarg'], []):
x_min, x_max = chrom_ds['t_start'], chrom_ds['t_end']
alltimes = np.concatenate([subset['chrom_dat'][0] for subset in ds])
times = dt.argsubselect(alltimes, x_min, x_max) + move
goodtimes = np.where((times < len(alltimes)) & ~(times <0))[0]
if not np.array_equal(goodtimes, []):
x_min, x_max = alltimes[times[goodtimes[[0,-1]]]]
pick_times(x_min, x_max, spect, ds, chrom, ms_ds, chrom_ds)
def autozoomy(ms_spec):
if cf.settings().value("view/autozoomy", type=bool) and not (
......
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