def _get_openfun(self, filepath, mode): '''Returns the file opening function for the document''' self.set_path(filepath, mode) if mode == 'add': return partial(self.tree().io.add_files, filepath) elif mode == 'replace': return partial(self.tree().io.open_files, filepath)
def _get_openfun(self, filepath, mode): '''Returns the file opening function for the document''' self.set_path(filepath, mode) if mode == 'add': return partial(self.tree().io.add_files, filepath) elif mode == 'replace': return partial(self.tree().io.open_files, filepath)
def _find_candidate(self, candidate, name, version): '''Finds the candidate release worker from the candidates list''' asset_id = candidate['id'] url = self._release_url('assets', asset_id) cls = self._get_binary(url) func = partial(self._process_buffer, name, cls.buf, config.APP_DATA, version) cls.finished.connect(partial(cls.fin, func), self._queued) return cls
def saveas(self, title=SAVE_TABLE): '''Saves the current database to a new path''' path = self.getpath(qtio.getsavefile, title) if path: self.savedialog.show() self.app.processEvents() fun = partial(self.tabs.saveas, path) connect = partial(setattr, self, path) self.threading(fun, self.savedialog, connect)
def switch_profile(self): '''Switches the profile upon changing the selected QComboBox''' profile = self.profile fun = partial(self.engine_qcombo.set_current_text, profile.engine) self.engine_qcombo.block_once(fun) numberfun = partial(self.number.setValue, len(profile.populations)) self.number.block_once(numberfun) self.crosslinkerbox.reset_view() self.table.reset_view()
def __plot(self, group, indexes=None): '''Plots a 2D x/y chromatogram and adds the image to the layout''' widget = transition_canvas.QtGraphWidget(self.parent(), group, indexes) self.parent().visualizer_view.add_widget(widget) # bind signals recalculate = partial(self.parent().updater.recalculate, group) widget.picked.connect(recalculate) store = partial(self.parent().updater.store, group) widget.dropped.connect(store)
def __plot(self, group, indexes=None): '''Plots a 2D x/y chromatogram and adds the image to the layout''' widget = transition_canvas.QtGraphWidget(self.parent(), group, indexes) self.parent().visualizer_view.add_widget(widget) # bind signals recalculate = partial(self.parent().updater.recalculate, group) widget.picked.connect(recalculate) store = partial(self.parent().updater.store, group) widget.dropped.connect(store)
def set_keybindings(self): '''Bind keyboard shortcuts for traversing the QTreeView''' shortcuts = OrderedDict() shortcuts['L'] = partial(self.expand, select=True) shortcuts['Shift+L'] = partial(self.expand, select=True, recurse=True) shortcuts['Ctrl+Shift+L'] = self.expand shortcuts['H'] = partial(self.collapse, select=True) shortcuts['Shift+H'] = partial(self.collapse, select=True, recurse=True) shortcuts['Ctrl+Shift+H'] = self.collapse self.parent().bind_keys(shortcuts)
def edit(self, menu): '''Adds all the edit entries to the widgets''' items = OrderedDict() items['&Sort'] = OrderedDict() items['&Sort']['&Peptide'] = { 'statusTip': 'Sort Transitions by Peptide', 'triggered': partial(self.parent.nodes.sort, 'peptide') } items['&Sort']['&Retention Time'] = { 'statusTip': 'Sort Transitions by RT', 'triggered': partial(self.parent.nodes.sort, 'RT') } items['&Sort']['&Peptide Score'] = { 'statusTip': 'Sort Transitions by Peptide Score', 'triggered': partial(self.parent.nodes.sort, 'score') } items['&Sort']['&Expectation Value'] = { 'statusTip': 'Sort Transitions by EV', 'triggered': partial(self.parent.nodes.sort, 'EV') } items['&Sort']['&Mod Counts'] = { 'statusTip': 'Sort Transitions by mod counts', 'triggered': partial(self.parent.nodes.sort, 'Mod Count') } items[len(items)] = None # items['&Checkstate'] = OrderedDict() # items['&Checkstate']['&Item'] = { # 'statusTip': 'Toggle Item', # 'shortcut': 'Space', # 'triggered': self.parent.tree.toggle_item # } # items['&Checkstate']['&Children'] = { # 'statusTip': 'Toggle Children', # 'shortcut': 'Shift+Space', # 'triggered': self.parent.tree.toggle_children # } # # items[len(items)] = None # # items['&Annotations'] = { # 'statusTip': 'Edit Annotations', # 'shortcut': 'Ctrl+A', # 'triggered': self.parent.change_labels # } self.set_items(menu, items)
def edit(self, menu): '''Adds all the edit entries to the widgets''' items = OrderedDict() items['&Sort'] = OrderedDict() items['&Sort']['&Peptide'] = { 'statusTip': 'Sort Transitions by Peptide', 'triggered': partial(self.parent.nodes.sort, 'peptide') } items['&Sort']['&Retention Time'] = { 'statusTip': 'Sort Transitions by RT', 'triggered': partial(self.parent.nodes.sort, 'RT') } items['&Sort']['&Peptide Score'] = { 'statusTip': 'Sort Transitions by Peptide Score', 'triggered': partial(self.parent.nodes.sort, 'score') } items['&Sort']['&Expectation Value'] = { 'statusTip': 'Sort Transitions by EV', 'triggered': partial(self.parent.nodes.sort, 'EV') } items['&Sort']['&Mod Counts'] = { 'statusTip': 'Sort Transitions by mod counts', 'triggered': partial(self.parent.nodes.sort, 'Mod Count') } items[len(items)] = None # items['&Checkstate'] = OrderedDict() # items['&Checkstate']['&Item'] = { # 'statusTip': 'Toggle Item', # 'shortcut': 'Space', # 'triggered': self.parent.tree.toggle_item # } # items['&Checkstate']['&Children'] = { # 'statusTip': 'Toggle Children', # 'shortcut': 'Shift+Space', # 'triggered': self.parent.tree.toggle_children # } # # items[len(items)] = None # # items['&Annotations'] = { # 'statusTip': 'Edit Annotations', # 'shortcut': 'Ctrl+A', # 'triggered': self.parent.change_labels # } self.set_items(menu, items)
def set_keybindings(self): '''Bind keyboard shortcuts for traversing the QTreeView''' shortcuts = OrderedDict() shortcuts['L'] = partial(self.expand, select=True) shortcuts['Shift+L'] = partial(self.expand, select=True, recurse=True) shortcuts['Ctrl+Shift+L'] = self.expand shortcuts['H'] = partial(self.collapse, select=True) shortcuts['Shift+H'] = partial(self.collapse, select=True, recurse=True) shortcuts['Ctrl+Shift+H'] = self.collapse self.parent().bind_keys(shortcuts)
def get_menu_button(self, iconkey, cls, *args): '''Creates a menubutton to add to the current display''' icon = qt.IMAGES[iconkey] fun = partial(self.initchild, cls, *args) return widgets.Push(icon=icon, connect=fun, parent=self)
def _transitions(self, filepath): '''Save function for Transitions documents''' document = self.worker.transitions indexes = range(len(document)) fun = partial(spectra.write_file, document, filepath, indexes) self.threading(fun, self.savedialog)
def _setup_run(self): '''Setup click button to execute running thread''' layout = self.add_layout(QtGui.QHBoxLayout) slot = partial(self.launch, running.RunDiscoverer, self.quantitative) run = widgets.ClickButton("Run", slot) layout.addWidget(run)
def clear(self): '''Clears the data from the visible table''' self.table.block_once(self.table.clearContents) for column_values in self.table.model().values(): del column_values[:] self.table.block_once(partial(self.table.setRowCount, 1))
class ReporterIonSummary(namedtuple("ReporterIonSummary", "ratio mz intensity")): '''Definitions for a report ion ratio summary''' _round = partial(round, ndigits=3) # CLASS METHODS @classmethod def fromquery(cls, query, spectralwindow): '''Initializes the reporter ion summary from a query and mz window''' mz = np.zeros(query.mzs.size) intensity = np.zeros(query.mzs.size) indexes = ZIP(*query.where(spectralwindow.mz)) for row, column in indexes: mz[row] = spectralwindow.mz[column] intensity[row] = spectralwindow.intensity[column] if intensity.any(): ratio = intensity / intensity.max() else: ratio = intensity return cls(ratio.tolist(), mz.tolist(), intensity.tolist()) # PUBLIC def tostr(self, attr): return ':'.join([str(self._round(i)) for i in getattr(self, attr)])
def _transitions(self, filepath): '''Save function for Transitions documents''' document = self.worker.transitions indexes = range(len(document)) fun = partial(spectra.write_file, document, filepath, indexes) self.threading(fun, self.savedialog)
def _setup_menu_item(self, iconkey, cls, *args): '''Create icon-embedded button to add to layout''' icon = qt.IMAGES[iconkey] fun = partial(self.launch, cls, *args) return widgets.Push(icon=icon, connect=fun, parent=self)
def file(self, menu): '''Adds all the file entries to the widgets''' items = OrderedDict() items['&Open'] = OrderedDict() items['&Open']['&File'] = { 'shortcut': 'Ctrl+O', 'statusTip': 'Open Transitions', 'triggered': self.io.open } items['&Open']['&Add'] = { 'shortcut': 'Ctrl+Shift+A', 'statusTip': 'Add Transitions', 'triggered': partial(self.io.open, mode='add') } items['&Save'] = { 'shortcut': 'Ctrl+S', 'statusTip': 'Save Transitions', 'triggered': self.io.save } items['&Save As'] = { 'shortcut': 'Ctrl+Shift+S', 'statusTip': 'Save Transitions As', 'triggered': self.io.saveas } items['&Save File(s)'] = { 'statusTip': 'Save Transition File(s)', 'triggered': self.io.save_files } items['&Save Image'] = { 'shortcut': 'Ctrl+I', 'statusTip': 'Save Current Image', 'triggered': self.io.save_image } items[len(items)] = None items['&Close'] = OrderedDict() items['&Close']['&All'] = { 'statusTip': 'Close All File(s)', 'shortcut': 'Ctrl+C', 'triggered': self.io.close_files } items['&Close']['&File(s)'] = { 'statusTip': 'Close Selected File(s)', 'shortcut': 'Ctrl+Shift+C', 'triggered': self.io.close_selected_files } items[len(items)] = None items['&Exit'] = { 'shortcut': 'Ctrl+Q', 'statusTip': 'Exit Window', 'triggered': self.parent.close } self.set_items(menu, items)
def file(self, menu): '''Adds all the file entries to the widgets''' items = OrderedDict() items['&Open'] = OrderedDict() items['&Open']['&File'] = { 'shortcut': 'Ctrl+O', 'statusTip': 'Open PMFs', 'triggered': self.parent.io.open } items['&Open']['&Add'] = { 'shortcut': 'Ctrl+Shift+A', 'statusTip': 'Add PMFs', 'triggered': partial(self.parent.io.open, mode='add') } items['&Save'] = { 'shortcut': 'Ctrl+S', 'statusTip': 'Save PMFs', 'triggered': self.parent.io.save } items['&Save As'] = { 'shortcut': 'Ctrl+Shift+S', 'statusTip': 'Save PMF As', 'triggered': self.parent.io.saveas } items['&Save File(s)'] = { 'statusTip': 'Save PMF File(s)', 'triggered': self.parent.io.save_files } items['&Save Image'] = { 'shortcut': 'Ctrl+I', 'statusTip': 'Save Current Image', 'triggered': self.parent.io.save_image } items[len(items)] = None items['&Close'] = OrderedDict() items['&Close']['&All'] = { 'statusTip': 'Close All File(s)', 'shortcut': 'Ctrl+C', 'triggered': self.parent.io.close_files } items['&Close']['&File(s)'] = { 'statusTip': 'Close Selected File(s)', 'shortcut': 'Ctrl+Shift+C', 'triggered': self.parent.io.close_selected_files } items[len(items)] = None items['&Exit'] = { 'shortcut': 'Ctrl+Q', 'statusTip': 'Exit Window', 'triggered': self.parent.close } self.set_items(menu, items)
def reset_item(self, index, row, column): '''Remakes a given item to avoid reparenting the given object''' item = self.table.takeItem(index + 1, column) # block insertion to avoid table signals fun = partial(self.table.set_item, index, column, item) self.block_once(fun)
def reset_item(self, index, row, column): '''Remakes a given item to avoid reparenting the given object''' item = self.table.takeItem(index + 1, column) # block insertion to avoid table signals fun = partial(self.table.set_item, index, column, item) self.block_once(fun)
def pvoigt(x, *p): '''Returns a pseudo-voigt function the x values and a given guess.''' height, mean, sigma, fraction = p gauss = partial(gaussian, x, 1, mean, sigma) loren = partial(lorentzian, x, 1, mean, sigma) if fraction < 0 or fraction > 1: # set bounds via astronomically high values if out of bounds y = x * np.inf else: # estimate distribution y = height * ((1 - fraction) * gauss() + fraction * loren()) if y.min() < 0: y = y * np.inf return y
def export(self, menu): '''Adds a menu for custom exportation settings''' items = OrderedDict() items['&Report'] = OrderedDict() items['&Report']['&Integrated'] = { 'statusTip': 'Export Integrated', 'shortcut': 'Ctrl+e', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.integrate), } items['&Report']['&Area'] = { 'statusTip': 'Export Area List', 'shortcut': 'Ctrl+Shift+e', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.area), } items['&Report']['&Intensity'] = { 'statusTip': 'Export Intensity List', 'shortcut': 'Ctrl+Alt+e', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.intensity), } items['&Report']['&Comparative'] = OrderedDict() items['&Report']['&Comparative']['&Standard'] = { 'statusTip': 'Export Standard Quantitative Comparative', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.comparative), } items['&Report']['&Comparative']['&Filtered'] = { 'statusTip': 'Export Filtered Quantitative Comparative', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.filteredcomparative), } items['&Report']['&Ratio Table'] = OrderedDict() items['&Report']['&Ratio Table']['&Standard'] = { 'statusTip': 'Export Standard Ratio Table', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.ratiotable), } items['&Report']['&Ratio Table']['&Filtered'] = { 'statusTip': 'Export Filtered Ratio Table', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.filteredratiotable), } self.set_items(menu, items)
def decorator(self, *args, **kwds): if self.app.threads: # task currently occuring, avoid tandem I/O return frozen = partial(f, self, *args, **kwds) blocked = partial(self.table.block_once, frozen) getattr(self.table, "showspinner", self.table.show)() worker = threads.WorkerThread(blocked) background = threads.BackgroundThread(worker, self) endfun = getattr(self.table, "hidespinner", self.table.show) worker.procedure_done.connect(endfun, qt.CONNECTION['Queued']) #worker.result.connect(slot) for thread in (worker, background): thread.start()
def decorator(self, *args, **kwds): if self.app.threads: # task currently occuring, avoid tandem I/O return frozen = partial(f, self, *args, **kwds) blocked = partial(self.table.block_once, frozen) getattr(self.table, "showspinner", self.table.show)() worker = threads.WorkerThread(blocked) background = threads.BackgroundThread(worker, self) endfun = getattr(self.table, "hidespinner", self.table.show) worker.procedure_done.connect(endfun, qt.CONNECTION['Queued']) #worker.result.connect(slot) for thread in (worker, background): thread.start()
def set_buttons(self): '''Adds a submit and get taxonomy buttons to the layout''' fun = partial(webbrowser.open, TAXONOMY) findtaxa = widgets.ClickButton("Find Taxonomy", fun) self.layout.addWidget(findtaxa, 5, 0, 1, 5) submit = widgets.ClickButton("Submit", self.submit) self.layout.addWidget(submit, 5, 5, 1, 5)
def set_buttons(self): '''Adds a submit and get taxonomy buttons to the layout''' fun = partial(webbrowser.open, TAXONOMY) findtaxa = widgets.ClickButton("Find Taxonomy", fun) self.layout.addWidget(findtaxa, 5, 0, 1, 5) submit = widgets.ClickButton("Submit", self.submit) self.layout.addWidget(submit, 5, 5, 1, 5)
def chain(f, n=1): ''' Chain function calls Args: f (callable): frozen callable n (int): number if instances to chain the function ''' return partial(reduce, (lambda x, y: y(x)), [f] * n)
def save_spreadsheet(self, processor): '''Exports a spreadsheet using a custom processing function''' filepath = self._get_save_path('excel_extension') if filepath: self.parent().savedialog.show() self.app.processEvents() fun = partial(processor, self.tree().document, filepath) self.threading(fun, self.parent().savedialog)
def save_spreadsheet(self, processor): '''Exports a spreadsheet using a custom processing function''' filepath = self._get_save_path('excel_extension') if filepath: self.parent().savedialog.show() self.app.processEvents() fun = partial(processor, self.tree().document, filepath) self.threading(fun, self.parent().savedialog)
def chain(f, n=1): ''' Chain function calls Args: f (callable): frozen callable n (int): number if instances to chain the function ''' return partial(reduce, (lambda x, y: y(x)), [f] * n)
def set_hierarchical(self): '''Makes the hierarchical/level separated toggle buttons''' layout = QtGui.QHBoxLayout() self.layout.addLayout(layout) for title, attrname in WIDGETS: slot = partial(self.clicked, attrname) button = widgets.ClickButton(title, slot, checkable=True) layout.addWidget(button) setattr(self, attrname, button)
def delete_row(self, row, rows): '''Deletes the row from the widget and then adjusts the table''' for column in reversed(range(self.table.columnCount())): column_values = self.model().list[column] if row < len(column_values): del column_values[row] rows = self.table.rowCount() - 1 adjust_rowcount = partial(self.table.setRowCount, rows) self.table.block_once(adjust_rowcount)
def delete_row(self, row, rows): '''Deletes the row from the widget and then adjusts the table''' for column in reversed(range(self.table.columnCount())): column_values = self.model().list[column] if row < len(column_values): del column_values[row] rows = self.table.rowCount() - 1 adjust_rowcount = partial(self.table.setRowCount, rows) self.table.block_once(adjust_rowcount)
def save(self): '''Saves the spectral document to file''' if self.path != self.parent()._qt['path']: self.parent().savedialog.show() self.app.processEvents() fun = partial(spectra.write_file, self.tree().document, self.path) self.threading(fun, self.parent().savedialog) else: self.saveas()
def view(self, menu): '''Adds all the view entries to the widgets''' items = OrderedDict() items['&Expand'] = OrderedDict() items['&Expand']['&All'] = { 'statusTip': 'Expand All', 'shortcut': 'Ctrl+Shift+Right', 'triggered': self.nodes.expand } items['&Expand']['&From Selected'] = { 'statusTip': 'Expand From Selected', 'shortcut': 'Shift+Right', 'triggered': partial(self.nodes.expand, select=True, recurse=True) } items['&Expand']['&Selected'] = { 'statusTip': 'Expand Selected', 'shortcut': 'Right', 'triggered': partial(self.nodes.expand, select=True) } items['&Collapse'] = OrderedDict() items['&Collapse']['&All'] = { 'statusTip': 'Collapse All', 'shortcut': 'Ctrl+Shift+Left', 'triggered': self.nodes.collapse } items['&Collapse']['&From Selected'] = { 'statusTip': 'Collapse From Selected', 'shortcut': 'Shift+Left', 'triggered': partial(self.nodes.collapse, select=True, recurse=True) } items['&Collapse']['&Selected'] = { 'statusTip': 'Collapse Selected', 'shortcut': 'Left', 'triggered': partial(self.nodes.collapse, select=True) } self.set_items(menu, items)
def save(self): '''Saves the spectral document to file''' if self.path != self.parent()._qt['path']: self.parent().savedialog.show() self.app.processEvents() fun = partial(spectra.write_file, self.tree().document, self.path) self.threading(fun, self.parent().savedialog) else: self.saveas()
def set_togglebar(self): '''Adds paired QPushbuttons to toggle the current display''' layout = QtGui.QHBoxLayout() self.layout.addLayout(layout) for title, attrname in WIDGETS: slot = partial(self.clicked, attrname) button = widgets.ClickButton(title, slot, checkable=True) layout.addWidget(button) setattr(self, attrname, button)
def __init__(self, parent, store, **kwds): super(ClickButton, self).__init__(parent) self._store = store self.display = kwds.get('display', str) self.__connect = kwds.get('connect').__get__(self) if 'tooltip' in kwds: self.setToolTip(kwds['tooltip']) if 'connect' in kwds: self.clicked.connect(partial(self.__connect, store)) self.setText(self.attribute)
def __init__(self, parent, store, **kwds): super(ClickButton, self).__init__(parent) self._store = store self.display = kwds.get('display', str) self.__connect = kwds.get('connect').__get__(self) if 'tooltip' in kwds: self.setToolTip(kwds['tooltip']) if 'connect' in kwds: self.clicked.connect(partial(self.__connect, store)) self.setText(self.attribute)
def saveas(self, indexes=None): '''Saves selected spectral files to a user-chosen path''' if indexes is None and self.tree().document is not None: indexes = range(len(self.tree().document)) filepath = self._get_save_path('document_extension') if filepath: self.set_path(filepath, mode='replace') self.parent().savedialog.show() self.app.processEvents() fun = partial(spectra.write_file, self.tree().document, filepath, indexes) self.threading(fun, self.parent().savedialog)
def saveas(self, indexes=None): '''Saves selected spectral files to a user-chosen path''' if indexes is None and self.tree().document is not None: indexes = range(len(self.tree().document)) filepath = self._get_save_path('document_extension') if filepath: self.set_path(filepath, mode='replace') self.parent().savedialog.show() self.app.processEvents() fun = partial(spectra.write_file, self.tree().document, filepath, indexes) self.threading(fun, self.parent().savedialog)
def export(self, menu): '''Adds a menu for custom exportation settings''' items = OrderedDict() items['&Report'] = OrderedDict() items['&Report']['&Integrated'] = { 'statusTip': 'Export Integrated', 'shortcut': 'Ctrl+e', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.integrate), } items['&Report']['&Area'] = { 'statusTip': 'Export Area List', 'shortcut': 'Ctrl+Shift+e', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.area), } items['&Report']['&Intensity'] = { 'statusTip': 'Export Intensity List', 'shortcut': 'Ctrl+Alt+e', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.intensity), } items['&Report']['&Comparative'] = OrderedDict() items['&Report']['&Comparative']['&Standard'] = { 'statusTip': 'Export Standard Quantitative Comparative', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.comparative), } items['&Report']['&Comparative']['&Filtered'] = { 'statusTip': 'Export Filtered Quantitative Comparative', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.filteredcomparative), } items['&Report']['&Ratio Table'] = OrderedDict() items['&Report']['&Ratio Table']['&Standard'] = { 'statusTip': 'Export Standard Ratio Table', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.ratiotable), } items['&Report']['&Ratio Table']['&Filtered'] = { 'statusTip': 'Export Filtered Ratio Table', 'triggered': partial(self.io.save_spreadsheet, self.tree.export.filteredratiotable), } self.set_items(menu, items)
def _worker(self, fun, dialog, connects): ''' Initialize worker thread for I/O events. args: fun (callable): function to execute within worker dialog (QDialog): Widget kept responsive connects (tuple): slots to connect to worker.finished ''' worker = threads.WorkerThread(fun) hide = partial(self.hide, dialog) worker.finished.connect(hide, qt.CONNECTION['Queued']) worker.error.connect(self.error, qt.CONNECTION['Queued']) for connect in connects: worker.finished.connect(connect, qt.CONNECTION['Queued']) return worker
def set_shortcuts(self): self.shortcuts = { 'Ctrl+f': self.table.finder.show, 'Ctrl+b': self.table.block, 'Ctrl+c': self.copy, 'Ctrl+x': self.cut, 'Ctrl+v': self.paste, 'Del': self.delete, 'Ctrl+a': self.select_all } modes = { 'Ctrl+Shift+s': 'Single', 'Ctrl+Shift+m': 'Multi', 'Ctrl+Shift+e': 'Extended' } for keysequence, mode in modes.items(): fun = partial(self.select_mode, qt.SELECTION_MODE[mode]) self.shortcuts[keysequence] = fun
def bind_trace(self, mode='call'): '''Activates the tracer and can be set to 'call' or 'line' mode''' tracer = TRACERS[mode] shortcuts = {'Ctrl+t': partial(sys.settrace, tracer)} self.bind_keys(shortcuts)
def set_selection(self, index): fun = partial(self.setCurrentCell, index.row, index.column) self.block_once(fun)
def edit(self, menu): '''Adds all the edit entries to the widgets''' items = OrderedDict() items['&Sort'] = OrderedDict() items['&Sort']['&Peptide'] = { 'statusTip': 'Sort Transitions by Peptide', 'triggered': partial(self.nodes.sort, 'Peptide') } items['&Sort']['&Retention Time'] = { 'statusTip': 'Sort Transitions by RT', 'triggered': partial(self.nodes.sort, 'RT') } items['&Sort']['&Peptide Score'] = { 'statusTip': 'Sort Transitions by Peptide Score', 'triggered': partial(self.nodes.sort, 'Score') } items['&Sort']['&Expectation Value'] = { 'statusTip': 'Sort Transitions by EV', 'triggered': partial(self.nodes.sort, 'EV') } items['&Sort']['&Mod Counts'] = { 'statusTip': 'Sort Transitions by mod counts', 'triggered': partial(self.nodes.sort, 'Mod Count') } items['&Peak Bounds'] = OrderedDict() items['&Peak Bounds']['&Start'] = OrderedDict() items['&Peak Bounds']['&Start']['&Left'] = { 'statusTip': 'Move Start Bound Left', 'shortcut': 'Alt+h', 'triggered': partial(self.tree.line.move, 'start', -1, 1) } items['&Peak Bounds']['&Start']['&Strong Left'] = { 'statusTip': 'Move Start Bound Strongly Left', 'shortcut': 'Alt+Shift+h', 'triggered': partial(self.tree.line.move, 'start', -1, 5) } items['&Peak Bounds']['&Start']['&Right'] = { 'statusTip': 'Move Start Bound Right', 'shortcut': 'Alt+j', 'triggered': partial(self.tree.line.move, 'start', 1, 1) } items['&Peak Bounds']['&Start']['&Strong Right'] = { 'statusTip': 'Move Start Bound Strongly Right', 'shortcut': 'Alt+Shift+j', 'triggered': partial(self.tree.line.move, 'start', 1, 5) } items['&Peak Bounds']['&End'] = OrderedDict() items['&Peak Bounds']['&End']['&Left'] = { 'statusTip': 'Move End Bound Left', 'shortcut': 'Alt+k', 'triggered': partial(self.tree.line.move, 'end', -1, 1) } items['&Peak Bounds']['&End']['&Strong Left'] = { 'statusTip': 'Move End Bound Strongly Left', 'shortcut': 'Alt+Shift+k', 'triggered': partial(self.tree.line.move, 'end', -1, 5) } items['&Peak Bounds']['&End']['&Right'] = { 'statusTip': 'Move End Bound Right', 'shortcut': 'Alt+l', 'triggered': partial(self.tree.line.move, 'end', 1, 1) } items['&Peak Bounds']['&End']['&Strong Right'] = { 'statusTip': 'Move End Bound Strongly Right', 'shortcut': 'Alt+Shift+l', 'triggered': partial(self.tree.line.move, 'end', 1, 5) } items['&Checkstate'] = OrderedDict() items['&Checkstate']['&Item'] = { 'statusTip': 'Toggle Item', 'shortcut': 'Space', 'triggered': self.toggle.item } items['&Checkstate']['&Children'] = { 'statusTip': 'Toggle Children', 'shortcut': 'Shift+Space', 'triggered': self.toggle.children } items[len(items)] = None items['&Settings'] = { 'statusTip': 'Edit user settings', 'triggered': self.settings } self.set_items(menu, items)
from xldlib.resources.parameters import reports from xldlib.utils import logger from . import best_peptide, comparative, overall, quantitative, report, skyline # load objects/functions from collections import namedtuple from xldlib.definitions import partial # DATAFRAMES # ---------- DATAFRAMES = { 'best_peptide': best_peptide.Dataframe, 'best_peptide_file': partial(best_peptide.Dataframe, infile=True), 'comparative': comparative.Dataframe, 'comparative_named': partial(comparative.Dataframe, flags=comparative.FLAGS['named']), 'quantitative_comparative': partial(comparative.Dataframe, flags=comparative.FLAGS['quantitative']), 'overall': overall.Dataframe, 'quantitative': quantitative.Dataframe, 'report': report.Dataframe, 'skyline': skyline.Dataframe, } # HELPERS # -------
def mousePressEvent(self, event): '''Hide on mouse click event and blocks parent events''' self.parent().block_once(partial(self.mouse_click, event))
def _session(self, filepath): '''Save function for session data''' fun = partial(self.worker.matched.save, filepath) self.threading(fun, self.savedialog)
def _excel(self, filepath): '''Save function for Open Office spreadsheets''' fun = partial(shutil.copy, paths.FILES['spreadsheet'], filepath) self.threading(fun, self.savedialog)
def __init__(self, path=None, data=None, registered=False): super(TransitionsDocument, self).__init__(path, data, registered) self.memory = False self.cache = None self.togglememory = partial(togglememory, self)