Skip to content

Commit

Permalink
Merge pull request #30 from michaelmarty/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
michaelmarty authored Feb 25, 2019
2 parents 0a6d615 + 1bd2841 commit e0c13a7
Show file tree
Hide file tree
Showing 25 changed files with 728 additions and 127 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Scripts/MTM/test_UniDec.py
build.bat
metaunidec/test_MUD.py
unidec_bin/CDCReaderOld.exe
unidec_modules/NanodiscBuilder.py
unidec_modules/fft_test.py
unidec_src/UniDec/compilewin.bat
unidec_src/UniDec/UniDec.pdb
Expand All @@ -58,4 +57,11 @@ unidec_modules/Mass_Defect_Extracts.txt
unidec_modules/Mass_Defect_Grid.txt
unidec_modules/Total_1D_Mass_Defects.txt
unidec_modules/Total_2D_Mass_Defects.txt
unidec_modules/Mass_Defect_Extracts_xvals.txt
unidec_modules/Mass_Defect_Extracts_xvals.txt
unidec_modules/0_1D_Mass_Defects.txt
unidec_modules/0_2D_Mass_Defects.txt
unidec_modules/1_1D_Mass_Defects.txt
unidec_modules/1_2D_Mass_Defects.txt
unidec_modules/isolated_packages/spreadsheet.py
unidec_src/UniDec/UniDec.VC.VC.opendb

25 changes: 25 additions & 0 deletions GUniDec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,31 @@ def on_label_max_charge_states(self, e):
vlines=False, color=p.color)
self.view.plot4.repaint()

def on_label_avg_charge_states(self, e):
charges = np.arange(self.eng.config.startz, self.eng.config.endz + 1)
if self.eng.config.adductmass > 0:
sign = "+"
else:
sign = "-"

self.view.plot4.textremove()
for i in range(0, self.eng.pks.plen):
p = self.eng.pks.peaks[i]
if p.ignore == 0:
if (not ud.isempty(p.mztab)) and (not ud.isempty(p.mztab2)):
mztab = np.array(p.mztab)
avgcharge = ud.weighted_avg(charges, mztab[:, 1])
p.avgcharge = avgcharge
pos = (p.mass + self.eng.config.adductmass * avgcharge) / avgcharge

print("Mass:", p.mass, "Average Charge:", avgcharge)
mztab = ud.datachop(mztab, np.amin(self.eng.data.data2[:, 0]), np.amax(self.eng.data.data2[:, 0]))
self.view.plot4.plotadd(mztab[:, 0], mztab[:, 1], p.color)
self.view.plot4.addtext(sign + str(np.round(avgcharge, 2)), pos, np.amax(mztab[:, 1]) + 0.07,
vlines=True, color=p.color)
self.view.plot4.repaint()
self.view.peakpanel.add_data(self.eng.pks, show="avgcharge")

def on_plot_isotope_distribution(self, e=0):
for i in range(0, self.eng.pks.plen):
p = self.eng.pks.peaks[i]
Expand Down
30 changes: 19 additions & 11 deletions Launcher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
warnings.simplefilter(action="ignore",category=FutureWarning)

warnings.simplefilter(action="ignore", category=FutureWarning)

import wx
from unidec_modules.unidec_presbase import UniDecPres
Expand All @@ -13,6 +13,7 @@
from metaunidec.meta_import_wizard.meta_import_wizard import ImportWizard as HDF5Wizard
from metaunidec.ultrameta import DataCollector as UMDC
import wx.py as py
import sys


class UniDecLauncher(UniDecPres):
Expand All @@ -34,6 +35,12 @@ def __init__(self, *args, **kwargs):

def init(self, *args, **kwargs):
self.view = Lview(self)
self.view.Bind(wx.EVT_CLOSE, self.on_close)

def on_close(self, e=None):
self.quit_application()
self.view.Destroy()
sys.exit()


class Lview(wx.Frame):
Expand All @@ -51,13 +58,13 @@ def __init__(self, parent):
button6 = wx.Button(panel, -1, "HDF5 Import Wizard\n\nImport Data into HDF5 for MetaUniDec")
button7 = wx.Button(panel, -1, "UltraMeta Data Collector\n\nVisualize Multiple HDF5 Data Sets\nFit Trends")

