def initialize(self): """ Initialize Config, DataContainer, and Peaks :return: None """ self.config = unidecstructure.UniDecConfig() self.clear_history() self.config.initialize_system_paths() self.reset_config() self.data = unidecstructure.DataContainer() self.pks = peakstructure.Peaks()
def __init__(self, parent, data_list, config=None, yvals=None, pks=None, value=None, directory=None): """ Creates a window for visualizing high-mass mass defects. :param parent: Passed to wx.Frame :param data_list: List of mass distribution data. :param config: UniDecConfig object :param yvals: List of titles for each mass distribution in data_list :param pks: Peaks object :param value: Kendrick reference mass (default is 760.076, the mass of POPC) :param directory: Directory to save files to (default is os.getcwd()) :return: None """ wx.Frame.__init__(self, parent, title="Mass Defect") # ,size=(-1,-1)) # Setup initial values if directory is None: self.directory = os.getcwd() else: self.directory = directory self.parent = parent self.m0 = deepcopy(value) if self.m0 is None: self.m0 = 760.076 if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() self.config.discreteplot = 0 self.config.cmap = u"jet" self.config.peakcmap = u"rainbow" self.config.separation = 0.025 else: self.config = config self.config.publicationmode = 0 self.pos = -1 self.yvals = yvals self.ylab = "Normalized Mass Defect" if self.config.defectparams is not None: p = self.config.defectparams self.nbins = p[0] self.transformmode = p[1] self.centermode = p[2] self.xtype = p[3] else: self.nbins = 50 self.transformmode = 1 self.centermode = 1 self.xtype = 0 self.factor = 1 self.xlab = "" self.outfname = os.path.splitext(self.config.filename)[0] if self.outfname is not "": self.outfname += "_" try: self.datalist = [data_list[0]] except: self.datalist = data_list[0] for i in range(1, len(data_list)): self.datalist.append(ud.mergedata(data_list[0], data_list[i])) self.datalist = np.array(self.datalist) if self.yvals is not None: try: self.yvals = np.array(self.yvals, dtype="float") except: self.yvals = np.arange(0, len(self.datalist)) self.datasum = np.transpose( [self.datalist[0, :, 0], np.sum(self.datalist[:, :, 1], axis=0)]) print("Data list shape:", self.datalist.shape) # Make the menu filemenu = wx.Menu() if self.datalist.shape[0] > 1: extractwindow = filemenu.Append( wx.ID_ANY, "Extract Mass Defect Values", "Open Window to Extract Mass Defect Values") self.Bind(wx.EVT_MENU, self.on_extract_window, extractwindow) filemenu.AppendSeparator() menu_save_fig_png = filemenu.Append( wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") menu_save_fig_pdf = filemenu.Append( wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig_png) self.Bind(wx.EVT_MENU, self.on_save_fig_pdf, menu_save_fig_pdf) self.plotmenu = wx.Menu() self.menuaddline = self.plotmenu.Append( wx.ID_ANY, "Add Horizontal Line", "Add Horizontal Line at Specific Y Value") self.menufit = self.plotmenu.Append(wx.ID_ANY, "Fit Peaks", "Fit total mass defect peaks") self.menupeaks = self.plotmenu.Append(wx.ID_ANY, "Label Peaks", "Label peaks") self.Bind(wx.EVT_MENU, self.on_add_line, self.menuaddline) self.Bind(wx.EVT_MENU, self.on_fit, self.menufit) self.Bind(wx.EVT_MENU, self.on_label_peaks, self.menupeaks) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") menu_bar.Append(self.plotmenu, "Plot") self.SetMenuBar(menu_bar) # Setup the GUI panel = wx.Panel(self) self.plot1 = plot1d.Plot1d(panel) self.plot2 = plot2d.Plot2d(panel) self.plot3 = plot1d.Plot1d(panel) self.plot4 = plot1d.Plot1d(panel) if self.datalist.shape[0] > 1: self.flag2 = True self.plot5 = plot1d.Plot1d(panel) self.plot6 = plot2d.Plot2d(panel) else: self.flag2 = False self.plot5 = None self.plot6 = None sizer = wx.BoxSizer(wx.VERTICAL) plotsizer1 = wx.BoxSizer(wx.HORIZONTAL) plotsizer2 = wx.BoxSizer(wx.HORIZONTAL) plotsizer1.Add(self.plot1, 2, wx.EXPAND) plotsizer1.Add(self.plot4, 0, wx.EXPAND) plotsizer2.Add(self.plot2, 2, wx.EXPAND) plotsizer2.Add(self.plot3, 0, wx.EXPAND) if self.flag2: plotsizer1.Add(self.plot5, 0, wx.EXPAND) plotsizer2.Add(self.plot6, 0, wx.EXPAND) sizer.Add(plotsizer1, 1, wx.EXPAND) sizer.Add(plotsizer2, 1, wx.EXPAND) controlsizer = wx.BoxSizer(wx.HORIZONTAL) self.ctlm0 = wx.TextCtrl(panel, value=str(self.m0)) self.ctlwindow = wx.TextCtrl(panel, value=str(self.nbins)) controlsizer.Add(wx.StaticText(panel, label="Kendrick Mass"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlm0, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(wx.StaticText(panel, label="Number of Defect Bins"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlwindow, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) if len(data_list) > 1: label = "Back" else: label = "Replot" backbutton = wx.Button(panel, label=label) controlsizer2.Add(backbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_back, backbutton) if len(data_list) > 1: nextbutton = wx.Button(panel, label="Next") controlsizer2.Add(nextbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_next, nextbutton) totalbutton = wx.Button(panel, label="Total") controlsizer2.Add(totalbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.makeplottotal, totalbutton) else: if not ud.isempty(pks): self.pks = pks peaksbutton = wx.Button(panel, label="Plot Peaks") controlsizer2.Add(peaksbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_peaks, peaksbutton) self.radiobox = wx.RadioBox(panel, choices=["Integrate", "Interpolate"], label="Type of Transform") controlsizer.Add(self.radiobox, 0, wx.EXPAND) self.radiobox.SetSelection(self.transformmode) self.radiobox2 = wx.RadioBox(panel, choices=["-0.5:0.5", "0:1"], label="Range") controlsizer.Add(self.radiobox2, 0, wx.EXPAND) self.radiobox2.SetSelection(self.centermode) self.radiobox3 = wx.RadioBox(panel, choices=["Normalized", "Mass (Da)"], label="Mass Defect Units") controlsizer.Add(self.radiobox3, 0, wx.EXPAND) self.radiobox3.SetSelection(self.xtype) sizer.Add(controlsizer, 0, wx.EXPAND) sizer.Add(controlsizer2, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close) try: self.makeplottotal(0) except Exception as e: self.on_next(0) self.Centre() # self.MakeModal(True) self.Show(True) self.Raise()
def __init__(self, parent, data, config=None, directory=None): wx.Frame.__init__(self, parent, title="FFT Analysis") # Setup initial values if directory is None: self.directory = os.getcwd() else: self.directory = directory if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() self.config.discreteplot = 0 else: self.config = config self.config.publicationmode = 0 self.window_fwhm = 500 self.binsize = 0.5 self.wbin = 200 self.diffrange = [700, 800] self.rawdata = data self.rawdata[:, 1] /= np.amax(self.rawdata[:, 1]) self.xlims = [min(data[:, 0]), max(data[:, 0])] # Make the menu filemenu = wx.Menu() menu_save_fig_png = filemenu.Append(wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") menu_save_fig_pdf = filemenu.Append(wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig_png) self.Bind(wx.EVT_MENU, self.on_save_fig_pdf, menu_save_fig_pdf) self.plotmenu = wx.Menu() self.menuaddline = self.plotmenu.Append(wx.ID_ANY, "Add Horizontal Line", "Add Horizontal Line at Specific Y Value") self.Bind(wx.EVT_MENU, self.on_add_line, self.menuaddline) self.menupeaks = self.plotmenu.Append(wx.ID_ANY, "Get Peaks", "Get Peaks from Spectrum") self.Bind(wx.EVT_MENU, self.on_get_peaks, self.menupeaks) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") menu_bar.Append(self.plotmenu, "Plot") self.SetMenuBar(menu_bar) # Setup the GUI displaysize = wx.GetDisplaySize() panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) plotpanel1 = wx.BoxSizer(wx.HORIZONTAL) plotpanel2 = wx.BoxSizer(wx.HORIZONTAL) if displaysize[0] < 1700: figsize = (4, 3) else: figsize = (5, 4) self.plot1 = plot1d.Plot1d(panel, figsize=figsize) self.plot2 = plot2d.Plot2d(panel, figsize=figsize) self.plot3 = plot1d.Plot1d(panel, figsize=figsize) self.plot4 = plot1d.Plot1d(panel, figsize=figsize) plotpanel1.Add(self.plot1, 1, flag=wx.EXPAND) plotpanel2.Add(self.plot2, 1, flag=wx.EXPAND) plotpanel1.Add(self.plot3, 1, flag=wx.EXPAND) plotpanel2.Add(self.plot4, 1, flag=wx.EXPAND) self.plot1._axes = [0.1, 0.1, 0.64, 0.8] controlsizer = wx.BoxSizer(wx.HORIZONTAL) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) self.ctlfwhm = wx.TextCtrl(panel, value=str(self.window_fwhm)) self.ctlwbin = wx.TextCtrl(panel, value=str(self.wbin)) self.ctlbinsize = wx.TextCtrl(panel, value=str(self.binsize)) controlsizer.Add(wx.StaticText(panel, label=" Window FWHM:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlfwhm, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(wx.StaticText(panel, label=" Window every:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlwbin, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(wx.StaticText(panel, label=" Linearization Bin Size:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlbinsize, 0, wx.ALIGN_CENTER_VERTICAL) self.ctlmin = wx.TextCtrl(panel, value=str(self.diffrange[0])) self.ctlmax = wx.TextCtrl(panel, value=str(self.diffrange[1])) controlsizer2.Add(wx.StaticText(panel, label=" Min Difference:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(self.ctlmin, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(wx.StaticText(panel, label=" Max Difference:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(self.ctlmax, 0, wx.ALIGN_CENTER_VERTICAL) label = "Replot" replotbutton = wx.Button(panel, label=label) controlsizer2.Add(replotbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.makeplot, replotbutton) comparebutton = wx.Button(panel, label="Compare") controlsizer2.Add(comparebutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_compare_regions, comparebutton) self.compareclicks = 0 self.comparetext = wx.StaticText(panel, label="Click to activate compare mode") controlsizer2.Add(self.comparetext, 0, wx.ALIGN_CENTER_VERTICAL) sizer.Add(plotpanel1, 0, wx.EXPAND) sizer.Add(plotpanel2, 0, wx.EXPAND) sizer.Add(controlsizer, 0, wx.EXPAND) sizer.Add(controlsizer2, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close) self.makeplot() self.Centre() # self.MakeModal(True) self.Show(True)
def __init__( self, parent, datalist=None, filelist=None, config=None, ): """ """ wx.Frame.__init__(self, parent, title="Mass Defect Comparison") # ,size=(-1,-1)) file1 = None file2 = None if datalist is None: if filelist is None: if config is None: print( "ERROR: No data supplied to Mass Defect Compare Window" ) return else: self.config = config file1 = self.config.defectcomparefiles[0] file2 = self.config.defectcomparefiles[1] else: file1 = filelist[0] file2 = filelist[1] self.get_data(file1, file2) self.file1 = file1 self.file2 = file2 self.parent = parent if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() self.config.discreteplot = 0 self.config.cmap = u"jet" self.config.peakcmap = u"rainbow" self.config.separation = 0.025 else: self.config = config self.config.publicationmode = 0 self.pos = -1 self.ylab = "Normalized Mass Defect" if self.config.defectparams is not None: p = self.config.defectparams self.nbins = p[0] self.transformmode = p[1] self.centermode = p[2] self.xtype = p[3] else: self.nbins = 50 self.transformmode = 1 self.centermode = 1 self.xtype = 0 self.factor = 1 self.xlab = "" self.outfname = self.config.outfname if self.outfname != "": self.outfname += "_" self.total = False self.notchanged = False ''' # Make the menu filemenu = wx.Menu() if self.datalist.shape[0] > 1: extractwindow = filemenu.Append(wx.ID_ANY, "Extract Mass Defect Values", "Open Window to Extract Mass Defect Values") self.Bind(wx.EVT_MENU, self.on_extract_window, extractwindow) filemenu.AppendSeparator() menu_save_fig_png = filemenu.Append(wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") menu_save_fig_pdf = filemenu.Append(wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig_png) self.Bind(wx.EVT_MENU, self.on_save_fig_pdf, menu_save_fig_pdf) self.plotmenu = wx.Menu() self.menuaddline = self.plotmenu.Append(wx.ID_ANY, "Add Horizontal Line", "Add Horizontal Line at Specific Y Value") self.menuaddmultiline = self.plotmenu.Append(wx.ID_ANY, "Add Multiple Lines", "Add Multiple Horizontal Lines at Specific Y Values") self.menufit = self.plotmenu.Append(wx.ID_ANY, "Fit Peaks", "Fit total mass defect peaks") self.menupeaks = self.plotmenu.Append(wx.ID_ANY, "Label Peaks", "Label peaks") self.menulinreg = self.plotmenu.Append(wx.ID_ANY, "Linear Regression", "Linear Regression") self.menucom = self.plotmenu.Append(wx.ID_ANY, "Center of Mass", "Center of Mass") self.Bind(wx.EVT_MENU, self.on_add_line, self.menuaddline) self.Bind(wx.EVT_MENU, self.on_add_multilines, self.menuaddmultiline) self.Bind(wx.EVT_MENU, self.on_fit, self.menufit) self.Bind(wx.EVT_MENU, self.on_label_peaks, self.menupeaks) self.Bind(wx.EVT_MENU, self.on_linear_regression, self.menulinreg) self.Bind(wx.EVT_MENU, self.on_com, self.menucom) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") menu_bar.Append(self.plotmenu, "Plot") self.SetMenuBar(menu_bar)''' # Setup the GUI panel = wx.Panel(self) self.plot1 = plot2d.Plot2d(panel) self.plot2 = plot2d.Plot2d(panel) self.plot3 = ColorPlot.ColorPlot2D(panel) # self.plot4 = plot1d.Plot1d(panel) sizer = wx.BoxSizer(wx.VERTICAL) # plotsizer1 = wx.BoxSizer(wx.HORIZONTAL) plotsizer2 = wx.BoxSizer(wx.HORIZONTAL) # plotsizer1.Add(self.plot4, 0, wx.EXPAND) plotsizer2.Add(self.plot1, 2, wx.EXPAND) plotsizer2.Add(self.plot2, 2, wx.EXPAND) plotsizer2.Add(self.plot3, 2, wx.EXPAND) # sizer.Add(plotsizer1, 1, wx.EXPAND) sizer.Add(plotsizer2, 1, wx.EXPAND) controlsizer = wx.BoxSizer(wx.HORIZONTAL) self.ctlf1 = wx.TextCtrl(panel, value=str(self.file1), size=(1500, 25)) self.f1button = wx.Button(panel, label="File 1: ") self.Bind(wx.EVT_BUTTON, self.on_f1button, self.f1button) controlsizer.Add(self.f1button, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlf1, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1 = wx.BoxSizer(wx.HORIZONTAL) self.ctlf2 = wx.TextCtrl(panel, value=str(self.file2), size=(1500, 25)) self.f2button = wx.Button(panel, label="File 2: ") self.Bind(wx.EVT_BUTTON, self.on_f2button, self.f2button) controlsizer1.Add(self.f2button, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlf2, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) label = "Replot" ReplotButton = wx.Button(panel, label=label) controlsizer2.Add(ReplotButton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_replot, ReplotButton) ''' self.radiobox = wx.RadioBox(panel, choices=["Integrate", "Interpolate"], label="Type of Transform") controlsizer.Add(self.radiobox, 0, wx.EXPAND) self.radiobox.SetSelection(self.transformmode) self.radiobox2 = wx.RadioBox(panel, choices=["-0.5:0.5", "0:1"], label="Range") controlsizer.Add(self.radiobox2, 0, wx.EXPAND) self.radiobox2.SetSelection(self.centermode) self.radiobox3 = wx.RadioBox(panel, choices=["Normalized", "Mass (Da)"], label="Mass Defect Units") controlsizer.Add(self.radiobox3, 0, wx.EXPAND) self.radiobox3.SetSelection(self.xtype) ''' sizer.Add(controlsizer, 0, wx.EXPAND) sizer.Add(controlsizer1, 0, wx.EXPAND) sizer.Add(controlsizer2, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close) self.makeplot(0) self.Centre() # self.MakeModal(True) self.Show(True) self.Raise()
def __init__(self, parent, data_list, config=None, yvals=None, mode="1D", pks=None, pksmode="mz", *args, **kwargs): """ A simple window for animating mulitple 1D or 2D plots in a sequence. :param parent: Parent window. Passed to wx.Frame. :param data_list: List of data to be plotted :param config: UniDecConfig object :param yvals: Titles for the plots. :param mode: 1 = 1D plots, 2 = 2D plots :param args: :param kwargs: :return: None """ wx.Frame.__init__(self, parent, title="Plot Animations", size=(-1, -1)) # Initialize parameters if mode == "2D": self.mode = 2 else: self.mode = 1 if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() else: self.config = config self.datalist = data_list self.pks = pks self.pksmode = pksmode if self.pksmode == "mz": self.xlabel = "m/z (Th)" self.testkda = False elif self.pksmode == "CCS": self.xlabel = "CCS" self.testkda = False else: self.xlabel = "Mass (Da)" self.testkda = True self.yvals = yvals if self.yvals is None: self.yvals = list(range(0, len(data_list))) self.dim = 1 self.pos = -1 self.play = False self.animation = None # Create GUI # Make the menu filemenu = wx.Menu() menu_save_fig = filemenu.Append(wx.ID_ANY, "Save Figures", "Save all figures at selected path") self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") self.SetMenuBar(menu_bar) self.CreateStatusBar(2) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) if self.mode == 1: self.plot = plot1d.Plot1d(panel) else: self.plot = plot2d.Plot2d(panel) sizer.Add(self.plot, 0, wx.EXPAND) controlsizer = wx.BoxSizer(wx.HORIZONTAL) sb = wx.StaticBox(panel, label='Frame Rate (ms/frame)') sbs = wx.StaticBoxSizer(sb, orient=wx.VERTICAL) frmax = 2000 frmin = 1 self.frslider = wx.Slider( panel, wx.ID_ANY, 500, frmin, frmax, (30, 60), (250, -1), wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS) self.frslider.SetTickFreq(100) sbs.Add(self.frslider, 0, wx.EXPAND) self.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, self.update_framerate, self.frslider) controlsizer.Add(sbs, 0, wx.EXPAND) self.playbutton = wx.ToggleButton(panel, label="Play") self.nextbutton = wx.Button(panel, label="Next") self.backbutton = wx.Button(panel, label="Back") controlsizer.Add(self.backbutton, 0, wx.EXPAND) controlsizer.Add(self.playbutton, 0, wx.EXPAND) controlsizer.Add(self.nextbutton, 0, wx.EXPAND) self.Bind(wx.EVT_TOGGLEBUTTON, self.on_play, self.playbutton) self.Bind(wx.EVT_BUTTON, self.on_next, self.nextbutton) self.Bind(wx.EVT_BUTTON, self.on_back, self.backbutton) self.ctlautoscale = wx.CheckBox(panel, label="Autoscale") controlsizer.Add(self.ctlautoscale, 0, wx.EXPAND) if self.mode == 2: self.ctlautoscale.SetValue(True) sizer.Add(controlsizer, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close, self) self.init() self.Centre() self.Show(True)
def __init__(self, parent, datalist, xarray, yarray, config=None, xtype=0): wx.Frame.__init__(self, parent, title="Mass Defect Extractor") # ,size=(-1,-1)) self.xtype = xtype if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() self.config.discreteplot = 0 self.config.cmap = u"jet" self.config.peakcmap = u"rainbow" self.config.separation = 0.025 else: self.config = config # Setup initial values try: self.directory = parent.directory except: self.directory = os.getcwd() self.outfname = os.path.splitext(self.config.filename)[0] if self.outfname != "": self.outfname += "_" self.window = 0.05 self.data = datalist self.xdat = xarray self.ydat = yarray defaultexchoice = "Local Max" self.totgrid = [] self.grid = [] self.fitdats = None self.fits = None # Make the menu filemenu = wx.Menu() menu_oligomer_tools = filemenu.Append(wx.ID_ANY, "Generate from Masses", "Oligomer and Mass Tools") filemenu.AppendSeparator() menu_save_fig_png = filemenu.Append( wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") menu_save_fig_pdf = filemenu.Append( wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_oligomer_tools, menu_oligomer_tools) self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig_png) self.Bind(wx.EVT_MENU, self.on_save_fig_pdf, menu_save_fig_pdf) self.plotmenu = wx.Menu() self.menuaddline = self.plotmenu.Append( wx.ID_ANY, "Add Horizontal Line", "Add Horizontal Line at Specific Y Value") self.plotmenu.AppendSeparator() self.menutotal = self.plotmenu.Append( wx.ID_ANY, "Plot Total Bound vs. Unbound", "Assumes the first value is the unbound and each other is 1, 2, 3, and so on bound ligands." ) self.Bind(wx.EVT_MENU, self.on_add_line, self.menuaddline) self.Bind(wx.EVT_MENU, self.on_total, self.menutotal) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") menu_bar.Append(self.plotmenu, "Plot") self.SetMenuBar(menu_bar) # Setup the GUI panel = wx.Panel(self) self.plot1 = plot1d.Plot1d(panel) self.plot2 = plot2d.Plot2d(panel) self.plot5 = plot1d.Plot1d(panel) self.plot6 = plot2d.Plot2d(panel) sizer = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) sb = wx.StaticBox(panel, label='Set the Mass Defect Values to Extract') sbs = wx.StaticBoxSizer(sb, orient=wx.VERTICAL) importbutton = wx.Button(panel, label="Import from File") self.Bind(wx.EVT_BUTTON, self.on_import_masses, importbutton) clearbutt = wx.Button(panel, label="Clear List") self.Bind(wx.EVT_BUTTON, self.on_clear_masslist, clearbutt) addbutton = wx.Button(panel, label="Add Species") self.Bind(wx.EVT_BUTTON, self.on_add_mass, addbutton) sbs.Add(importbutton, 0, wx.EXPAND) sbs.Add(addbutton, 0, wx.EXPAND) self.masslistbox = masstools.MassListCtrlPanel( panel, columntitle="Mass Defect Value", size=(210, 320)) sbs.Add(wx.StaticText(panel, label="Mass Defect List")) sbs.Add(self.masslistbox) sbs.Add(clearbutt, 0, wx.EXPAND) # hbox.Add(sbs, 0, wx.EXPAND) plotsizer1 = wx.BoxSizer(wx.VERTICAL) plotsizer2 = wx.BoxSizer(wx.VERTICAL) plotsizer1.Add(self.plot1, 2, wx.EXPAND) plotsizer1.Add(self.plot2, 2, wx.EXPAND) plotsizer2.Add(self.plot5, 0, wx.EXPAND) plotsizer2.Add(self.plot6, 0, wx.EXPAND) hbox.Add(sbs, 0) hbox.Add(plotsizer1, 1, wx.EXPAND) hbox.Add(plotsizer2, 1, wx.EXPAND) sizer.Add(hbox, 1, wx.EXPAND) controlsizer = wx.BoxSizer(wx.HORIZONTAL) totalbutton = wx.Button(panel, label="Extract") controlsizer.Add(totalbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_extract, totalbutton) controlsizer.Add(wx.StaticText(panel, label=" How to extract: "), 0, wx.ALIGN_CENTER_VERTICAL) self.ctlextract = wx.ComboBox(panel, value=defaultexchoice, choices=list(extractchoices.values()), style=wx.CB_READONLY | wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlextract, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) self.ctlwindow = wx.TextCtrl(panel, value=str(self.window), size=(60, 23)) controlsizer.Add(wx.StaticText(panel, label="Window:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlwindow, 0, wx.ALIGN_CENTER_VERTICAL) self.ctlnorm = wx.RadioBox( panel, label="Extract Normalization", choices=["None", "Max", "Sum", "Peak Max", "Peak Sum"]) self.ctlnorm.SetSelection(2) # , majorDimension=3,style=wx.RA_SPECIFY_COLS) self.ctlnorm.SetSelection(2) controlsizer.Add(self.ctlnorm, 0, wx.ALIGN_CENTER_VERTICAL) fitbutton = wx.Button(panel, label="Fit") controlsizer.Add(fitbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_fit, fitbutton) self.ctlmaxshift = wx.TextCtrl(panel, value=str(0.05), size=(40, 23)) controlsizer.Add(wx.StaticText(panel, label="Max MD Shift:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlmaxshift, 0, wx.ALIGN_CENTER_VERTICAL) self.ctlshiftguess = wx.TextCtrl(panel, value=str("None"), size=(40, 23)) controlsizer.Add(wx.StaticText(panel, label="Shift Guess:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlshiftguess, 0, wx.ALIGN_CENTER_VERTICAL) self.ctlwidthguess = wx.TextCtrl(panel, value=str(0.05), size=(40, 23)) controlsizer.Add(wx.StaticText(panel, label="Width Guess:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlwidthguess, 0, wx.ALIGN_CENTER_VERTICAL) sizer.Add(controlsizer, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close) self.Centre() # self.MakeModal(True) self.Show(True) self.Raise() self.make_list_plots()
def __init__(self, parent, datalist, xvals=None, config=None, directory=None): wx.Frame.__init__(self, parent, title="FFT Analysis") # Setup initial values if directory is None: self.directory = os.getcwd() else: self.directory = directory if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() self.config.discreteplot = 0 else: self.config = config self.config.publicationmode = 0 self.binsize = 0.5 self.diffrange = [740, 770] if xvals is None: xvals = np.arange(0, len(datalist)) self.xvals = xvals self.datalist = np.array(datalist) mins = [] maxes = [] for d in self.datalist: d[:, 1] /= np.amax(d[:, 1]) mins.append(np.amin(d[:, 0])) maxes.append(np.amax(d[:, 0])) self.xlims = [min(mins), max(maxes)] self.colors = self.config.get_colors(len(self.datalist)) # Make the menu filemenu = wx.Menu() menu_save_fig_png = filemenu.Append( wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") menu_save_fig_pdf = filemenu.Append( wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig_png) self.Bind(wx.EVT_MENU, self.on_save_fig_pdf, menu_save_fig_pdf) self.plotmenu = wx.Menu() self.menuaddline = self.plotmenu.Append( wx.ID_ANY, "Add Horizontal Line", "Add Horizontal Line at Specific Y Value") self.Bind(wx.EVT_MENU, self.on_add_line, self.menuaddline) #self.menupeaks = self.plotmenu.Append(wx.ID_ANY, "Get Peaks", # "Get Peaks from Spectrum") #self.Bind(wx.EVT_MENU, self.on_get_peaks, self.menupeaks) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") menu_bar.Append(self.plotmenu, "Plot") self.SetMenuBar(menu_bar) # Setup the GUI displaysize = wx.GetDisplaySize() panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) plotpanel1 = wx.BoxSizer(wx.HORIZONTAL) plotpanel2 = wx.BoxSizer(wx.HORIZONTAL) if displaysize[0] < 1700: figsize = (4, 3) else: figsize = (5, 4) self.plot1 = plot1d.Plot1d(panel, figsize=figsize) self.plot2 = plot2d.Plot2d(panel, figsize=figsize) self.plot3 = plot1d.Plot1d(panel, figsize=figsize) self.plot4 = plot1d.Plot1d(panel, figsize=figsize) plotpanel1.Add(self.plot1, 1, flag=wx.EXPAND) plotpanel2.Add(self.plot2, 1, flag=wx.EXPAND) plotpanel1.Add(self.plot3, 1, flag=wx.EXPAND) plotpanel2.Add(self.plot4, 1, flag=wx.EXPAND) self.plot1._axes = [0.1, 0.1, 0.64, 0.8] controlsizer = wx.BoxSizer(wx.HORIZONTAL) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) self.ctlminmz = wx.TextCtrl(panel, value=str(self.xlims[0])) self.ctlmaxmz = wx.TextCtrl(panel, value=str(self.xlims[1])) self.ctlbinsize = wx.TextCtrl(panel, value=str(self.binsize)) controlsizer.Add(wx.StaticText(panel, label=" Min m/z:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlminmz, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(wx.StaticText(panel, label=" Max m/z:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlmaxmz, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add( wx.StaticText(panel, label=" Linearization Bin Size:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlbinsize, 0, wx.ALIGN_CENTER_VERTICAL) self.ctlmin = wx.TextCtrl(panel, value=str(self.diffrange[0])) self.ctlmax = wx.TextCtrl(panel, value=str(self.diffrange[1])) controlsizer2.Add(wx.StaticText(panel, label=" Min Difference:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(self.ctlmin, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(wx.StaticText(panel, label=" Max Difference:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(self.ctlmax, 0, wx.ALIGN_CENTER_VERTICAL) self.ctlsep = wx.TextCtrl(panel, value=str(self.config.separation)) controlsizer2.Add(wx.StaticText(panel, label=" Plot Separation:"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(self.ctlsep, 0, wx.ALIGN_CENTER_VERTICAL) label = "Replot" replotbutton = wx.Button(panel, label=label) controlsizer2.Add(replotbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.makeplot, replotbutton) sizer.Add(plotpanel1, 0, wx.EXPAND) sizer.Add(plotpanel2, 0, wx.EXPAND) sizer.Add(controlsizer, 0, wx.EXPAND) sizer.Add(controlsizer2, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close) self.makeplot() self.Centre() # self.MakeModal(True) self.Show(True)
def __init__(self, parent, inputdata=None, config=None, directory=""): wx.Frame.__init__(self, parent, title="iFAMS") # ,size=(-1,-1)) self.parent = parent self.directory = directory # Set up the config file if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() else: self.config = config # Make the menu filemenu = wx.Menu() menu_load_data = filemenu.Append(wx.ID_ANY, "Load Spectrum", "Loads the Mass Spectrum from a .txt file") menu_save_fig_png = filemenu.Append(wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") menu_save_fig_pdf = filemenu.Append(wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_load_spectrum, menu_load_data) self.Bind(wx.EVT_MENU, self.on_save_fig, menu_save_fig_png) self.Bind(wx.EVT_MENU, self.on_save_fig_pdf, menu_save_fig_pdf) self.plotmenu = wx.Menu() menu_bar = wx.MenuBar() menu_bar.Append(filemenu, "&File") menu_bar.Append(self.plotmenu, "Plot") self.SetMenuBar(menu_bar) # Setup the Plots panel = wx.Panel(self) self.plot1 = plot1d.Plot1d(panel) self.plot2 = plot1d.Plot1d(panel) self.plot3 = plot1d.Plot1d(panel) self.plot4 = plot1d.Plot1d(panel) sizer = wx.BoxSizer(wx.VERTICAL) plotsizer1 = wx.BoxSizer(wx.HORIZONTAL) plotsizer2 = wx.BoxSizer(wx.HORIZONTAL) plotsizer1.Add(self.plot1, 2, wx.EXPAND) plotsizer1.Add(self.plot4, 0, wx.EXPAND) plotsizer2.Add(self.plot2, 2, wx.EXPAND) plotsizer2.Add(self.plot3, 0, wx.EXPAND) sizer.Add(plotsizer1, 1, wx.EXPAND) sizer.Add(plotsizer2, 1, wx.EXPAND) controlsizer = wx.BoxSizer(wx.HORIZONTAL) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) controlsizer3 = wx.BoxSizer(wx.HORIZONTAL) controlsizer4 = wx.BoxSizer(wx.HORIZONTAL) controlsizer5 = wx.BoxSizer(wx.HORIZONTAL) # Set up the controls self.ctlm0 = wx.TextCtrl(panel, value=str(0)) self.ctlwindow = wx.TextCtrl(panel, value=str(0)) self.ctlwindow1 = wx.TextCtrl(panel, value=str(0)) self.zerodata = wx.TextCtrl(panel, value=str(0)) self.overtone = wx.TextCtrl(panel, value=str(0)) self.harmavg = wx.TextCtrl(panel, value=str(0)) self.lowcharge = wx.TextCtrl(panel, value=str(0)) self.highcharge = wx.TextCtrl(panel, value=str(0)) self.mansub = wx.TextCtrl(panel, value=str(0)) controlsizer2.Add(wx.StaticText(panel, label="Minimum Frequency"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(self.ctlm0, 0, wx.ALIGN_CENTER_VERTICAL) controlsizer2.Add(wx.StaticText(panel, label="Minimum Height"), 0, wx.ALIGN_CENTER_VERTICAL) 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) recalcbutton = wx.Button(panel, label="Recalc. Maxima Finder") controlsizer2.Add(recalcbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_calc, recalcbutton) iFAMSbutton = wx.Button(panel, label="Run iFAMS analysis") controlsizer.Add(iFAMSbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_SubAndCharCalc, iFAMSbutton) Filbutton = wx.Button(panel, label="Fourier Filter") controlsizer4.Add(Filbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_fourier_fil, Filbutton) havgbutton = wx.Button(panel, label="Harmonic Average") controlsizer3.Add(havgbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_harm_average, havgbutton) self.realdatasel = wx.CheckBox(panel, label="plot real data") controlsizer.Add(self.realdatasel, 0, wx.EXPAND) self.Bind(wx.EVT_CHECKBOX, self.onChecked) mancalcbutton = wx.Button(panel, label="Man Calc Subunit and Charge") controlsizer5.Add(mancalcbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_man_calc, mancalcbutton) sizer.Add(controlsizer, 0, wx.EXPAND) sizer.Add(controlsizer2, 0, wx.EXPAND) sizer.Add(controlsizer3, 0, wx.EXPAND) sizer.Add(controlsizer4, 0, wx.EXPAND) sizer.Add(controlsizer5, 0, wx.EXPAND) panel.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_CLOSE, self.on_close) self.Centre() # self.MakeModal(True) self.Show(True) self.Raise() if inputdata is not None: self.data = inputdata self.makeplot()
def __init__(self, parent, data, pks, config=None): wx.Frame.__init__(self, parent, title="Subtract and Divide Tools", size=(1100, 600)) # ,size=(-1,-1)) self.parent = parent self.div = 760 self.sub = 44088 self.data = data self.pks = pks self.avgs = None self.nums = None if config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() else: self.config = config self.sub = config.molig try: self.masses = [] for p in self.pks.peaks: if p.ignore == 0: self.masses.append(p.mass) defaultsub = np.amin(self.masses) except: self.masses = None defaultsub = 44088 self.sub = defaultsub self.panel = wx.Panel(self) self.plot1 = plot1d.Plot1d(self.panel) self.plot2 = plot1d.Plot1d(self.panel) self.ctlsub = wx.TextCtrl(self.panel, value=str(self.sub)) self.ctldiv = wx.TextCtrl(self.panel, value=str(self.div)) self.ctlresult = wx.TextCtrl(self.panel, value="") self.ctltype = wx.RadioBox(self.panel, label="X-axis", choices=["Mass", "Number"]) self.replotbutton = wx.Button(self.panel, -1, "Replot") self.sizer = wx.BoxSizer(wx.VERTICAL) s1 = wx.BoxSizer(wx.HORIZONTAL) s1.Add(self.plot1, 1, wx.GROW) s1.Add(self.plot2, 1, wx.GROW) self.sizer.Add(s1, 1) s2 = wx.BoxSizer(wx.HORIZONTAL) s2.Add(wx.StaticText(self.panel, label=" Subtract (Da): "), flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(self.ctlsub, 0, flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(wx.StaticText(self.panel, label=" Divide (Da): "), flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(self.ctldiv, 0, flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(self.ctltype, 0, flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(self.replotbutton, 0, flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(wx.StaticText(self.panel, label=" Result (Da): "), flag=wx.ALIGN_CENTER_VERTICAL) s2.Add(self.ctlresult, 0, flag=wx.ALIGN_CENTER_VERTICAL) self.sizer.Add(s2, 0) self.Bind(wx.EVT_BUTTON, self.replot, self.replotbutton) self.Bind(wx.EVT_RADIOBOX, self.change_type, self.ctltype) self.panel.SetSizer(self.sizer) self.panel.Fit() self.Show(True) self.replot()
def __init__(self, parent, data_list, config=None, yvals=None, directory=None, header=None, params=None): """ Create wx.Frame and initialzie components :param parent: Parent window or panel passed to wx.Frame :param data_list: Input data for extraction in a list of arrays (N x 2) :param config: UniDecConfig object. If None, will use defaults. :param yvals: Position values for corresponding data_list elements. For plots, these become the titles. For the Weighted-Average-of-Position (WAP) these are the position values. :param directory: Directory for saving files. Default is current working directory. :param header: Header for files that are written. Default is "Extract" :param params: List of 8 values that define the parameters for extraction. 0=mass 0 1=mass 1 2=mass 2 3=minimum oligomeric state of mass 1 4=maximum oligomeric state of mass 1 5=minimum oligomeric state of mass 2 6=maximum oligomeric state of mass 2 7=Error window for finding intensity value masses = m0 + m1 * range(min m1, max m1 +1) + m2 * range(min m2, max m2 +1) :return: None """ wx.Frame.__init__(self, parent, title="2D Grid Extraction", size=(-1, -1)) # Make Menu self.filemenu = wx.Menu() self.menuSaveFigPNG = self.filemenu.Append(wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") self.menuSaveFigPDF = self.filemenu.Append(wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_save_fig, self.menuSaveFigPNG) self.Bind(wx.EVT_MENU, self.on_save_figPDF, self.menuSaveFigPDF) self.plotmenu = wx.Menu() self.menufit = self.plotmenu.Append(wx.ID_ANY, "Fit Gaussians", "Fit total distribution to a series of Gaussians") self.menufit2 = self.plotmenu.Append(wx.ID_ANY, "Fit Poisson", "Fit total distribution to a Poisson Distribution") self.menufit3 = self.plotmenu.Append(wx.ID_ANY, "Fit Binomial", "Fit total distribution to a Binomial Distribution") self.menufit4 = self.plotmenu.Append(wx.ID_ANY, "Fit Multiple Poissons", "Fit total distribution to multiple Poisson distributions") self.Bind(wx.EVT_MENU, self.on_fit, self.menufit) self.Bind(wx.EVT_MENU, self.on_fit2, self.menufit2) self.Bind(wx.EVT_MENU, self.on_fit3, self.menufit3) self.Bind(wx.EVT_MENU, self.on_fit4, self.menufit4) self.menuBar = wx.MenuBar() self.menuBar.Append(self.filemenu, "&File") self.menuBar.Append(self.plotmenu, "Plot") self.SetMenuBar(self.menuBar) # Initialize Parameters if config is None: # Default UniDecConfig object self.config = unidecstructure.UniDecConfig() self.config.initialize() else: self.config = config if directory is None: self.directory = os.getcwd() else: self.directory = directory if header is None: self.header = "Extract" else: self.header = header if params is None: self.params = [98868, 760.076, 22044, 0, 90, 0, 2, 0] self.params = [0, 4493, 678, 1, 20, 0, 30, 10] else: self.params = params self.datalist = data_list self.dlen = len(data_list) self.pos = -1 self.yvals = np.array(yvals).astype(np.float) if ud.isempty(yvals): self.yvals = np.arange(0, len(data_list)) self.storediscrete = deepcopy(self.config.discreteplot) # Setup GUI panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) self.plot1 = plot1d.Plot1d(panel) self.plot2 = plot2d.Plot2d(panel) sizer.Add(self.plot1, 1, wx.EXPAND) sizer.Add(self.plot2, 1, wx.EXPAND) controlsizer = wx.BoxSizer(wx.HORIZONTAL) controlsizer1 = wx.BoxSizer(wx.HORIZONTAL) self.ctlm0 = wx.TextCtrl(panel, value=str(self.params[0])) self.ctlm1 = wx.TextCtrl(panel, value=str(self.params[1])) self.ctlm2 = wx.TextCtrl(panel, value=str(self.params[2])) self.ctlm1min = wx.TextCtrl(panel, value=str(self.params[3])) self.ctlm1max = wx.TextCtrl(panel, value=str(self.params[4])) self.ctlm2min = wx.TextCtrl(panel, value=str(self.params[5])) self.ctlm2max = wx.TextCtrl(panel, value=str(self.params[6])) self.ctlwindow = wx.TextCtrl(panel, value=str(self.params[7])) controlsizer.Add(wx.StaticText(panel, label="Mass 0"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlm0, 0, wx.EXPAND) controlsizer.Add(wx.StaticText(panel, label="Mass 1"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlm1, 0, wx.EXPAND) controlsizer.Add(wx.StaticText(panel, label="Mass 2"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlm2, 0, wx.EXPAND) controlsizer.Add(wx.StaticText(panel, label="Mass Window"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer.Add(self.ctlwindow, 0, wx.EXPAND) if self.dlen > 1: self.ctlnorm = wx.CheckBox(panel, label="Normalize") controlsizer.Add(self.ctlnorm, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Mass 1 Min #"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm1min, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Mass 1 Max #"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm1max, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Mass 2 Min #"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm2min, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Mass 2 Max #"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm2max, 0, wx.EXPAND) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) backbutton = wx.Button(panel, label="Back") nextbutton = wx.Button(panel, label="Next") if self.dlen > 1: totalbutton = wx.Button(panel, label="Total") else: totalbutton = wx.Button(panel, label="Replot") #wapbutton = wx.Button(panel, label="WAP") if self.dlen > 1: controlsizer2.Add(backbutton, 0, wx.EXPAND) controlsizer2.Add(nextbutton, 0, wx.EXPAND) controlsizer2.Add(totalbutton, 0, wx.EXPAND) #if self.dlen > 1: #controlsizer2.Add(wapbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.on_back, backbutton) self.Bind(wx.EVT_BUTTON, self.on_next, nextbutton) self.Bind(wx.EVT_BUTTON, self.on_total, totalbutton) #self.Bind(wx.EVT_BUTTON, self.on_wap, wapbutton) sizer.Add(controlsizer, 0, wx.EXPAND) sizer.Add(controlsizer1, 0, wx.EXPAND) sizer.Add(controlsizer2, 0, wx.EXPAND) self.Bind(wx.EVT_CLOSE, self.on_close, self) panel.SetSizer(sizer) sizer.Fit(self) # Run initial extraction try: self.on_total(0) except Exception as e: try: self.on_next(0) except: pass print(e) self.Centre() self.Show(True) self.normflag = 1
def __init__(self, parent, data, config=None, directory=None): """ masses = m0 + m1 * range(min m1, max m1 +1) :return: None """ wx.Frame.__init__(self, parent, title="2D Grid Extraction", size=(-1, -1)) # Make Menu self.filemenu = wx.Menu() self.menuSaveFigPNG = self.filemenu.Append( wx.ID_ANY, "Save Figures as PNG", "Save all figures as PNG in central directory") self.menuSaveFigPDF = self.filemenu.Append( wx.ID_ANY, "Save Figures as PDF", "Save all figures as PDF in central directory") self.Bind(wx.EVT_MENU, self.on_save_fig, self.menuSaveFigPNG) self.Bind(wx.EVT_MENU, self.on_save_figPDF, self.menuSaveFigPDF) self.menuBar = wx.MenuBar() self.menuBar.Append(self.filemenu, "&File") self.SetMenuBar(self.menuBar) # Initialize Parameters self.data = data self.config = config if self.config is None: self.config = unidecstructure.UniDecConfig() self.config.initialize() self.config.cmap = u"viridis" if directory is None: self.directory = os.getcwd() else: if directory is None: self.directory = self.config.dirname if self.config.griddecon is None: self.params = [98868, 760.076, 0, 120, 1, 25, 0, 20, 3, 1] else: self.params = self.config.griddecon if config is not None: self.params[0] = self.config.oligomerlist[0][0] self.params[1] = self.config.oligomerlist[0][1] self.params[2] = self.config.oligomerlist[0][2] self.params[3] = self.config.oligomerlist[0][3] self.params[4] = self.config.startz self.params[5] = self.config.endz self.params[7] = self.config.mzsig self.params[8] = self.config.msig self.params[9] = self.config.zzsig self.storediscrete = deepcopy(self.config.discreteplot) else: self.storediscrete = 1 # Setup GUI panel = wx.Panel(self) topsizer = wx.BoxSizer(wx.HORIZONTAL) sizer = wx.BoxSizer(wx.VERTICAL) self.plot1 = plot1d.Plot1d(panel) self.plot2 = plot2d.Plot2d(panel) sizer.Add(self.plot1, 1, wx.EXPAND) sizer.Add(self.plot2, 1, wx.EXPAND) controlsizer = wx.BoxSizer(wx.VERTICAL) controlsizer1 = wx.BoxSizer(wx.VERTICAL) self.ctlm0 = wx.TextCtrl(panel, value=str(self.params[0])) self.ctlm1 = wx.TextCtrl(panel, value=str(self.params[1])) self.ctlm1min = wx.TextCtrl(panel, value=str(self.params[2])) self.ctlm1max = wx.TextCtrl(panel, value=str(self.params[3])) self.ctlm2min = wx.TextCtrl(panel, value=str(self.params[4])) self.ctlm2max = wx.TextCtrl(panel, value=str(self.params[5])) self.ctlwindow = wx.TextCtrl(panel, value=str(self.params[6])) self.ctlfwhm = wx.TextCtrl(panel, value=str(self.params[7])) self.ctlmsig = wx.TextCtrl(panel, value=str(self.params[8])) self.ctlzzsig = wx.TextCtrl(panel, value=str(self.params[9])) controlsizer1.Add(wx.StaticText(panel, label="Base Mass"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm0, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Monomer Mass"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm1, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Mass Window"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlwindow, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Monomer Min #"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm1min, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Monomer Max #"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm1max, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Minimum Charge State"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm2min, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Maximum Charge State"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlm2max, 0, wx.EXPAND) controlsizer1.Add( wx.StaticText(panel, label="Peak Full Width at Half Max"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlfwhm, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Mass Filter Width"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlmsig, 0, wx.EXPAND) controlsizer1.Add(wx.StaticText(panel, label="Charge Filter Width"), 0, wx.ALIGN_CENTER_VERTICAL) controlsizer1.Add(self.ctlzzsig, 0, wx.EXPAND) controlsizer2 = wx.BoxSizer(wx.HORIZONTAL) extractbutton = wx.Button(panel, label="Extract") deconbutton = wx.Button(panel, label="Deconvolute") controlsizer2.Add(extractbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.extract, extractbutton) controlsizer2.Add(deconbutton, 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.deconvolve, deconbutton) controlsizer.Add(controlsizer1, 0, wx.EXPAND) controlsizer.Add(controlsizer2, 0, wx.EXPAND) topsizer.Add(sizer, 0, wx.EXPAND) topsizer.Add(controlsizer, 1, wx.EXPAND) self.Bind(wx.EVT_CLOSE, self.on_close, self) panel.SetSizer(topsizer) topsizer.Fit(self) # Run initial extraction self.extract(0) #self.deconvolve(0) self.Centre() self.Show(True)