Commit 8f4c29ad authored by Yan's avatar Yan
Browse files

DRLMOB - minor speedup

parent 7d370789
...@@ -14,7 +14,7 @@ from . import zcetools_help ...@@ -14,7 +14,7 @@ from . import zcetools_help
from . import reactivitytools from . import reactivitytools
__version__ = "0.0.48" __version__ = "0.0.49"
__all__ = ['config', 'datatools', 'docks', 'drltools', 'datasets', __all__ = ['config', 'datatools', 'docks', 'drltools', 'datasets',
......
...@@ -298,6 +298,7 @@ def main(): ...@@ -298,6 +298,7 @@ def main():
p_logger.addHandler(barHandler) p_logger.addHandler(barHandler)
zce_logger.addHandler(barHandler) zce_logger.addHandler(barHandler)
params_logger.addHandler(barHandler) params_logger.addHandler(barHandler)
ds_logger.addHandler(barHandler)
barHandler.setLevel("DEBUG") barHandler.setLevel("DEBUG")
main_window = QtWidgets.QMainWindow(windowTitle="Prasopes") main_window = QtWidgets.QMainWindow(windowTitle="Prasopes")
......
...@@ -69,6 +69,7 @@ class ThermoRawDataset(Dataset): ...@@ -69,6 +69,7 @@ class ThermoRawDataset(Dataset):
self.dataset = load_raw(self.filename, self.dataset = load_raw(self.filename,
cf.settings().value("tmp_location")) cf.settings().value("tmp_location"))
self.chromatograms = self.get_chromatograms() self.chromatograms = self.get_chromatograms()
self.fullspectra = self.get_spectra()
self.mintime, self.maxtime = [self.chromatograms[i][0][i] self.mintime, self.maxtime = [self.chromatograms[i][0][i]
for i in (0, -1)] for i in (0, -1)]
if autoparams: if autoparams:
...@@ -134,6 +135,7 @@ class BrukerTimsDataset(Dataset): ...@@ -134,6 +135,7 @@ class BrukerTimsDataset(Dataset):
self.dataset = OpenTIMS( self.dataset = OpenTIMS(
pathlib.Path(os.path.dirname(self.filename))) pathlib.Path(os.path.dirname(self.filename)))
self.chromatograms = self.get_chromatograms() self.chromatograms = self.get_chromatograms()
self.fullspectra = self.get_spectra()
self.mintime, self.maxtime = [self.chromatograms[i][0][i] self.mintime, self.maxtime = [self.chromatograms[i][0][i]
for i in (0, -1)] for i in (0, -1)]
...@@ -179,6 +181,7 @@ class BrukerTimsDataset(Dataset): ...@@ -179,6 +181,7 @@ class BrukerTimsDataset(Dataset):
masses, ints = self.binit( masses, ints = self.binit(
massints['mz'], massints['intensity'], massints['mz'], massints['intensity'],
cf.settings().value("timstof/ms_bins", type=float), len(framessel)) cf.settings().value("timstof/ms_bins", type=float), len(framessel))
logger.info("DONE: getting timsTOF spectra")
return [[masses, ints]] return [[masses, ints]]
def get_mobspectra(self, mint=None, maxt=None): def get_mobspectra(self, mint=None, maxt=None):
...@@ -214,14 +217,16 @@ class BrukerTimsDataset(Dataset): ...@@ -214,14 +217,16 @@ class BrukerTimsDataset(Dataset):
np.arange(self.dataset.max_frame)+1, columns=( np.arange(self.dataset.max_frame)+1, columns=(
'intensity', 'mz', 'inv_ion_mobility'))], 'intensity', 'mz', 'inv_ion_mobility'))],
np.clip(self.chromatograms[0][1], np.finfo(np.float32).eps, None)) np.clip(self.chromatograms[0][1], np.finfo(np.float32).eps, None))
logger.info("DONE: getting mz/mob peak ion chromatogram")
return intensity return intensity
def get_subspace(self, xax, subselect, start, end, bins, def get_subspace(self, xax, subselect, start, end, bins,
mint=None, maxt=None): mint=None, maxt=None):
mint = mint or self.mintime mint = mint or self.mintime
maxt = maxt or self.maxtime maxt = maxt or self.maxtime
logger.info(("getting timsTOF for {:.3f}-{:.3f} minutes, subselecting" msg = ("getting timsTOF for {:.3f}-{:.3f} minutes, subselecting"
" {}: {}-{}").format(mint, maxt, subselect, start, end)) " {}: {}-{}").format(mint, maxt, subselect, start, end)
logger.info(msg)
framessel = self.sampletimes(mint, maxt, cf.settings().value( framessel = self.sampletimes(mint, maxt, cf.settings().value(
"timstof/mob_sampling", type=int)) "timstof/mob_sampling", type=int))
massintstof = self.dataset.query( massintstof = self.dataset.query(
...@@ -231,8 +236,8 @@ class BrukerTimsDataset(Dataset): ...@@ -231,8 +236,8 @@ class BrukerTimsDataset(Dataset):
massintstof[xax][goodargs], massintstof['intensity'][goodargs], massintstof[xax][goodargs], massintstof['intensity'][goodargs],
cf.settings().value("timstof/{}".format(bins), type=float), cf.settings().value("timstof/{}".format(bins), type=float),
len(framessel)) len(framessel))
logger.info("DONE: "+msg)
return mobs, ints return mobs, ints
maxt = maxt or self.maxtime
def get_mobilogram(self, startm, endm, mint=None, maxt=None): def get_mobilogram(self, startm, endm, mint=None, maxt=None):
x, y = self. get_subspace('inv_ion_mobility', 'mz', x, y = self. get_subspace('inv_ion_mobility', 'mz',
......
...@@ -42,7 +42,7 @@ def update_msprofile(pt, row, dataset): ...@@ -42,7 +42,7 @@ def update_msprofile(pt, row, dataset):
spectrum = pt.cellWidget(row, 3).figure.get_axes()[0] spectrum = pt.cellWidget(row, 3).figure.get_axes()[0]
spectrum.clear() spectrum.clear()
limits = [] limits = []
spectra = dataset.get_spectra(-np.inf, np.inf) spectra = dataset.fullspectra
for i, spectxy in enumerate(spectra): for i, spectxy in enumerate(spectra):
massargs = drl.get_subargs(pt, row, spectxy[0], 1, 2) massargs = drl.get_subargs(pt, row, spectxy[0], 1, 2)
spectrum.plot(spectxy[0], spectxy[1], ':', color='gray') spectrum.plot(spectxy[0], spectxy[1], ':', color='gray')
......
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