Commit d6d89659 authored by 3Yan's avatar 3Yan
Browse files

DRL - ions now defined by m/z and PeakWidth

* changed the ion selection from start m/z-end m/z to m/z-peak width.
parent 329c6d7d
......@@ -6,7 +6,6 @@ from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
from copy import copy
import gc
import matplotlib
import numpy as np
import prasopes.datatools as dt
......@@ -44,6 +43,13 @@ def floatize(table, row, column, nonneg=True):
return outfloat
def get_massargs(pt, row, ds):
startm = floatize(pt, row, 1) - (floatize(pt, row, 2) / 2)
endm = floatize(pt, row, 1) + (floatize(pt, row, 2) / 2)
massargs = dt.argsubselect(ds['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
......@@ -53,8 +59,7 @@ def update_profile(pt, row, dataset):
spectrum = pt.cellWidget(row, 3).figure.get_axes()[0]
masses = dataset['masses']
massargs = dt.argsubselect(
masses, floatize(pt, row, 1), floatize(pt, row, 2))
massargs = get_massargs(pt, row, dataset)
yshape = np.mean(dataset['matrix'], axis=0)
spectrum.clear()
spectrum.plot(masses, yshape, ':', color='gray')
......@@ -68,9 +73,7 @@ def update_profile(pt, row, dataset):
def get_intensity(row, ds, drls):
startm = floatize(drls['pt'], row, 1)
endm = floatize(drls['pt'], row, 2)
massargs = dt.argsubselect(ds['masses'], startm, endm)
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(
......@@ -180,7 +183,7 @@ def gettableitemlist(ptable):
else:
frg = ""
text.append(frg)
line = "{} ({}-{})".format(*text)
line = "{} ({}; fw={})".format(*text)
ion_list.append(line)
return ion_list
......@@ -371,8 +374,8 @@ def load_drltables(parent, dataset, drls, drlspectrum):
filter="comma-separated values (*.csv)")[0]
if filename is not '':
names = []
start_masses = []
end_masses = []
masses = []
peak_widths = []
states = []
corrections = []
......@@ -392,7 +395,7 @@ def load_drltables(parent, dataset, drls, drlspectrum):
"Config file corrupted on line {},"
" cancelling request".format(i+1))
return
for j, k in enumerate((names, start_masses, end_masses,
for j, k in enumerate((names, masses, peak_widths,
states, *corrections)):
k.append(rawline[j])
for row in reversed(range(drls['pt'].rowCount())):
......@@ -402,8 +405,8 @@ def load_drltables(parent, dataset, drls, drlspectrum):
for i in range(len(names)):
add_line(dataset, drls, drlspectrum)
drls['pt'].item(i, 0).setText(names[i])
drls['pt'].item(i, 1).setText(start_masses[i])
drls['pt'].item(i, 2).setText(end_masses[i])
drls['pt'].item(i, 1).setText(masses[i])
drls['pt'].item(i, 2).setText(peak_widths[i])
# and after that the daughter table
drls['cors'].setValue(int(1 + (len(names) / 2)))
for i in range(len(names)):
......@@ -427,7 +430,7 @@ def save_drlconfig(drls, parent, exp_f_name=None):
i+1, i+1))
cortext = ", ".join(corlist)
expf = open(exp_f_name, 'w')
expf.write("#ion_name, start m/z, end m/z, visible,"
expf.write("#ion_name, m/z, peak_width, visible,"
"{}\n".format(cortext))
for row in range(drls['pt'].rowCount()):
vals = []
......@@ -663,7 +666,7 @@ def main_window(parent, ds, filename, cache):
dcolums.append("corrected for ({})".format(i+1))
dcolums.append("factor ({})".format(i+1))
drls['dt'] = iontable(dcolums)
drls['pt'] = iontable(["Name", "start (m/z)", "end (m/z)",
drls['pt'] = iontable(["Name", "Mass (m/z)", "Peak width",
"profile"])
#TODO: DIRTY, DIRTY, DIRTY !!! do it nicer when I'll know how i want it
for n in range(drls['dt'].columnCount()):
......
Supports Markdown
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