Skip to content

Commit

Permalink
Merge pull request #45 from michaelmarty/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
michaelmarty authored Jun 23, 2020
2 parents ee6a605 + eaa7cbe commit 6cf2c2e
Show file tree
Hide file tree
Showing 54 changed files with 1,308 additions and 363 deletions.
24 changes: 22 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,27 @@ __pycache__/
unidec_bin/Example Data/ADH_unidecfiles/ADH_peak_areas.dat
unidec_bin/Example Data/POPC_Nanodiscs_unidecfiles/POPC_Nanodiscs_1D_Mass_Defects.txt
unidec_bin/Example Data/POPC_Nanodiscs_unidecfiles/POPC_Nanodiscs_2D_Mass_Defects.txt
unidec_modules/thermo_reader/
unidec_modules/thermo_reader/greparam.py
unidec_bin/Presets/Marius/

MANIFEST.in
desktop.ini
setup.py
unidec_bin/Example Data/BSA_unidecfiles/BSA_Figure1.pdf
unidec_bin/Example Data/BSA_unidecfiles/BSA_Figure2.pdf
unidec_bin/Example Data/BSA_unidecfiles/BSA_Figure3.pdf
unidec_bin/Example Data/BSA_unidecfiles/BSA_Figure4.pdf
unidec_bin/Example Data/BSA_unidecfiles/BSA_Figure5.pdf
unidec_bin/Example Data/BSA_unidecfiles/BSA_Figure6.pdf
unidec_bin/Example Data/BSA_unidecfiles/BSA_manualfile.dat
unidec_bin/Example Data/BSA_unidecfiles/BSA_report.aux
unidec_bin/Example Data/BSA_unidecfiles/BSA_report.log
unidec_bin/Example Data/BSA_unidecfiles/BSA_report.pdf
unidec_bin/recent.txt
unidec_bin/Example Data/BSA_unidecfiles/BSA_chargepeaks.txt
unidec_bin/Example Data/POPC_Nanodiscs_unidecfiles/Extract_grid_2D_Extract.txt
unidec_bin/Example Data/POPC_Nanodiscs_unidecfiles/Extract_total_2D_Extract.txt
ExtractFull2D_Da.txt
extracts.txt
sums.txt
unidec_bin/Example Data/POPC_Nanodiscs_unidecfiles/POPC_Nanodiscs_chargepeaks.txt

123 changes: 83 additions & 40 deletions GUniDec.py

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion UniChrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ def on_unidec_run(self, e=None):
savefile = self.export_mz_file()
if self.udwin is None:
self.udwin = GUniDec.UniDecApp()
self.udwin.on_open_file(savefile, self.eng.dirname)
try:
self.udwin.on_open_file(savefile, self.eng.dirname)
except:
self.udwin = GUniDec.UniDecApp()
self.udwin.on_open_file(savefile, self.eng.dirname)
pass

def export_mz_file(self, e=None, append=None, directory=None):
Expand Down
111 changes: 102 additions & 9 deletions datacollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import matplotlib.cm as cm
from matplotlib.pyplot import colormaps
from matplotlib import rcParams

from matplotlib.patches import Rectangle
from pubsub import pub

import multiprocessing
from unidec_modules import UniFit, Extract2D, unidecstructure, PlotAnimations, plot1d, plot2d, miscwindows, \
MassDefects, nativez, IM_functions
MassDefects, nativez, IM_functions, DoubleDec
from unidec_modules.PlottingWindow import PlottingWindow
import unidec_modules.unidectools as ud
from unidec_modules.AutocorrWindow import AutocorrWindow
Expand Down Expand Up @@ -169,7 +169,7 @@ def get_list(self, fcmap='rainbow'):
class ListCtrlPanel(wx.Panel):
def __init__(self, parent, list_type="X", size=(200, 400)):
wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
id_value = wx.NewId()
id_value = wx.NewIdRef()
self.selection = []
self.list_type = list_type
self.parent=parent
Expand All @@ -186,11 +186,11 @@ def __init__(self, parent, list_type="X", size=(200, 400)):
self.SetAutoLayout(True)
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_right_click, self.list)

