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
8ccb50ef
Commit
8ccb50ef
authored
Aug 09, 2019
by
Yan
Browse files
Parameters change support - pt6
* drltools roughly fixed * not tested!!
parent
c14eca65
Changes
2
Hide whitespace changes
Inline
Side-by-side
prasopes/drltools.py
View file @
8ccb50ef
...
...
@@ -44,41 +44,45 @@ def floatize(table, row, column, nonneg=True):
return
outfloat
def
get_massargs
(
pt
,
row
,
d
s
):
def
get_massargs
(
pt
,
row
,
s
ubset
):
startm
=
floatize
(
pt
,
row
,
1
)
-
(
floatize
(
pt
,
row
,
2
)
/
2
)
endm
=
floatize
(
pt
,
row
,
1
)
+
(
floatize
(
pt
,
row
,
2
)
/
2
)
massargs
=
dt
.
argsubselect
(
d
s
[
'masses'
],
startm
,
endm
)
massargs
=
dt
.
argsubselect
(
s
ubset
[
'masses'
],
startm
,
endm
)
return
massargs
def
update_profile
(
pt
,
row
,
dataset
):
"""parent table profile spectrum updating procedure"""
# Dont do anything to graph when the spectrum is not populated
logger
.
debug
(
"updating parent table row {} profile"
.
format
(
row
))
if
isinstance
(
dataset
[
'masses'
],
type
(
None
)):
# Dont do anything to graph when the spectrum is not populated
if
len
(
dataset
)
==
0
:
return
spectrum
=
pt
.
cellWidget
(
row
,
3
).
figure
.
get_axes
()[
0
]
masses
=
dataset
[
'masses'
]
massargs
=
get_massargs
(
pt
,
row
,
dataset
)
yshape
=
np
.
mean
(
dataset
[
'matrix'
],
axis
=
0
)
spectrum
.
clear
()
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
])
limits
=
[]
for
i
,
subset
in
enumerate
(
dataset
):
masses
=
subset
[
'masses'
]
massargs
=
get_massargs
(
pt
,
row
,
subset
)
yshape
=
np
.
mean
(
subset
[
'matrix'
],
axis
=
0
)
spectrum
.
plot
(
masses
,
yshape
,
':'
,
color
=
'gray'
)
spectrum
.
plot
(
masses
[
massargs
],
yshape
[
massargs
],
color
=
gt
.
colors
[
i
%
len
(
gt
.
colors
)]
/
255
)
limits
.
append
((
masses
[
massargs
[[
0
,
-
1
]]],
max
(
yshape
[
massargs
])))
widest
=
np
.
argmax
([
abs
(
lim
[
0
][
1
]
-
lim
[
0
][
0
])
for
lim
in
limits
])
xmin
,
xmax
=
limits
[
widest
][
0
]
xex
=
max
((
xmax
-
xmin
)
*
0.25
,
0.20
)
spectrum
.
set_xlim
(
xmin
-
xex
,
xmax
+
xex
)
ymax
=
max
([
lim
[
1
]
for
lim
in
limits
])
spectrum
.
set_ylim
(
ymax
*-
0.1
,
ymax
*
1.2
)
spectrum
.
figure
.
canvas
.
draw
()
def
get_intensity
(
row
,
ds
,
drls
):
massargs
=
get_massargs
(
drls
[
'pt'
],
row
,
ds
)
#prevent division by 0
intensity
=
np
.
divide
(
np
.
sum
(
ds
[
'matrix'
].
T
[
massargs
].
T
,
axis
=
1
),
np
.
clip
(
ds
[
'chrom_dat'
][
1
],
np
.
nextafter
(
0
,
1
,
dtype
=
np
.
float32
),
None
))
intensity
=
np
.
concatenate
([
np
.
divide
(
np
.
sum
(
subset
[
'matrix'
].
T
[
get_massargs
(
drls
[
'pt'
],
row
,
subset
)].
T
,
axis
=
1
),
np
.
clip
(
subset
[
'chrom_dat'
][
1
],
np
.
finfo
(
np
.
float32
).
eps
,
None
))
for
subset
in
ds
])
return
intensity
...
...
@@ -86,7 +90,7 @@ def get_daughterset(ds, drls):
"""Fuction to acquire the curves of the daugher ions"""
logger
.
info
(
"getting set of the daughter ions"
)
names
=
[]
times
=
ds
[
'chrom_dat'
][
0
,
:]
-
drls
[
'tshift'
].
value
()
times
=
np
.
concatenate
([
sub
[
'chrom_dat'
][
0
,
:]
-
drls
[
'tshift'
].
value
()
for
sub
in
ds
])
intensities
=
[]
for
row
in
range
(
drls
[
'dt'
].
rowCount
()):
if
drls
[
'dt'
].
cellWidget
(
row
,
0
).
checkState
()
==
2
:
...
...
@@ -104,14 +108,13 @@ def get_daughterset(ds, drls):
cortext
=
" + "
.
join
(
corlist
)
intensities
.
append
(
intensity
)
names
.
append
(
"{} - ({})"
.
format
(
drls
[
'dt'
].
item
(
row
,
0
).
text
(),
cortext
))
drls
[
'dt'
].
item
(
row
,
0
).
text
(),
cortext
))
return
names
,
times
,
intensities
def
get_parentset
(
ds
,
drls
):
names
=
[]
times
=
ds
[
'chrom_dat'
][
0
,
:]
times
=
np
.
concatenate
([
sub
[
'chrom_dat'
][
0
,
:]
for
sub
in
ds
])
intensities
=
[]
rowlist
=
[]
for
row
in
range
(
drls
[
'dt'
].
rowCount
()):
...
...
@@ -134,12 +137,12 @@ def update_drlspectrum(ds, drls, drlspectrum):
"""Generic DRL spectrum updating procedure"""
logger
.
info
(
"updating DRL spectrum"
)
# Do not do anything when the data set is not populated.
if
isinstance
(
ds
[
'masses'
],
type
(
None
))
:
if
len
(
ds
)
==
0
:
return
names
,
times
,
intensities
=
get_daughterset
(
ds
,
drls
)
drlspectrum
.
clear
()
gt
.
pop_plot
(
drlspectrum
,
drls
[
'graphlabels'
])
gt
.
pop_plot
(
0
,
0
,
drlspectrum
,
drls
[
'graphlabels'
])
drlspectrum
.
axvline
(
0
,
0
,
0.9
,
color
=
"#FF000088"
,
linestyle
=
":"
)
if
drls
[
'cutoff'
].
value
()
!=
0
:
...
...
@@ -158,8 +161,8 @@ def update_drlspectrum(ds, drls, drlspectrum):
if
drls
[
'rel'
].
checkState
()
==
2
:
#Do not divide by 0
intensity
=
np
.
divide
(
intensity
,
np
.
clip
(
np
.
sum
(
intensities
,
0
),
np
.
nextafter
(
0
,
1
,
dtype
=
np
.
float32
),
None
),
dtype
=
np
.
float64
)
intensities
,
0
),
np
.
finfo
(
np
.
float32
).
eps
,
None
),
dtype
=
np
.
float64
)
drlspectrum
.
plot
(
times
,
intensity
,
label
=
label
,
color
=
(
gt
.
colors
[
row
%
len
(
gt
.
colors
)]
/
255
))
i
+=
1
...
...
@@ -661,8 +664,7 @@ def main_window(parent, ds, filename, cache, update_signal):
drls
[
'checkAll'
]
=
QtWidgets
.
QCheckBox
(
"Select all"
)
drls
[
'cors'
]
=
QtWidgets
.
QSpinBox
(
minimum
=
0
)
drls
[
'cors'
].
setValue
(
3
)
drls
[
'graphlabels'
]
=
dict
(
x
=
[
0
],
y
=
[
0
],
line
=
None
,
name
=
""
,
xlabel
=
"time(min)"
,
drls
[
'graphlabels'
]
=
dict
(
line
=
None
,
name
=
""
,
xlabel
=
"time(min)"
,
ylabel
=
"relative intensity"
)
dial_graph
=
Figure
(
figsize
=
(
5
,
2
),
dpi
=
100
,
facecolor
=
"None"
)
...
...
@@ -672,7 +674,7 @@ def main_window(parent, ds, filename, cache, update_signal):
graph_canvas
.
setAutoFillBackground
(
False
)
gt
.
pan_factory
(
chromplot
)
gt
.
zoom_factory
(
chromplot
,
1.15
)
gt
.
pop_plot
(
chromplot
,
drls
[
'graphlabels'
])
gt
.
pop_plot
(
0
,
0
,
chromplot
,
drls
[
'graphlabels'
])
dcolums
=
[
"Name"
]
for
i
in
range
(
drls
[
'cors'
].
value
()):
...
...
prasopes/imagetools.py
View file @
8ccb50ef
...
...
@@ -24,7 +24,7 @@ def paint_image(mass_spec, spect, painttarget=None):
printplot
.
set_xlim
(
spect
.
get_xlim
())
printplot
.
set_ylim
(
spect
.
get_ylim
())
data
=
[
line
.
get_data
()
for
line
in
spect
.
lines
]
[
gt
.
pop_plot
(
*
line
,
printplot
,
mass_spec
)
for
line
in
data
]
[
gt
.
pop_plot
(
*
line
,
printplot
,
mass_spec
,
i
)
for
i
,
line
in
enumerate
(
data
)
]
printplot
.
locator_params
(
nbins
=
xtics
,
axis
=
'x'
)
cache_file
=
BytesIO
()
paintfig
.
savefig
(
cache_file
)
...
...
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