sizer.Add(button1, (0,0),flag=wx.EXPAND)
sizer.Add(button2, (1,0),flag=wx.EXPAND)
sizer.Add(button3, (2,0),flag=wx.EXPAND)
sizer.Add(button4, (0,1),flag=wx.EXPAND)
sizer.Add(button1, (0, 0), flag=wx.EXPAND)
sizer.Add(button2, (1, 0), flag=wx.EXPAND)
sizer.Add(button3, (2, 0), flag=wx.EXPAND)
sizer.Add(button4, (0, 1), flag=wx.EXPAND)
sizer.Add(button6, (2, 1), flag=wx.EXPAND)
sizer.Add(button7, (1, 1), flag=wx.EXPAND)
sizer.Add(button5, (3,0),span=(1,2),flag=wx.EXPAND)
sizer.Add(button5, (3, 0), span=(1, 2), flag=wx.EXPAND)

self.Bind(wx.EVT_BUTTON, self.button1, button1)
self.Bind(wx.EVT_BUTTON, self.button2, button2)
Expand All @@ -78,7 +85,7 @@ def button1(self, e=None):
app = GUniDec.UniDecApp()
app.start()

def button2(self,e=None):
def button2(self, e=None):
print("Launching Data Collector")
app = wx.App(False)
frame = datacollector.DataCollector(None, "Collect Data")
Expand All @@ -91,12 +98,12 @@ def button3(self, e=None):
frame.Show()
app.MainLoop()

def button4(self,e=None):
def button4(self, e=None):
print("Launching MetaUniDec")
app = mudpres.UniDecApp()
app.start()

def button5(self,e=None):
def button5(self, e=None):
print("Launching Scripting Shell")
app = Shell()
app.start()
Expand All @@ -108,7 +115,7 @@ def button6(self, e=None):
frame.Show()
app.MainLoop()

def button7(self,e=None):
def button7(self, e=None):
print("Launching UltraMeta Data Collector")
app = wx.App(False)
frame = UMDC(None, "UltraMeta Data Collector")
Expand All @@ -123,12 +130,13 @@ def __init__(self, *args, **kwargs):

self.shellwindow = py.shell.ShellFrame(self.shell, title="UniDecShell").Show()

#self.shell.Execute('app=UniDecApp()')
# self.shell.Execute('app=UniDecApp()')
# self.shell.Execute('app.start()')
# self.shellwindow.Center()
# self.shell.setFocus()
self.__wx_app.MainLoop()


if __name__ == '__main__':
# app2 = Shell()
multiprocessing.freeze_support()
Expand Down
25 changes: 14 additions & 11 deletions datacollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def populate(self, listctrldata, colors=None):
self.SetItemData(index, i)
if colors is not None:
color = wx.Colour(int(round(colors[i][0] * 255)), int(round(colors[i][1] * 255)),
int(round(colors[i][2] * 255)) , alpha=255)
int(round(colors[i][2] * 255)), alpha=255)
self.SetItemBackgroundColour(index, col=color)

def clear_list(self):
Expand Down Expand Up @@ -154,7 +154,7 @@ def __init__(self, parent, list_type="X", size=(200, 400)):
wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
id_value = wx.NewId()
self.selection = []
self.list_type=list_type
self.list_type = list_type
sizer = wx.BoxSizer(wx.VERTICAL)
if list_type == "X":
self.list = XValueListCtrl(self, id_value, size=size, style=wx.LC_REPORT | wx.BORDER_NONE)
Expand Down Expand Up @@ -388,7 +388,8 @@ def __init__(self, parent, title, config=None, pks=None, *args, **kwargs):

self.runsizer = wx.BoxSizer(wx.HORIZONTAL)
self.runsizer.Add(wx.StaticText(self.panel, label=" What to extract: "), 0, wx.ALIGN_CENTER_VERTICAL)
self.ctldata = wx.ComboBox(self.panel, value="Raw Data", choices=list(datachoices.values()), style=wx.CB_READONLY)
self.ctldata = wx.ComboBox(self.panel, value="Raw Data", choices=list(datachoices.values()),
style=wx.CB_READONLY)
self.runsizer.Add(self.ctldata, 0, wx.EXPAND)

