Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Zelenka
prasopes
Commits
9fae08bb
Commit
9fae08bb
authored
Oct 07, 2019
by
Yan
Browse files
More fixes, copying of parameters working
* sw is still haunted by bugs after uniting but its workable
parent
f6740c3c
Changes
3
Show whitespace changes
Inline
Side-by-side
prasopes/__main__.py
View file @
9fae08bb
...
...
@@ -78,8 +78,9 @@ class AugFigureCanvas(FigureCanvas):
self
.
mass_selector
=
gt
.
AugSpanSelector
(
self
.
spectplot
,
self
.
ms
)
#TODO: rewrite timeSelector to better shape when I'm done
self
.
time_selector
=
SpanSelector
(
self
.
chromplot
,
lambda
x_min
,
x_max
:
gt
.
pick_times
(
x_min
,
x_max
,
self
.
spectplot
,
self
.
ds
,
self
.
chromplot
,
self
.
ms
,
self
.
chrom
,
self
.
paramstable
),
'horizontal'
,
useblit
=
True
,
rectprops
=
dict
(
alpha
=
0.15
,
facecolor
=
'purple'
),
button
=
3
)
gt
.
pick_times
(
x_min
,
x_max
,
self
),
'horizontal'
,
useblit
=
True
,
rectprops
=
dict
(
alpha
=
0.15
,
facecolor
=
'purple'
),
button
=
3
)
def
load_file
(
parent
,
augCanvas
,
update
,
settings
,
loadthread
,
filename
=
None
):
...
...
@@ -215,6 +216,9 @@ def key_pressed(event, augCanvas, config):
update_spectrum
(
augCanvas
,
config
)
if
event
.
key
()
==
QtCore
.
Qt
.
Key_C
:
if
event
.
modifiers
().
__int__
()
==
QtCore
.
Qt
.
ControlModifier
:
if
augCanvas
.
paramstable
.
underMouse
():
dt
.
clip_tablestr
(
augCanvas
)
else
:
imgt
.
clip_spect_img
(
augCanvas
.
ms
,
augCanvas
.
spectplot
,
augCanvas
.
filename
)
if
event
.
modifiers
().
__int__
()
==
QtCore
.
Qt
.
ControlModifier
+
\
...
...
prasopes/datatools.py
View file @
9fae08bb
...
...
@@ -40,6 +40,15 @@ def clip_spectstr(augCanvas):
[
QtWidgets
.
QApplication
.
clipboard
().
setText
(
string
,
i
)
for
i
in
range
(
2
)]
def
clip_tablestr
(
augCanvas
):
pairs
=
[
" "
.
join
((
augCanvas
.
paramstable
.
item
(
row
,
1
).
text
(),
augCanvas
.
paramstable
.
item
(
row
,
2
).
text
()))
for
row
in
range
(
augCanvas
.
paramstable
.
rowCount
())
if
augCanvas
.
paramstable
.
cellWidget
(
row
,
0
).
checkState
()]
text
=
", "
.
join
(
pairs
)
[
QtWidgets
.
QApplication
.
clipboard
().
setText
(
text
,
i
)
for
i
in
range
(
2
)]
def
table
(
labels
,
minsizex
=
600
,
minsizey
=
0
):
"""creates a reasonable table"""
table
=
QtWidgets
.
QTableWidget
(
columnCount
=
len
(
labels
))
...
...
prasopes/graphtools.py
View file @
9fae08bb
...
...
@@ -183,83 +183,86 @@ def textedit_factory(axis, plot_data):
axis
.
figure
.
canvas
.
mpl_connect
(
'pick_event'
,
annpicked
)
def
plot_subtime
(
mpl_spectrum
,
mpl_chromatogram
,
ds
,
ms_data
,
chrom_data
):
#def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
def
plot_subtime
(
augCanvas
):
"""plot averaged spectrum of subselected part of the chromatogram"""
slims
=
[
mpl_spectrum
.
get_xlim
(),
mpl_spectrum
.
get_ylim
()]
chlims
=
[
mpl_chromatogram
.
get_xlim
(),
mpl_chromatogram
.
get_ylim
()]
ms_data
[
'annotation'
].
clear
()
mpl_spectrum
.
clear
()
mpl_chromatogram
.
clear
()
for
i
,
subset
in
enumerate
(
ds
):
selection
=
chrom_data
[
'timesarg'
][
i
]
if
len
(
ms_data
[
'headers'
])
==
len
(
ds
):
legend
=
legendize
(
ms_data
[
'headers'
][
i
][
selection
],
chrom_data
)
slims
=
[
augCanvas
.
spectplot
.
get_xlim
(),
augCanvas
.
spectplot
.
get_ylim
()]
chlims
=
[
augCanvas
.
chromplot
.
get_xlim
(),
augCanvas
.
chromplot
.
get_ylim
()]
augCanvas
.
ms
[
'annotation'
].
clear
()
augCanvas
.
spectplot
.
clear
()
augCanvas
.
chromplot
.
clear
()
for
i
,
subset
in
enumerate
(
augCanvas
.
ds
):
selection
=
augCanvas
.
chrom
[
'timesarg'
][
i
]
if
len
(
augCanvas
.
ms
[
'headers'
])
==
len
(
augCanvas
.
ds
):
legend
=
legendize
(
augCanvas
.
ms
[
'headers'
][
i
][
selection
],
augCanvas
.
chrom
)
else
:
legend
=
None
if
cf
.
settings
().
value
(
"view/oddeven"
,
type
=
bool
):
for
j
in
range
(
2
):
chromx
=
subset
[
'chrom_dat'
][
0
,
:][
j
::
2
]
chromy
=
subset
[
'chrom_dat'
][
1
,
:][
j
::
2
]
pop_plot
(
chromx
,
chromy
,
mpl_chromatogram
,
chrom_data
,
i
*
2
+
j
,
legend
)
pop_plot
(
chromx
,
chromy
,
augCanvas
.
chromplot
,
augCanvas
.
chrom
,
i
*
2
+
j
,
legend
)
if
not
np
.
array_equal
(
selection
[
j
::
2
],
[]):
clr
=
i
*
2
+
j
if
selection
[
0
]
%
2
==
0
\
else
i
*
2
+
(
1
-
j
)
ms_x
=
subset
[
'masses'
]
ms_y
=
np
.
mean
(
subset
[
'matrix'
][
selection
[
j
::
2
]],
axis
=
0
)
pop_plot
(
ms_x
,
ms_y
,
mpl_spectrum
,
ms_data
,
clr
,
legend
)
pop_plot
(
ms_x
,
ms_y
,
augCanvas
.
spectplot
,
augCanvas
.
ms
,
clr
,
legend
)
dots_x
=
subset
[
'chrom_dat'
][
0
,
selection
[
j
::
2
]]
dots_y
=
subset
[
'chrom_dat'
][
1
,
selection
[
j
::
2
]]
mpl_chromatogram
.
plot
(
dots_x
,
dots_y
,
'.'
,
color
=
(
augCanvas
.
chromplot
.
plot
(
dots_x
,
dots_y
,
'.'
,
color
=
(
colors
[(
clr
)
%
len
(
colors
)]
/
255
))
else
:
chromx
=
subset
[
'chrom_dat'
][
0
,
:]
chromy
=
subset
[
'chrom_dat'
][
1
,
:]
pop_plot
(
chromx
,
chromy
,
mpl_chromatogram
,
chrom_data
,
i
,
legend
)
pop_plot
(
chromx
,
chromy
,
augCanvas
.
chromplot
,
augCanvas
.
chrom
,
i
,
legend
)
if
not
np
.
array_equal
(
selection
,
[]):
ms_x
=
subset
[
'masses'
]
ms_y
=
np
.
mean
(
subset
[
'matrix'
][
selection
],
axis
=
0
)
pop_plot
(
ms_x
,
ms_y
,
mpl_spectrum
,
ms_data
,
i
,
legend
)
pop_plot
(
ms_x
,
ms_y
,
augCanvas
.
spectplot
,
augCanvas
.
ms
,
i
,
legend
)
dots_x
=
subset
[
'chrom_dat'
][
0
,
selection
]
dots_y
=
subset
[
'chrom_dat'
][
1
,
selection
]
mpl_chromatogram
.
plot
(
dots_x
,
dots_y
,
'.'
,
color
=
(
augCanvas
.
chromplot
.
plot
(
dots_x
,
dots_y
,
'.'
,
color
=
(
colors
[
i
%
len
(
colors
)]
/
255
))
mpl_
spect
rum
.
set_xlim
(
slims
[
0
])
augCanvas
.
spect
plot
.
set_xlim
(
slims
[
0
])
if
not
cf
.
settings
().
value
(
"view/autozoomy"
,
type
=
bool
):
mpl_
spect
rum
.
set_ylim
(
slims
[
1
])
if
not
ms_data
[
'headers'
]
==
[]:
mpl_
spect
rum
.
legend
(
loc
=
2
)
mpl_
spect
rum
.
get_legend
().
set_in_layout
(
False
)
mpl_chromatogram
.
legend
(
loc
=
2
)
mpl_chromatogram
.
get_legend
().
set_in_layout
(
False
)
augCanvas
.
spect
plot
.
set_ylim
(
slims
[
1
])
if
not
augCanvas
.
ms
[
'headers'
]
==
[]:
augCanvas
.
spect
plot
.
legend
(
loc
=
2
)
augCanvas
.
spect
plot
.
get_legend
().
set_in_layout
(
False
)
augCanvas
.
chromplot
.
legend
(
loc
=
2
)
augCanvas
.
chromplot
.
get_legend
().
set_in_layout
(
False
)
else
:
autozoomy
(
mpl_
spect
rum
)
ann_spec
(
mpl_spectrum
,
ms_data
)
mpl_chromatogram
.
set_xlim
(
chlims
[
0
])
mpl_chromatogram
.
set_ylim
(
chlims
[
1
])
mpl_chromatogram
.
get_figure
().
canvas
.
draw
()
autozoomy
(
augCanvas
.
spect
plot
)
ann_spec
(
augCanvas
.
spectplot
,
augCanvas
.
ms
)
augCanvas
.
chromplot
.
set_xlim
(
chlims
[
0
])
augCanvas
.
chromplot
.
set_ylim
(
chlims
[
1
])
augCanvas
.
chromplot
.
get_figure
().
canvas
.
draw
()
def
pick_times
(
x_min
,
x_max
,
mpl_spectrum
,
data_set
,
mpl_chromatogram
,
mass_spect
,
chrom_spect
,
table
):
def
pick_times
(
x_min
,
x_max
,
augCanvas
):
"""subselect part of the chromatogram and plot it"""
chrom_spect
[
't_start'
]
=
x_min
chrom_spect
[
't_end'
]
=
x_max
augCanvas
.
chrom
[
't_start'
]
=
x_min
augCanvas
.
chrom
[
't_end'
]
=
x_max
times
=
dt
.
argsubselect
(
np
.
concatenate
(
[
subset
[
'chrom_dat'
][
0
]
for
subset
in
data_set
]),
x_min
,
x_max
)
chrom_spect
[
'timesarg'
].
clear
()
for
subset
in
data_set
:
[
subset
[
'chrom_dat'
][
0
]
for
subset
in
augCanvas
.
ds
]),
x_min
,
x_max
)
augCanvas
.
chrom
[
'timesarg'
].
clear
()
for
subset
in
augCanvas
.
ds
:
goodtimes
=
np
.
where
((
times
<
len
(
subset
[
'chrom_dat'
][
0
]))
&
~
(
times
<
0
))[
0
]
chrom_spect
[
'timesarg'
].
append
(
times
[
goodtimes
])
augCanvas
.
chrom
[
'timesarg'
].
append
(
times
[
goodtimes
])
times
=
times
-
len
(
subset
[
'chrom_dat'
][
0
])
update_paramstable
(
table
,
mass_spect
,
chrom_spect
)
plot_subtime
(
mpl_spectrum
,
mpl_chromatogram
,
data_set
,
mass_spect
,
chrom_spect
)
update_paramstable
(
augCanvas
)
plot_subtime
(
augCanvas
)
def
shift_times
(
event
,
spect
,
chrom
,
ds
,
ms_ds
,
chrom_d
s
):
def
shift_times
(
event
,
augCanva
s
):
"""shifts times when arrow is pressed"""
if
event
.
key
()
==
QtCore
.
Qt
.
Key_Left
:
move
=
-
1
...
...
@@ -267,14 +270,15 @@ def shift_times(event, spect, chrom, ds, ms_ds, chrom_ds):
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
])
if
not
np
.
array_equal
(
augCanvas
.
chrom
[
'timesarg'
],
[]):
x_min
,
x_max
=
augCanvas
.
chrom
[
't_start'
],
augCanvas
.
chrom
[
't_end'
]
alltimes
=
np
.
concatenate
([
subset
[
'chrom_dat'
][
0
]
for
subset
in
augCanvas
.
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_d
s
)
pick_times
(
x_min
,
x_max
,
augCanva
s
)
def
autozoomy
(
ms_spec
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment