def OnGetItemInformation(self, itemID, return_list=False): # get item information information = { 'start': str2int( self.peaklist.GetItem( itemID, self.config.driftTopColNames['start']).GetText()), 'end': str2int( self.peaklist.GetItem( itemID, self.config.driftTopColNames['end']).GetText()), 'scans': str2int( self.peaklist.GetItem( itemID, self.config.driftTopColNames['end']).GetText()), 'drift_voltage': str2num( self.peaklist.GetItem( itemID, self.config.driftTopColNames['drift_voltage']).GetText()), 'document': self.peaklist.GetItem( itemID, self.config.driftTopColNames['filename']).GetText() } if return_list: start = information['start'] end = information['end'] scans = information['scans'] drift_voltage = information['drift_voltage'] document = information['document'] return start, end, scans, drift_voltage, document return information
def importConfig(self, fileName=None, e=None): """ Imports config from a file """ if not os.path.isfile(fileName): print('not a path') return f = open(fileName, 'r') for line in f: if len(line.split()) > 1: if line.startswith("iPolarity "): self.iPolarity = str(line.split()[1]) if line.startswith("iActivationZone "): self.iActivationZone = str(line.split()[1]) if line.startswith("iActivationMode "): self.iActivationMode = str(line.split()[1]) if line.startswith("iSPV "): self.iSPV = str2int(line.split()[1]) if line.startswith("iScanTime "): self.iScanTime = str2int(line.split()[1]) if line.startswith("iStartVoltage "): self.iStartVoltage = str2num(line.split()[1]) if line.startswith("iEndVoltage "): self.iEndVoltage = str2num(line.split()[1]) if line.startswith("iStepVoltage "): self.iStepVoltage = str2num(line.split()[1]) if line.startswith("iExponentPerct "): self.iExponentPerct = str2num(line.split()[1]) if line.startswith("iExponentIncre "): self.iExponentIncre = str2num(line.split()[1]) if line.startswith("iBoltzmann "): self.iBoltzmann = str2num(line.split()[1]) # if line.startswith("wrensPath "): # self.wrensPath = str(line.split(" ")[1::]) # print(self.wrensPath, os.path.isabs(self.wrensPath)) if line.startswith("wrensLinearName "): self.wrensLinearName = str(line.split()[1]) if line.startswith("wrensExponentName "): self.wrensExponentName = str(line.split()[1]) if line.startswith("wrensBoltzmannName "): self.wrensBoltzmannName = str(line.split()[1]) if line.startswith("wrensUserDefinedName "): self.wrensUserDefinedName = str(line.split()[1]) if line.startswith("wrensResetName "): self.wrensResetName = str(line.split()[1]) self.wrensLinearPath = "".join( ['"', self.wrensRunnerPath, '" ', self.wrensLinearName, ' "']) self.wrensExponentPath = "".join( ['"', self.wrensRunnerPath, '" ', self.wrensExponentName, ' "']) self.wrensBoltzmannPath = "".join( ['"', self.wrensRunnerPath, '" ', self.wrensBoltzmannName, ' "']) self.wrensUserDefinedPath = "".join( ['"', self.wrensRunnerPath, '" ', self.wrensUserDefinedName, ' "']) self.wrensResetPath = "".join( ['"', self.wrensRunnerPath, '" ', self.wrensResetName, ' "'])
def onApply(self, evt): self.onCheckID() if self.importEvent: return self.parent.peaklist.CheckItem(self.itemInfo['id'], self.origami_select_value.GetValue()) self.parent.peaklist.SetStringItem(self.itemInfo['id'], self.config.peaklistColNames['charge'], self.origami_charge_value.GetValue()) self.parent.peaklist.SetStringItem(self.itemInfo['id'], self.config.peaklistColNames['colormap'], self.origami_colormap_value.GetStringSelection()) self.parent.peaklist.SetStringItem(self.itemInfo['id'], self.config.peaklistColNames['mask'], num2str(self.origami_mask_value.GetValue())) self.parent.peaklist.SetStringItem(self.itemInfo['id'], self.config.peaklistColNames['alpha'], num2str(self.origami_transparency_value.GetValue())) self.parent.peaklist.SetStringItem(self.itemInfo['id'], self.config.peaklistColNames['method'], self.origami_method_value.GetStringSelection()) self.parent.peaklist.SetStringItem(self.itemInfo['id'], self.config.peaklistColNames['label'], self.origami_label_value.GetValue()) if self.itemInfo['parameters'] == None: self.itemInfo['parameters'] = {} self.itemInfo['parameters']['firstVoltage'] = str2int(self.origami_startScan_value.GetValue()) self.itemInfo['parameters']['startV'] = str2num(self.origami_startVoltage_value.GetValue()) self.itemInfo['parameters']['endV'] = str2num(self.origami_endVoltage_value.GetValue()) self.itemInfo['parameters']['stepV'] = str2num(self.origami_stepVoltage_value.GetValue()) self.itemInfo['parameters']['spv'] = str2int(self.origami_scansPerVoltage_value.GetValue()) self.itemInfo['parameters']['expIncrement'] = str2num(self.origami_exponentialIncrement_value.GetValue()) self.itemInfo['parameters']['expPercent'] = str2num(self.origami_exponentialPercentage_value.GetValue()) self.itemInfo['parameters']['dx'] = str2num(self.origami_boltzmannOffset_value.GetValue()) # update ion information self.itemInfo['charge'] = self.origami_charge_value.GetValue() self.itemInfo['colormap'] = self.origami_colormap_value.GetStringSelection() self.itemInfo['mask'] = self.origami_mask_value.GetValue() self.itemInfo['alpha'] = self.origami_transparency_value.GetValue() self.itemInfo['label'] = self.origami_label_value.GetValue() self.itemInfo['min_threshold'] = self.origami_min_threshold_value.GetValue() self.itemInfo['max_threshold'] = self.origami_max_threshold_value.GetValue() # update ion value try: charge = str2int(self.itemInfo['charge']) ion_centre = (str2num(self.itemInfo['mzStart']) + str2num(self.itemInfo['mzEnd'])) / 2 mw = (ion_centre - self.config.elementalMass['Hydrogen'] * charge) * charge ion_value = (u"%s ~%.2f Da") % (self.itemInfo['ionName'], mw) self.origami_ion_value.SetValue(ion_value) except: self.origami_ion_value.SetValue(self.itemInfo['ionName']) self.OnAssignColor(evt=None) self.parent.onUpdateDocument(itemInfo=self.itemInfo, evt=None) if evt != None: evt.Skip()
def onSetupParameters(self, evt): self.importEvent = True self.origami_select_value.SetValue(self.itemInfo['select']) self.origami_filename_value.SetValue(self.itemInfo['document']) try: charge = str2int(self.itemInfo['charge']) ion_centre = (str2num(self.itemInfo['mzStart']) + str2num(self.itemInfo['mzEnd'])) / 2 mw = (ion_centre - self.config.elementalMass['Hydrogen'] * charge) * charge ion_value = (u"%s ~%.2f Da") % (self.itemInfo['ionName'], mw) self.origami_ion_value.SetValue(ion_value) except: self.origami_ion_value.SetValue(self.itemInfo['ionName']) self.origami_charge_value.SetValue(str(self.itemInfo['charge'])) self.origami_label_value.SetValue(self.itemInfo['label']) self.origami_colormap_value.SetStringSelection(self.itemInfo['colormap']) self.origami_mask_value.SetValue(self.itemInfo['mask']) self.origami_transparency_value.SetValue(self.itemInfo['alpha']) self.origami_color_value.SetBackgroundColour(self.itemInfo['color']) self.origami_min_threshold_value.SetValue(self.itemInfo['min_threshold']) self.origami_max_threshold_value.SetValue(self.itemInfo['max_threshold']) if self.itemInfo['parameters'] != None: self.origami_method_value.SetStringSelection(self.itemInfo['parameters']['method']) self.origami_startScan_value.SetValue(str(self.itemInfo['parameters'].get('firstVoltage', ''))) self.origami_scansPerVoltage_value.SetValue(str(self.itemInfo['parameters'].get('spv', ''))) self.origami_startVoltage_value.SetValue(str(self.itemInfo['parameters'].get('startV', ''))) self.origami_endVoltage_value.SetValue(str(self.itemInfo['parameters'].get('endV', ''))) self.origami_stepVoltage_value.SetValue(str(self.itemInfo['parameters'].get('stepV', ''))) self.origami_exponentialIncrement_value.SetValue(str(self.itemInfo['parameters'].get('expIncrement', ''))) self.origami_exponentialPercentage_value.SetValue(str(self.itemInfo['parameters'].get('expPercent', ''))) self.origami_boltzmannOffset_value.SetValue(str(self.itemInfo['parameters'].get('dx', ''))) else: self.origami_startScan_value.SetValue(str(self.config.origami_startScan)) self.origami_scansPerVoltage_value.SetValue(str(self.config.origami_spv)) self.origami_startVoltage_value.SetValue(str(self.config.origami_startVoltage)) self.origami_endVoltage_value.SetValue(str(self.config.origami_endVoltage)) self.origami_stepVoltage_value.SetValue(str(self.config.origami_stepVoltage)) self.origami_exponentialIncrement_value.SetValue(str(self.config.origami_exponentialIncrement)) self.origami_exponentialPercentage_value.SetValue(str(self.config.origami_exponentialPercentage)) self.origami_boltzmannOffset_value.SetValue(str(self.config.origami_boltzmannOffset)) self.origami_method_value.SetStringSelection(self.config.origami_acquisition) try: self.origami_method_value.SetStringSelection(self.itemInfo['method']) except: pass self.enableDisableBoxes(evt=None) self.importEvent = False
def OnSortByColumn(self, column): """ Sort data in peaklist based on pressed column """ # Check if it should be reversed if self.lastColumn == None: self.lastColumn = column elif self.lastColumn == column: if self.reverse == True: self.reverse = False else: self.reverse = True else: self.reverse = False self.lastColumn = column columns = self.peaklist.GetColumnCount() rows = self.peaklist.GetItemCount() tempData = [] # Iterate over row and columns to get data for row in range(rows): tempRow = [] for col in range(columns): item = self.peaklist.GetItem(itemId=row, col=col) # We want to make sure the first 3 columns are numbers if col == 0 or col == 1 or col == 2: itemData = str2num(item.GetText()) if itemData == None: itemData = 0 tempRow.append(itemData) elif col == 3: itemData = str2int(item.GetText()) if itemData == None: itemData = 0 tempRow.append(itemData) else: tempRow.append(item.GetText()) tempData.append(tempRow) # Sort data tempData.sort(key=itemgetter(column), reverse=self.reverse) # Clear table and reinsert data self.peaklist.DeleteAllItems() for row in range(rows): self.peaklist.Append(tempData[row])
def OnGetItemInformation(self, itemID, return_list=False): # get item information information = { 'start': str2num( self.peaklist.GetItem( itemID, self.config.driftBottomColNames['start']).GetText()), 'end': str2num( self.peaklist.GetItem( itemID, self.config.driftBottomColNames['end']).GetText()), 'intensity': str2num( self.peaklist.GetItem( itemID, self.config.driftBottomColNames['intensity']).GetText()), 'charge': str2int( self.peaklist.GetItem( itemID, self.config.driftBottomColNames['charge']).GetText()), 'document': self.peaklist.GetItem( itemID, self.config.driftBottomColNames['filename']).GetText() } if return_list: start = information['start'] end = information['end'] intensity = information['intensity'] charge = information['charge'] document = information['document'] return start, end, intensity, charge, document return information