self.runsizer.Add(wx.StaticText(self.panel, label=" Range:"), 0, wx.ALIGN_CENTER_VERTICAL)
Expand All @@ -406,7 +407,8 @@ def __init__(self, parent, title, config=None, pks=None, *args, **kwargs):
self.ctlnorm2 = wx.CheckBox(self.panel, label="Normalize Extraction")
self.runsizer.Add(self.ctlnorm2, 0, wx.EXPAND)
self.runsizer.Add(wx.StaticText(self.panel, label=" How to extract: "), 0, wx.ALIGN_CENTER_VERTICAL)
self.ctlextract = wx.ComboBox(self.panel, value="Height", choices=list(extractchoices.values()), style=wx.CB_READONLY)
self.ctlextract = wx.ComboBox(self.panel, value="Height", choices=list(extractchoices.values()),
style=wx.CB_READONLY)
self.runsizer.Add(self.ctlextract, 0, wx.EXPAND)
self.runsizer.Add(wx.StaticText(self.panel, label=" Window:"), 0, wx.ALIGN_CENTER_VERTICAL)
self.ctlwindow = wx.TextCtrl(self.panel, value="", size=(50, 20))
Expand Down Expand Up @@ -743,7 +745,8 @@ def update_get(self, e):
def update_set(self, e):
self.ctlprotmodel.SetValue(
next((label for label, flag in list(modelchoices.items()) if flag == self.protflag), "test"))
self.ctlligmodel.SetValue(next((label for label, flag in list(modelchoices.items()) if flag == self.ligflag), "test"))
self.ctlligmodel.SetValue(
next((label for label, flag in list(modelchoices.items()) if flag == self.ligflag), "test"))
self.dirinput.SetValue(self.directory)
self.xpanel.list.populate(self.xvals)
self.ypanel.list.populate(self.yvals)
Expand Down Expand Up @@ -1020,12 +1023,12 @@ def on_kd_fit(self, e):
maxsites = int(self.maxsites)
except (ValueError, TypeError):
maxsites = 0
model = UniFit.KDmodel(self.numprot, self.numlig, np.transpose(self.extract),
self.yvals[:, 2].astype(np.float64),
model = UniFit.KDmodel(np.transpose(self.extract), self.yvals[:, 2].astype(np.float64),
self.yvals[:, 1].astype(np.float64), nodelist, os.path.join(self.directory, "fits"),
removeoutliers=outlierflag, plot1=self.plot2.subplot1, plot2=self.plot3.axes,
plot3=self.plot3h, bootnum=self.bootstrap, prot=self.protflag, lig=self.ligflag,
maxsites=maxsites)
numtotprot=self.numprot, numtotlig=self.numlig, removeoutliers=outlierflag,
plot1=self.plot2.subplot1,
plot2=self.plot3.axes, plot3=self.plot3h, bootnum=self.bootstrap, maxsites=maxsites,
prot=self.protflag, lig=self.ligflag)
try:
if self.bootstrap > 0:
np.savetxt(os.path.join(self.directory, "fits_boots.txt"), model.randfit)
Expand Down Expand Up @@ -1181,7 +1184,7 @@ def on_export(self, e):
print("Grid is empty")

def on_msms_norm(self, e):
dlg = wx.FileDialog(self, "Choose MS1 data file in x y list format", '', "", "*.*",)
dlg = wx.FileDialog(self, "Choose MS1 data file in x y list format", '', "", "*.*", )
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetFilename()
dirname = dlg.GetDirectory()
Expand Down
9 changes: 5 additions & 4 deletions metaunidec/gui_elements/ud_cont_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def __init__(self, parent, config, pres, panel, iconfile):
gbox2b.Add(sbs, (i, 0), span=(1, 2), flag=wx.EXPAND)
i += 1

self.ctlisotopemode = wx.CheckBox(panel2b, label="Isotope Mode")
#self.ctlisotopemode = wx.CheckBox(panel2b, label="Isotope Mode")
self.ctlisotopemode = wx.Choice(panel2b, -1, size=(100, -1), choices=self.config.isotopechoices)
gbox2b.Add(self.ctlisotopemode, (i, 0), flag=wx.ALIGN_CENTER_VERTICAL)

self.ctlmanualassign = wx.CheckBox(panel2b, label="Manual Mode")
Expand Down Expand Up @@ -435,7 +436,7 @@ def import_config_to_gui(self):
self.ctlmaxnativez.SetValue(str(self.config.nativezub))
self.ctlpoolflag.SetSelection(self.config.poolflag)
self.ctlmanualassign.SetValue(self.config.manualfileflag)
self.ctlisotopemode.SetValue(self.config.isotopemode)
self.ctlisotopemode.SetSelection(self.config.isotopemode)
self.ctldatanorm.SetValue(self.config.datanorm)
self.ctlorbimode.SetValue(self.config.orbimode)
# self.ctlbintype.SetSelection(int(self.config.linflag))
Expand Down Expand Up @@ -547,7 +548,7 @@ def export_gui_to_config(self, e=None):
self.config.crossover = ud.string_to_value(self.ctlcrossover.GetValue())
self.config.numtot = ud.string_to_value(self.ctlnumtot.GetValue())

