def __groupby_color(self): '''Groups a given series of plotdata by color''' colored = mapping.OrderedDefaultdict(list) for plot in self.plotdata: colored[plot.color].append(plot.y) return colored
def __cluster_plots(self, clusters=3): '''Clusters plotdata''' clustered = mapping.OrderedDefaultdict(list) for color, ydata in self.__groupby_color().items(): for index in range(clusters): items = ydata[index::clusters] if items: clustered[color].append(np.max(items, axis=0)) return clustered
def get_clipboard(self, clipboard_text, delimiter='\t'): ''' Grab clipboard and process dimensions. get_clipboard()->[['A', 'B'], ['C', 'D'], ['E', 'F']] # (2x3) ''' lines = clipboard_text.splitlines() values = mapping.OrderedDefaultdict(list) for line in lines: for index, value in enumerate(line.split(delimiter)): values[index].append(value) return values
def organize_basemods(self): '''Returns a dictionary with {res: (name, mass)}''' names = self.mods['Mod Name'] formulas = self.mods['Formula'] react = self.mods['Reactivity'] basemods = mapping.OrderedDefaultdict(list) for index, name in enumerate(names): res = react[index] formula = formulas[index] basemods[res].append((name, formula)) return basemods
def get_fragment_masses(self): '''Returns a dictionary with crosslink fragment {name: mass}''' fragments = self.xler['fragments'] names = fragments['name'] formula = fragments['formula'] react = fragments['reactivity'] masses = mapping.OrderedDefaultdict(list) for index, name in enumerate(names): mass = round(chemical.Molecule(formula[index]), self.precision) masses[(mass, react[index])].append(name) return masses
def _get_values(self, selected_indexes): ''' Grab QTable cell values from the corresponding indexes Args: selected_indexes (list): objects with row/column variables Returns (dict): dict with {row: [values]} ''' values = mapping.OrderedDefaultdict(list) for index in selected_indexes: value = self.table.model().list[index.column][index.row] #value = self.table.model().get_value(index.row, index.column) if value is not None: values[index.row].append(value) return values