Example #1
0
    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)
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
 def on_save_fig(self, e=None):
     path = FileDialogs.save_file_dialog()
     base, ext = os.path.splitext(path)
     #self.init()
     #self.save_fig(base,ext)
     for i in range(0, len(self.datalist)):
         self.on_next(None)
         self.save_fig(base, ext)
Example #5
0
 def on_save_common_masses(self, e):
     outdata = self.commonmassespanel.list.get_list()
     cmfilename = FileDialogs.save_file_dialog("Save Common Masses File",
                                               "*.csv*",
                                               self.config.masstablefile)
     if cmfilename is not None:
         np.savetxt(cmfilename, outdata, delimiter=",", fmt="%s")
     print("Saving Common Masses to:", cmfilename)
Example #6
0
 def get_folder_path(self, evt):
     '''
     Get path to folder and place in txtctrl
     '''
     path = FileDialogs.open_dir_dialog()
     if path != None:
         self.folder_path.SetValue(path)
         self.my_tree.populate_tree()
Example #7
0
    def auto(self, evt=None, file_path=None):
        if file_path is None:
            file_path = FileDialogs.save_file_dialog("Save File As", "*.hdf5")
            filtered_lines = []

        if file_path is not None:
            cols, data = self.my_grid.get_data()
            meta_data_importer.auto_from_wizard(data, file_path,
                                                self.rb.GetSelection())
Example #8
0
 def on_save_fig_dialog(self, evt):
     """
     Open a save figure dialog for specified plot.
     :param evt: wx.Event (unused)
     :return: None
     """
     path = FileDialogs.save_file_dialog()
     if path is not None:
         self.save_figure(path)
Example #9
0
 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
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
 def on_write_dialog(self, evt):
     """
     Open a save figure dialog for specified plot.
     :param evt: wx.Event (unused)
     :return: None
     """
     if self.data is not None:
         path = FileDialogs.save_file_dialog()
         if path is not None:
             self.write_data(path)
     else:
         print(
             "Data object empty. Plot likely unsupported for text file output."
         )
Example #14
0
    def export_file(self, evt):
        '''
        Export import file for later import
        '''
        file_path = FileDialogs.save_file_dialog(message="Save Import CSV File", file_types="CSV (*.csv)|*.csv")
        max_index = self.my_grid.next_free_row()
        if file_path != None and max_index > 0:

            if file_path[-17:] != '_ionMS_import.csv' and file_path[-4:] != '.csv':
                file_path += '_ionMS_import.csv'

            f = open(file_path, 'w')
            # get im type
            if self.rb.GetSelection() == 0:
                f.writelines('ionMS import wizard,Linear,\n')
            elif self.rb.GetSelection() == 2:
                f.writelines("ionMS import wizard,MS,\n")
            elif self.rb.GetSelection() == 3:
                f.writelines("ionMS import wizard,MS Times,\n")
            else:
                f.writelines('ionMS import wizard,T-wave,\n')

            index = -1
            while True:
                # get column labels
                cols = self.my_grid.column_labels()

                index += 1
                if index == max_index:
                    break

                if index == 0:
                    # write column labels
                    tmp = ''
                    for c in cols:
                        tmp += '%s,' % cols[c]

                    f.writelines(tmp[:-1] + '\n')

                # write out user import list
                tmp = ''
                for c in cols:
                    tmp += '%s,' % self.my_grid.GetCellValue(index, c)

                f.writelines(tmp[:-1] + '\n')

            # don't forget to close the file
            f.close()

            return file_path  # + '_ionMS_import.csv'
 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)
Example #16
0
    def export_file(self, evt):
        '''
        Export import file for later import
        '''
        file_path = FileDialogs.save_file_dialog(
            message="Save Import CSV File", file_types="CSV (*.csv)|*.csv")
        max_index = self.my_grid.next_free_row()
        if file_path != None and max_index > 0:

            if file_path[-17:] != '_import.csv' and file_path[-4:] != '.csv':
                file_path += '_import.csv'

            cols, data = self.my_grid.get_data()

            f = open(file_path, 'w')
            # Write Type at the Top
            if self.rb.GetSelection() == 0:
                f.writelines('MetaUniDec Import Wizard,Time,\n')
            elif self.rb.GetSelection() == 1:
                f.writelines("MetaUniDec Import Wizard,Scans,\n")

            # Write Column Values
            tmp = ''
            for c in cols:
                tmp += '%s,' % cols[c]
            f.writelines(tmp[:-1] + '\n')

            # Write Data
            for i, a in enumerate(data):
                for j, l in enumerate(a):
                    f.write(str(l) + ",")
                f.write('\n')

            # close the file
            f.close()

            return file_path
Example #17
0
 def on_batch_chrom_dirs(self, e=None):
     paths = FileDialogs.open_multiple_dir_dialog(
         message="Choose Waters or Agilent files to batch process.",
         default=None)
     print("Batch Run Directories:", paths)
     self.batch_run(paths)
Example #18
0
 def on_open_dir(self, e=None):
     dirname = FileDialogs.open_single_dir_dialog("Choose a raw file", '')
     print("Opening Directory: ", dirname)
     if dirname is not None:
         if os.path.splitext(dirname)[1] in chrom_file_exts:
             self.open_file(dirname)
Example #19
0
 def on_batch_chrom1(self, e=None):
     paths = FileDialogs.open_multiple_files_dialog(
         message="Choose files to batch process.", file_type="*.*")
     print("Batch Run:", paths)
     self.batch_run(paths)