self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
self.popupID1 = wx.NewIdRef()
self.popupID2 = wx.NewIdRef()
if list_type == "Y":
self.popupID3 = wx.NewId()
self.popupID4 = wx.NewId()
self.popupID3 = wx.NewIdRef()
self.popupID4 = wx.NewIdRef()

self.Bind(wx.EVT_MENU, self.on_popup_one, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.on_popup_two, id=self.popupID2)
Expand Down Expand Up @@ -251,7 +251,7 @@ def clear_frame(self):
self.repaint()


datachoices = {0: "Raw Data", 1: "Processed Data", 2: "Zero Charge Mass Spectrum", 3: "CCS (Experimental)"}
datachoices = {0: "Raw Data", 1: "Processed Data", 2: "Zero Charge Mass Spectrum", 3: "CCS (Experimental)", 4: "DoubleDec (Experimental)"}
extractchoices = {0: "Height", 1: "Local Max", 2: "Area", 3: "Center of Mass", 4: "Local Max Position",
5: "Center of Mass 50%", 6: "Center of Mass 10%"}
extractlabels = {0: "Intensity", 1: "Intensity", 2: "Area", 3: "Mass", 4: "Mass", 5: "Mass", 6: "Mass"}
Expand Down Expand Up @@ -327,13 +327,19 @@ def __init__(self, parent, title, config=None, pks=None, *args, **kwargs):
self.menumsmsnorm = self.experimentalmenu.Append(wx.ID_ANY, "Normalize to MSMS",
"Normalizes mass deconvolutions to MS1 scan for variable 1 +/- variable 2")
self.Bind(wx.EVT_MENU, self.on_msms_norm, self.menumsmsnorm)
self.menudd = self.experimentalmenu.Append(wx.ID_ANY, "Batch DoubleDec",
"Run DoubleDec on All Files")
self.Bind(wx.EVT_MENU, self.on_doubledec, self.menudd)
self.menuautocorr = self.experimentalmenu.Append(wx.ID_ANY, "View Autocorrelation of Sum",
"Shows autocorelation plot of sum")
self.Bind(wx.EVT_MENU, self.on_autocorr, self.menuautocorr)
self.toolsmenu.AppendSeparator()
self.menuylabel = self.toolsmenu.Append(wx.ID_ANY, "Specify Var. 1 Label", "Adds Var. 1 axis label to plot")
self.Bind(wx.EVT_MENU, self.on_ylabel, self.menuylabel)

self.menuplotx = self.toolsmenu.Append(wx.ID_ANY, "Plot X Ranges", "Plot X Ranges")
self.Bind(wx.EVT_MENU, self.shade_plots, self.menuplotx)

self.toolsmenu.AppendSeparator()

### CMap drop down menu
Expand Down Expand Up @@ -528,8 +534,10 @@ def __init__(self, parent, title, config=None, pks=None, *args, **kwargs):
self.ylabel = ""
self.fcmap = "rainbow"
self.xcmap = "rainbow"
self.offsets = []
self.check_cmaps()
self.hdf5_file = ""
self.kernelfile=""
self.filetype = 0
self.update_set(0)
self.Centre()
Expand Down Expand Up @@ -828,6 +836,7 @@ def update_set(self, e):
self.ctlmin.SetValue(str(self.range[0]))
self.ctlmax.SetValue(str(self.range[1]))


def on_run(self, e, vals=None):
tstart = time.perf_counter()
self.update_get(e)
Expand Down Expand Up @@ -932,6 +941,14 @@ def on_run(self, e, vals=None):
data = np.loadtxt(filename)
self.xlabel = "CCS (A^2)"

elif self.datachoice == 4:
self.xlabel = "Mass (Da)"
filename = os.path.join(header + "_unidecfiles", subheader + "_massdd.txt")
if self.filetype == 1:
data = get_dataset(msdata, "mass_data_dd")
else:
data = np.loadtxt(filename)

if not ud.isempty(self.range):
bool1 = data[:, 0] >= self.range[0]
bool2 = data[:, 0] <= self.range[1]
Expand Down Expand Up @@ -961,7 +978,14 @@ def on_run(self, e, vals=None):
window = float(self.window)
except (ValueError, TypeError):
window = None
val = ud.data_extract(data, float(s), self.extractchoice, window=window)

