Commit 5f4240dd authored by Yan's avatar Yan
Browse files

TimsTof - big files support

* introduced sampling (to be refined!)
parent 1f461fe4
......@@ -134,6 +134,7 @@ class BrukerTimsDataset(Dataset):
def get_chromatograms(self):
keys = ('retention_time', 'intensity')
times = self.dataset.retention_times / 60
#devNote - summing is fast, asarray is fast, iterating is slow.
intensities = np.asarray([
np.sum(i['intensity']) for i in self.dataset.query_iter(
self.dataset.ms1_frames, columns=('intensity',))])
......@@ -142,15 +143,20 @@ class BrukerTimsDataset(Dataset):
def get_spectra(self, mint=None, maxt=None):
mint = mint or self.mintime
maxt = maxt or self.maxtime
massints = self.dataset.rt_query(mint*60, maxt*60,
columns=('mz', 'intensity'))
#TODO: set in config
frames = dt.argsubselect(self.dataset.retention_times,
mint*60, maxt*60) + 1
timescap = 500
framessel = frames if timescap >= len(frames) else np.linspace(
frames[0], frames[-1], timescap).astype('int')
massints = self.dataset.query(framessel, columns=('mz', 'intensity'))
sortmasses = np.sort(massints['mz'])
masssteps = sortmasses[1:] - sortmasses[:-1]
binspos = np.where(masssteps > 0.001)[0]
bins = sortmasses[:-1][binspos] + (masssteps[binspos]/2)
binpos = np.digitize(massints['mz'], bins)
masses = np.bincount(binpos, massints['mz']) / np.bincount(binpos)
ints = np.bincount(binpos, massints['intensity']) / self.dataset.max_frame
ints = np.bincount(binpos, massints['intensity']) / len(framessel)
return [[masses, ints]]
def get_peakchrom(self, startm, endm):
......
......@@ -239,11 +239,11 @@ def plot_subtime(augCanvas):
chromargs = augCanvas.ds.get_chromargs()
populate(augCanvas)
chromxy = augCanvas.ds.get_chromatograms()
for i, args in enumerate(chromargs):
if len(args):
dots_x, dots_y = [chromxy[i][j][args] for j in (0,1)]
dots_x, dots_y = [augCanvas.ds.chromatograms[i][j][args]
for j in (0,1)]
augCanvas.chromplot.plot(dots_x, dots_y, '.', color=(
colors[i % len(colors)]/255))
......
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