self.config.isotopemode = int(self.ctlisotopemode.GetValue())
self.config.isotopemode = int(self.ctlisotopemode.GetSelection())
self.config.datanorm = int(self.ctldatanorm.GetValue())
self.config.orbimode = int(self.ctlorbimode.GetValue())
self.config.manualfileflag = int(self.ctlmanualassign.GetValue())
Expand Down Expand Up @@ -658,7 +659,7 @@ def setup_tool_tips(self):
self.ctlminnativez.SetToolTip(wx.ToolTip("Minimum offset from a native charge state"))
self.ctlmaxnativez.SetToolTip(wx.ToolTip("Maximum offset from a native charge state"))

self.ctlisotopemode.SetToolTip(wx.ToolTip("Use isotopic distributions in deconvolution"))
self.ctlisotopemode.SetToolTip(wx.ToolTip("Use isotopic distributions in deconvolution.\nOutput either monoisotopic or average masses."))
self.ctldatanorm.SetToolTip(wx.ToolTip("Normalize Data and Results"))
self.ctlorbimode.SetToolTip(wx.ToolTip("Scale the intensity by dividing by the charge state"))
self.ctlmanualassign.SetToolTip(wx.ToolTip("Use manual assignments. See Tools>Manual Assignment"))
Expand Down
4 changes: 2 additions & 2 deletions metaunidec/mudstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def import_grids(self):
grid3 = [grid2, grid]
self.massgrid = np.transpose(grid3)
except:
print("Mass Grid Warning:", grid.shape, sum.shape, len(grid)/len(sum))
print("Mass Grid Warning:", grid.shape, sum.shape)#, len(grid)/len(sum))
# MZ Space
axis = get_dataset(msdataset, "mz_axis")
sum = get_dataset(msdataset, "mz_sum")
Expand All @@ -124,7 +124,7 @@ def import_grids(self):
grid3 = [grid2, grid]
self.mzgrid = np.transpose(grid3)
except:
print("mz grid Warning:", grid.shape, sum.shape, len(grid)/len(sum))
print("mz grid Warning:", grid.shape, sum.shape)#, len(grid)/len(sum))
hdf.close()
return num

Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ The main GUI class is GUniDec.UniDecApp.

## Change Log

v.3.1.1

Expanded isotope mode to either output monoisotopic masses or average masses.

Added an experimental feature to plot average charge state for peaks in UniDec.

Bug fixes.

v.3.1.0

Added new parameter for Point Width Smooth.
Expand Down
1 change: 1 addition & 0 deletions unidec_bin/Presets/Nanodiscs/DMPC.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ numz 21
endz 25
startz 5
zzsig 1.0
psig 0
mzsig 10
psfun 0
discreteplot 0
Expand Down
1 change: 1 addition & 0 deletions unidec_bin/Presets/Nanodiscs/DMPG.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ numz 21
endz 25
startz 5
zzsig 1.0
psig 0
mzsig 10
psfun 0
discreteplot 0
Expand Down
Binary file modified unidec_bin/UniDec.exe
Binary file not shown.
14 changes: 9 additions & 5 deletions unidec_modules/MassDefectExtractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@


class MassDefectExtractorWindow(wx.Frame):
def __init__(self, parent, datalist, xarray, yarray, config=None):
def __init__(self, parent, datalist, xarray, yarray, config=None, xtype=0):
wx.Frame.__init__(self, parent, title="Mass Defect") # ,size=(-1,-1))

self.xtype=xtype
if config is None:
self.config = unidecstructure.UniDecConfig()
self.config.initialize()
Expand Down Expand Up @@ -182,14 +183,12 @@ def on_extract(self, e=None):
except Exception as e:
print("Failed Data Export Extracts", e)
self.make_ext_plots()
#self.fill_grid()
# self.fill_grid()

def fill_grid(self):
print(self.grid.shape)
self.ss = spreadsheet.Spreadsheet(len(self.mdlist), len(self.ydat) + 1)



def make_ext_plots(self):
self.colormap = cm.get_cmap(ud.smartdecode(self.config.peakcmap), len(self.mdlist))
if self.colormap is None:
Expand Down Expand Up @@ -272,7 +271,7 @@ def on_add_line(self, e):
"""

for x in self.mdlist:
#print(x)
# print(x)
try:
ylim = self.plot6.subplot1.get_ylim()
self.plot6.subplot1.plot((x, x), (ylim[0], ylim[1]), color=self.plot2.tickcolor)
Expand Down Expand Up @@ -302,6 +301,11 @@ def on_oligomer_tools(self, e):
else:
nominalkmass = np.round(kmass)
kmdefect = kmass - nominalkmass
if self.xtype == 0:
factor = 1.0
else:
factor = self.config.kendrickmass
kmdefect *= factor
print(kmdefect)
self.masslistbox.list.populate(kmdefect)

Expand Down
Loading

0 comments on commit e0c13a7

Please sign in to comment.