if ";" not in s:
val = ud.data_extract(data, float(s), self.extractchoice, window=window)
else:
xs = s.split(';')
val = 0
for xval in xs:
val += ud.data_extract(data, float(xval), self.extractchoice, window=window)
xext.append(val)
self.extract.append(xext)
self.ypanel.list.populate(self.yvals, colors=ycolors)
Expand All @@ -988,6 +1012,40 @@ def on_run(self, e, vals=None):
hdf.close()
print("Extraction Complete")

def shade_plots(self, e):
self.update_get(e)
for i in range(0, len(self.xvals)):
color = self.xcolors[i]

s = self.xvals[i][0]
try:
window = float(self.window)
except (ValueError, TypeError):
window = None

if ";" not in s:
val = float(s)
self.make_shade_plot(val, window, color)
else:
xs = s.split(';')
val = 0
for xval in xs:
val += float(xval)
self.make_shade_plot(val, window, color)
self.plot1.repaint()

def make_shade_plot(self, val, window, color):
y0 = np.amin(self.data[0][:, 1])
ywidth = np.amax(self.data[0][:, 1]) - y0
if self.plot1.kdnorm == 1000:
val = val/self.plot1.kdnorm
window = window/self.plot1.kdnorm

print(val, window)
self.plot1.subplot1.add_patch(
Rectangle((val - window, y0), window * 2., ywidth, alpha=0.5, facecolor=color, edgecolor='black',
fill=True))

def make_grid_plots(self, e):
self.grid = np.array(self.grid)
if not ud.isempty(self.grid):
Expand Down Expand Up @@ -1298,6 +1356,41 @@ def on_msms_norm(self, e):
print(vals)
self.on_run(0, vals=vals)

def on_doubledec(self, e):
self.update_get(e)
if self.filetype == 1:
hdf = h5py.File(self.hdf5_file)
self.paths = []
self.headers = []
for k, l in enumerate(self.yvals):
if self.filetype == 1:
msdata = hdf.get(self.topname + "/" + str(l[0]))
filename = l[0]
header = os.path.splitext(filename)[0]
if self.localpath == 1 or not os.path.isabs(filename):
header = os.path.join(self.directory, header)
filename = os.path.join(self.directory, filename)
subheader = os.path.split(header)[1]

filename = os.path.join(header + "_unidecfiles", subheader + "_mass.txt")
if self.filetype == 1:
data = get_dataset(msdata, "mass_data")
else:
data = np.loadtxt(filename)

self.paths.append(filename)
self.headers.append(header)
print(self.paths)

dlg = wx.FileDialog(self, "Open Kernel Text File", self.directory, self.kernelfile, "*.txt")
if dlg.ShowModal() == wx.ID_OK:
self.kernelfile = dlg.GetPath()
dlg.Destroy()
print(self.kernelfile)
DoubleDec.batch_dd(self.paths, self.kernelfile)



def on_ylabel(self, e):
dlg = miscwindows.SingleInputDialog(self)
dlg.initialize_interface(title="Set Variable 1 Label", message="Variable 1 axis label:", defaultvalue="")
Expand Down
24 changes: 12 additions & 12 deletions iFAMS/wxiFAMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ def __init__(self, parent, inputdata=None, config=None, directory=""):
controlsizer2.Add(self.ctlwindow, 0, wx.ALIGN_CENTER_VERTICAL)
controlsizer2.Add(wx.StaticText(panel, label="Delta"), 0, wx.ALIGN_CENTER_VERTICAL)
controlsizer2.Add(self.ctlwindow1, 0, wx.ALIGN_CENTER_VERTICAL)
controlsizer4.Add(wx.StaticText(panel, label="# of zero frequency data"), 0, wx.ALIGN_RIGHT)
controlsizer4.Add(self.zerodata, 0, wx.ALIGN_RIGHT)
controlsizer4.Add(wx.StaticText(panel, label="# of harmonics for filter"), 0, wx.ALIGN_RIGHT)
controlsizer4.Add(self.overtone, 0, wx.ALIGN_RIGHT)
controlsizer3.Add(wx.StaticText(panel, label="# of harmonics for average"), 0, wx.ALIGN_RIGHT)
controlsizer3.Add(self.harmavg, 0, wx.ALIGN_RIGHT)
controlsizer5.Add(wx.StaticText(panel, label="lowest charge state"), 0, wx.ALIGN_RIGHT)
controlsizer5.Add(self.lowcharge, 0, wx.ALIGN_RIGHT)
controlsizer5.Add(wx.StaticText(panel, label="highest charge state"), 0, wx.ALIGN_RIGHT)
controlsizer5.Add(self.highcharge, 0, wx.ALIGN_RIGHT)
controlsizer5.Add(wx.StaticText(panel, label="subunit mass"), 0, wx.ALIGN_RIGHT)
controlsizer5.Add(self.mansub, 0, wx.ALIGN_RIGHT)
controlsizer4.Add(wx.StaticText(panel, label="# of zero frequency data"), 0)
controlsizer4.Add(self.zerodata, 0)
controlsizer4.Add(wx.StaticText(panel, label="# of harmonics for filter"), 0)
controlsizer4.Add(self.overtone, 0)
controlsizer3.Add(wx.StaticText(panel, label="# of harmonics for average"), 0)
controlsizer3.Add(self.harmavg, 0)
controlsizer5.Add(wx.StaticText(panel, label="lowest charge state"), 0)
controlsizer5.Add(self.lowcharge, 0)
controlsizer5.Add(wx.StaticText(panel, label="highest charge state"), 0)
controlsizer5.Add(self.highcharge, 0)
controlsizer5.Add(wx.StaticText(panel, label="subunit mass"), 0)
controlsizer5.Add(self.mansub, 0)

