def on_load_common_masses(self, e): cmfilename = FileDialogs.open_file_dialog( "Open Common Masses File", file_types="*.csv*", default=self.config.masstablefile) if cmfilename is not None: self.load_common_masses(cmfilename)
def auto(self, evt, file_path=None, filtered_lines=None): if file_path is None and (filtered_lines is None or len(filtered_lines) <= 2): file_path = FileDialogs.open_file_dialog("Open File", "*.csv") filtered_lines = [] if file_path is not None: # read in the comma-delimited import file f = open(file_path, 'r') lines = f.readlines() f.close() # strip lines beginning with # so can comment out lines # strip blank lines for line in lines: if line.strip() is '' or line[0] is '#': continue filtered_lines.append(line) if filtered_lines is not None and len(filtered_lines) > 2: # i.e. more than just hopefully the two header lines t = threading.Thread(target=data_importer.auto_from_wizard, args=(filtered_lines, self.exedir)) t.start() # gauge=ImporterProgressGauge.ProgressDialog() # gauge.progress_dialog(self,"Importing raw file(s)","Importing file %s of %s, please wait..." % (1, len(filtered_lines) - 2),len(filtered_lines) - 2) ImporterProgressGauge.progress_dialog(self, "Importing raw file(s)", "Importing file %s of %s, please wait..." % ( 1, len(filtered_lines) - 2), len(filtered_lines) - 2)
def import_file(self, evt=None, file_path=None): if file_path is None: file_path = FileDialogs.open_file_dialog("Open File", "*.csv") if file_path is not None: # read in the comma-delimited import file f = open(file_path, 'r') lines = f.readlines() f.close() type = lines[0].split(",")[1] if type.lower() == "scans": print("Type Scans:", type) self.rb.SetSelection(1) self.my_grid.EvtDriftType(1) else: print("Type Time:", type) self.rb.SetSelection(0) self.my_grid.EvtDriftType(0) data = np.genfromtxt(file_path, delimiter=",", skip_header=2, dtype=np.str) print("Data:", data) self.my_grid.load_data(data)
def on_load_conf_file(self, e=None): """ Opens a file dialog and then imports a new _conf.dat config file :param e: unused space for event :return: None """ cfilename = FileDialogs.open_file_dialog("Open Configuration File (_conf.dat)", file_types="*.*") if cfilename is not None: self.import_config(cfilename) pass
def on_import_masses(self, e): """ Opens a dialog to import mass list files. :param e: Unused event :return: None """ mfilename = FileDialogs.open_file_dialog( "Open Text File with List of Mass Defects", file_types="*.*") if mfilename is not None: importmass = np.loadtxt(mfilename) self.masslistbox.list.populate(importmass)
def on_import_masses(self, e): """ Opens a dialog to import mass list files. :param e: Unused event :return: None """ mfilename = FileDialogs.open_file_dialog("Open Mass File (mfile)", file_types="*.*") if mfilename is not None: importmass = np.loadtxt(mfilename) if importmass[0] > 0: self.masslistbox.list.populate(importmass)
def on_import_oligos(self, e): """ Open a file dialog to import oligomer files. :param e: Unused event :return: None """ # TODO: This fails when the output ofile isn't square (some are unnamed and other are named) ofilename = FileDialogs.open_file_dialog("Open Oligomer File (ofile)", file_types="*.*") if ofilename is not None: importolig = np.genfromtxt(ofilename, dtype='str') if np.shape(importolig) == (5, ) or np.shape(importolig) == (4, ): importolig = [importolig] self.oligomerlistbox.list.populate(importolig)
def on_import(self, e): """ Open a file dialog and import a N x 3 (MS) or N x 5 (IMMS) array of manual assignment. Add the array to the listctrl. :param e: Unused event :return: None """ import_file_name = FileDialogs.open_file_dialog("Open File", file_types="*.*") if import_file_name is not None: importtrunc = np.loadtxt(import_file_name) if self.config.imflag == 0: if importtrunc.shape == (3, ): importtrunc = [importtrunc] if len(importtrunc[0]) == 3: self.masslistbox.list.populate(importtrunc) # print importtrunc else: if importtrunc.shape == (5, ): importtrunc = [importtrunc] if len(importtrunc[0]) == 5: self.masslistbox.list.populate(importtrunc)