Commit 4b810153 authored by Yan's avatar Yan
Browse files

Mobility on DRL - experimental

* it looks like working, code is messy.
parent ad86799c
......@@ -14,7 +14,7 @@ from . import zcetools_help
from . import reactivitytools
__version__ = "0.0.45"
__version__ = "0.0.46"
__all__ = ['config', 'datatools', 'docks', 'drltools', 'datasets',
......
......@@ -23,6 +23,7 @@ import prasopes.zcetools as zce
import prasopes.docks as docks
import prasopes.datasets as datasets
import prasopes.mobtools_gui as mtg
import prasopes.drlmobtools_gui as mdrlgui
import prasopes.tangoicons
import sys
import logging
......@@ -347,10 +348,15 @@ def main():
drlact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_D)
drlact.triggered.connect(lambda: drlgui.main_window(
main_window, augCanvas, update))
tofact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
mobact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"applications-utilities"), "&MOB...", None)
tofact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_M)
tofact.triggered.connect(lambda: mtg.main_window(
mobact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_M)
mobact.triggered.connect(lambda: mtg.main_window(
main_window, augCanvas, update))
drlmobact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"applications-utilities"), "DR&LMOB...", None)
drlmobact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_L)
drlmobact.triggered.connect(lambda: mdrlgui.main_window(
main_window, augCanvas, update))
aboutact = QtWidgets.QAction("&About Prasopes", None)
aboutact.triggered.connect(lambda: about(main_window))
......@@ -404,7 +410,8 @@ def main():
main_window.menuBar().addMenu(tools_menu)
tools_menu.addAction(zceact)
tools_menu.addAction(drlact)
tools_menu.addAction(tofact)
tools_menu.addAction(mobact)
tools_menu.addAction(drlmobact)
tools_menu.addSeparator()
view_menu = QtWidgets.QMenu('&View', main_window)
[view_menu.addAction(i.action) for i in
......@@ -433,7 +440,8 @@ def main():
toolBar.addSeparator()
toolBar.addAction(zceact)
toolBar.addAction(drlact)
toolBar.addAction(tofact)
toolBar.addAction(mobact)
toolBar.addAction(drlmobact)
toolBar.addSeparator()
toolBar.addAction(autozoomy)
......
......@@ -195,6 +195,20 @@ class BrukerTimsDataset(Dataset):
np.clip(self.chromatograms[0][1], np.finfo(np.float32).eps, None))
return intensity
def get_mzmobpeakchrom(self, startmz, endmz, startmob, endmob):
boundsmz = sorted([startmz, endmz])
boundsmob = sorted([startmob, endmob])
logger.info("getting mz/mob peak ion chromatogram")
intensity = np.divide([
np.sum(i['intensity'][dt.argsubselect_2d(
i['mz'], startmz, endmz,
i['inv_ion_mobility'], startmob, endmob)])
for i in self.dataset.query_iter(
np.arange(self.dataset.max_frame)+1, columns=(
'intensity', 'mz', 'inv_ion_mobility'))],
np.clip(self.chromatograms[0][1], np.finfo(np.float32).eps, None))
return intensity
def get_subspace(self, xax, subselect, start, end, bins,
mint=None, maxt=None):
mint = mint or self.mintime
......
......@@ -15,8 +15,24 @@ def argsubselect(array, minimum, maximum):
return args
def argsubselect_2d(array1, min1, max1, array2, min2, max2):
"""finds arguments which fits into boundary conditions,
if there is no fit, return nearest argument"""
bounds1 = sorted([min1, max1])
bounds2 = sorted([min2, max2])
args = np.where((array1 >= bounds1[0]) & (array1 <= bounds1[1]) &
(array2 >= bounds2[0]) & (array2 <= bounds2[1]))[0]
if len(args) == 0:
# aver = (min1+max1)/2
# args = np.array([(np.abs(array - aver)).argmin()])
# TODO: FIXME!! THIS IS REALLY BAD!!
args = [0]
return args
def specttostr(augCanvas, delim=" ", names=["mass", "ion_count"],
units=["m/z", ""], description=""):
"""converts spectrum to string"""
lines = augCanvas.get_lines()
formnames = delim.join([delim.join(names) for i in range(len(lines))])
formunits = (delim).join([delim.join(units) for i in range(len(lines))])
......@@ -35,6 +51,7 @@ def specttostr(augCanvas, delim=" ", names=["mass", "ion_count"],
def clip_spectstr(augCanvas):
"""clip converted spectrum to string"""
description = ("{}_{:.4}-{:.4}_minutes_of_the_aquisition".format(
os.path.basename(augCanvas.ds.filename),
augCanvas.ds.mintime, augCanvas.ds.maxtime))
......@@ -45,6 +62,7 @@ def clip_spectstr(augCanvas):
def clip_tablestr(augCanvas):
"""clip values from table"""
pairs = [" ".join((augCanvas.paramstable.item(row, 1).text(),
augCanvas.paramstable.item(row, 2).text()))
for row in range(augCanvas.paramstable.rowCount())
......@@ -66,5 +84,4 @@ def table(labels, minsizex=600, minsizey=0):
table.horizontalHeader().setSectionResizeMode(
n, QtWidgets.QHeaderView.Stretch)
table.setMinimumSize(minsizex, minsizey)
return table
This diff is collapsed.
......@@ -25,17 +25,23 @@ def floatize(table, row, column, nonneg=True):
return outfloat
def get_range(center, width):
start = center - width / 2
end = center + width / 2
return start, end
def get_subargs(tab, row, masses, col1, col2):
startm = floatize(tab, row, col1) - (floatize(tab, row, col2) / 2)
endm = floatize(tab, row, col1) + (floatize(tab, row, col2) / 2)
startm, endm = get_range(floatize(tab, row, col1),
floatize(tab, row, col2))
massargs = dt.argsubselect(masses, startm, endm)
return massargs
def get_intensity(row, ds, drls):
# prevent division by 0
startm = floatize(drls['pt'], row, 1) - (floatize(drls['pt'], row, 2) / 2)
endm = floatize(drls['pt'], row, 1) + (floatize(drls['pt'], row, 2) / 2)
startm, endm = get_range(floatize(drls['pt'], row, 1),
floatize(drls['pt'], row, 2))
intensity = ds.get_peakchrom(startm, endm)
return intensity
......
......@@ -34,6 +34,7 @@ class AugFigureCanvas(FigureCanvas):
name="Chromatogram", xlabel="time(min)", ylabel="total ion count",
timesarg=[])
self.drlcache = [None, None]
self.mdrlcache = [None, None]
self.tofcache = [None, None]
self.mobontofcache = [None, None]
grid = self.figure.add_gridspec(2, 1)
......
......@@ -38,10 +38,8 @@ def pop_dial(dialspect, ionstable, labels, getfnc):
gt.pop_plot([], [], dialspect, labels)
for row in range(ionstable.rowCount()):
name = ionstable.item(row, 0).text()
startm = drl.floatize(ionstable, row, 3)\
- (drl.floatize(ionstable, row, 4) / 2)
endm = drl.floatize(ionstable, row, 3)\
+ (drl.floatize(ionstable, row, 4) / 2)
startm, endm = drl.get_range(drl.floatize(ionstable, row, 3),
drl.floatize(ionstable, row, 4))
[tstart, tend] = [drl.floatize(ionstable, row, i) for i in (1, 2)]
spectrum = getfnc(startm, endm, tstart, tend)
dialspect.plot(spectrum[0], spectrum[1], label=name,
......
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