recalcbutton = wx.Button(panel, label="Recalc. Maxima Finder")
controlsizer2.Add(recalcbutton, 0, wx.EXPAND)
Expand Down
18 changes: 9 additions & 9 deletions metaunidec/gui_elements/list_ctrls.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ def __init__(self, parent, pres, size=(200, 400)):
self.SetAutoLayout(True)
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_right_click, self.list)

self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
self.popupID3 = wx.NewId()
self.popupID4 = wx.NewId()
self.popupID5 = wx.NewId()
self.popupID6 = wx.NewId()
self.popupID7 = wx.NewId()
self.popupID10 = wx.NewId()
self.popupID11 = wx.NewId()
self.popupID1 = wx.NewIdRef()
self.popupID2 = wx.NewIdRef()
self.popupID3 = wx.NewIdRef()
self.popupID4 = wx.NewIdRef()
self.popupID5 = wx.NewIdRef()
self.popupID6 = wx.NewIdRef()
self.popupID7 = wx.NewIdRef()
self.popupID10 = wx.NewIdRef()
self.popupID11 = wx.NewIdRef()

self.Bind(wx.EVT_MENU, self.on_popup_one, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.on_popup_two, id=self.popupID2)
Expand Down
33 changes: 16 additions & 17 deletions metaunidec/gui_elements/ud_cont_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(self, parent, config, pres, panel, iconfile):
self.ctlminmz = wx.TextCtrl(panel1, value="", size=(50, -1))
self.ctlmaxmz = wx.TextCtrl(panel1, value="", size=(60, -1))
mzrange = wx.BoxSizer(wx.HORIZONTAL)
mzrange.Add(wx.StaticText(panel1, label="m/z: "), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
mzrange.Add(wx.StaticText(panel1, label="m/z: "), 0, wx.ALIGN_CENTER_VERTICAL)
mzrange.Add(self.ctlminmz)
mzrange.Add(wx.StaticText(panel1, label=" to "), 0, wx.ALIGN_CENTER_VERTICAL)
mzrange.Add(self.ctlmaxmz)
Expand Down Expand Up @@ -271,9 +271,9 @@ def __init__(self, parent, config, pres, panel, iconfile):
sbs = wx.StaticBoxSizer(sb, orient=wx.HORIZONTAL)
self.ctlminnativez = wx.TextCtrl(panel2b, value='', size=(75, -1))
self.ctlmaxnativez = wx.TextCtrl(panel2b, value='', size=(75, -1))
sbs.Add(self.ctlminnativez, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5)
sbs.Add(wx.StaticText(panel2b, label=' to '), 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
sbs.Add(self.ctlmaxnativez, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5)
sbs.Add(self.ctlminnativez, flag=wx.LEFT | wx.EXPAND, border=5)
sbs.Add(wx.StaticText(panel2b, label=' to '), 0, wx.EXPAND)
sbs.Add(self.ctlmaxnativez, flag=wx.LEFT | wx.EXPAND, border=5)
gbox2b.Add(sbs, (i, 0), span=(1, 2), flag=wx.EXPAND)
i += 1

Expand Down Expand Up @@ -397,16 +397,15 @@ def __init__(self, parent, config, pres, panel, iconfile):
self.ctlspeccm = wx.ComboBox(panel3b, wx.ID_ANY, style=wx.CB_READONLY)
self.parent.Bind(wx.EVT_COMBOBOX, self.on_spectra_color_change, self.ctlspeccm)

#for mp in self.config.cmaps2:
# for mp in self.config.cmaps2:
# self.ctl2dcm.Append(mp)
#for mp in self.config.cmaps:
# for mp in self.config.cmaps:
# self.ctlpeakcm.Append(mp)
# self.ctlspeccm.Append(mp)
self.ctl2dcm.AppendItems(self.config.cmaps2)
self.ctlpeakcm.AppendItems(self.config.cmaps)
self.ctlspeccm.AppendItems(self.config.cmaps)


i = 0
gbox3b.Add(wx.StaticText(panel3b, label='2D Color Map: '), (i, 0), flag=wx.ALIGN_CENTER_VERTICAL)
gbox3b.Add(self.ctl2dcm, (i, 1), flag=wx.ALIGN_CENTER_VERTICAL)
Expand Down Expand Up @@ -440,21 +439,21 @@ def __init__(self, parent, config, pres, panel, iconfile):
sbs2 = wx.StaticBoxSizer(sb2, orient=wx.HORIZONTAL)
self.ctlintlb = wx.TextCtrl(panel3b, value='', size=(75, -1))
self.ctlintub = wx.TextCtrl(panel3b, value='', size=(75, -1))
sbs2.Add(self.ctlintlb, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5)
sbs2.Add(wx.StaticText(panel3b, label=' to '), 0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
sbs2.Add(self.ctlintub, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5)
sbs2.Add(wx.StaticText(panel3b, label=' Da '), 0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
sbs2.Add(self.ctlintlb, flag=wx.LEFT | wx.EXPAND, border=5)
sbs2.Add(wx.StaticText(panel3b, label=' to '), 0, flag=wx.EXPAND)
sbs2.Add(self.ctlintub, flag=wx.LEFT | wx.EXPAND, border=5)
sbs2.Add(wx.StaticText(panel3b, label=' Da '), 0, flag=wx.EXPAND)
gbox3b.Add(sbs2, (i, 0), span=(1, 2), flag=wx.EXPAND)
i += 1

sb3 = wx.StaticBox(panel3b, label='Limits on # of Spectra')
sbs3 = wx.StaticBoxSizer(sb3, orient=wx.HORIZONTAL)
self.ctlcrossover = wx.TextCtrl(panel3b, value='', size=(75, -1))
self.ctlnumtot = wx.TextCtrl(panel3b, value='', size=(75, -1))
sbs3.Add(wx.StaticText(panel3b, label='If over'), 0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
sbs3.Add(self.ctlcrossover, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5)
sbs3.Add(wx.StaticText(panel3b, label=' plot only'), 0, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
sbs3.Add(self.ctlnumtot, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5)
sbs3.Add(wx.StaticText(panel3b, label='If over'), 0, flag=wx.EXPAND)
sbs3.Add(self.ctlcrossover, flag=wx.LEFT | wx.EXPAND, border=5)
sbs3.Add(wx.StaticText(panel3b, label=' plot only'), 0, flag=wx.EXPAND)
sbs3.Add(self.ctlnumtot, flag=wx.LEFT | wx.EXPAND, border=5)
gbox3b.Add(sbs3, (i, 0), span=(1, 2), flag=wx.EXPAND)
i += 1

Expand Down Expand Up @@ -966,9 +965,9 @@ def update_quick_controls(self, e=None):
except:
value = -1
psval = self.ctlpsfun.GetSelection()
#try:
# try:
# fwhm, psfun, mid = ud.auto_peak_width(self.pres.eng.data.data2)
#except:
# except:
# fwhm = -1
# psfun = -1
if value == 0:
Expand Down
Loading

0 comments on commit 6cf2c2e

Please sign in to comment.