Exemple #1
0
    def filter_peaks(self, minscore=0.4):
        newpeaks = []
        indexes = []
        for i, p in enumerate(self.pks.peaks):
            if p.dscore > minscore:
                newpeaks.append([p.mass, p.height, p.dscore])
                indexes.append(i)
        newpeaks = np.array(newpeaks)
        indexes = np.array(indexes)
        if len(newpeaks) > 0:
            self.pks = peakstructure.Peaks()
            self.pks.add_peaks(newpeaks,
                               massbins=self.config.massbins,
                               scores_included=True)
            self.pks.default_params(cmap=self.config.peakcmap)

            self.data.exgrid = self.data.exgrid[indexes]
            self.normalize_exgrid()

            ud.peaks_error_FWHM(self.pks, self.data.massdat)
            self.peaks_error_replicates(self.pks, self.data.spectra,
                                        self.config)

            self.update_history()
            self.export_params()
        else:
            print("No Peaks Found with Scores Above", minscore)
            self.pks = peakstructure.Peaks()
Exemple #2
0
    def pick_peaks(self):
        self.config.write_hdf5()
        self.sum_masses()

        scores_included = False
        try:
            if len(self.data.peaks[0]) == 3:
                scores_included = True
        except:
            pass

        self.pks = peakstructure.Peaks()
        self.pks.add_peaks(self.data.peaks,
                           massbins=self.config.massbins,
                           scores_included=scores_included)
        self.pks.default_params(cmap=self.config.peakcmap)

        ud.peaks_error_FWHM(self.pks, self.data.massdat)

        self.peaks_error_replicates(self.pks, self.data.spectra, self.config)
        for i, p in enumerate(self.pks.peaks):
            p.extracts = self.data.exgrid[i]

        self.update_history()
        self.export_params()
Exemple #3
0
 def initialize(self):
     """
     Initialize Config, DataContainer, and Peaks
     :return: None
     """
     self.config = unidecstructure.UniDecConfig()
     self.clear_history()
     self.config.initialize_system_paths()
     self.reset_config()
     self.data = unidecstructure.DataContainer()
     self.pks = peakstructure.Peaks()
Exemple #4
0
 def pick_peaks(self):
     self.config.write_hdf5()
     self.sum_masses()
     self.pks = peakstructure.Peaks()
     self.pks.add_peaks(self.data.peaks, massbins=self.config.massbins)
     self.pks.default_params(cmap=self.config.peakcmap)
     self.peaks_error_FWHM(self.pks, self.data.massdat)
     self.peaks_error_replicates(self.pks, self.data.spectra, self.config)
     for i, p in enumerate(self.pks.peaks):
         p.extracts = self.data.exgrid[i]
     self.update_history()
     self.export_params()
Exemple #5
0
    def sub_div(self, e=0):
        try:
            masses = []
            for p in self.eng.pks.peaks:
                if p.ignore == 0:
                    masses.append(p.mass)
            defaultsub = np.amin(masses)
        except:
            defaultsub = 44088

        defaultdiv = self.eng.config.molig
        dlg = miscwindows.DoubleInputDialog(self.view)
        dlg.initialize_interface("Subtract and Divide", "Subtract:",
                                 str(defaultsub), "Divide:", str(defaultdiv))
        dlg.ShowModal()
        try:
            sub = float(dlg.value)
            div = float(dlg.value2)
        except:
            print("Error with Subtract and Divide Inputs:", dlg.value,
                  dlg.value2)
            return 0

        try:
            sd_results = []
            message = "Average Masses:\n\n"
            outstring = ""
            for s in self.eng.data.spectra:
                pks = peakstructure.Peaks()
                peaks = ud.peakdetect(s.massdat, self.eng.config)
                pks.add_peaks(peaks, massbins=self.eng.config.massbins)
                sd_result = ud.subtract_and_divide(pks, sub, div)
                sd_results.append(sd_result)

                outstring += str(sd_result) + "\n"

            avg = np.mean(sd_results)
            message += outstring
            message += "\nOverall Average: " + str(avg)
            outstring += "\n" + str(avg)
            self.copy_to_clipboard(outstring)
            self.warn(message, caption="Subtract and Divide Results")

        except:
            sd_result = ud.subtract_and_divide(self.eng.pks, sub, div)
            outstring = str(sd_result)
            message = "Average Mass: " + outstring
            self.copy_to_clipboard(outstring)
            self.warn(message, caption="Subtract and Divide Results")
Exemple #6
0
 def open(self, path):
     self.data = MetaDataSet(self)
     self.pks = peakstructure.Peaks()
     if path is None:
         path = self.config.hdf_file
     else:
         self.config.hdf_file = path
         self.config.filename = os.path.split(path)[1]
         self.config.outfname = os.path.splitext(self.config.filename)[0]
         self.config.outfname = os.path.join("UniDec_Figures_and_Files", self.config.outfname)
         dir = os.path.dirname(path)
         os.chdir(dir)
         dirnew = os.path.split(self.config.outfname)[0]
         if not os.path.isdir(dirnew):
             os.mkdir(dirnew)
         self.config.default_file_names()
     self.config.read_hdf5(path)
     self.data.import_hdf5(path)
     self.update_history()
Exemple #7
0
 def run_autocorr(self, e):
     """
     Performs autocorrelation using ud.autocorr from unidectools.
     Plots the results and adds peaks to listctrl.
     :param e: Unused event
     :return: None
     """
     corr, peaks = ud.autocorr(self.massdat, self.config)
     self.plot1.plotrefreshtop(corr[:, 0], corr[:, 1], "Autocorrelation", "Mass Difference", "", "", self.config)
     pks2 = peakstructure.Peaks()
     pks2.add_peaks(peaks, self.config.massbins)
     pks2.default_params()
     if pks2.plen > 0:
         for p in pks2.peaks:
             if p.ignore == 0:
                 self.plot1.plotadddot(p.mass, p.height, p.color, p.marker)
         self.plot1.repaint()
     print(peaks)
     self.listpanel.list.populate(pks2)
Exemple #8
0
    def pick_scanpeaks(self):
        self.config.write_hdf5()
        self.out = metaunidec_call(self.config, "-scanpeaks")
        self.data.import_hdf5()
        self.sum_masses()

        combined_peaks = self.combine_scanpeaks()

        self.pks = peakstructure.Peaks()
        self.pks.add_peaks(combined_peaks,
                           massbins=self.config.massbins * 0.1,
                           scores_included=True)
        self.pks.default_params(cmap=self.config.peakcmap)

        self.scanpeaks_extracts()
        ud.peaks_error_FWHM(self.pks, self.data.massdat)
        self.peaks_error_replicates(self.pks, self.data.spectra, self.config)

        self.update_history()
        self.export_params()
        pass
Exemple #9
0
 def clear(self):
     self.data = MetaDataSet(self)
     self.pks = peakstructure.Peaks()
Exemple #10
0
            sub = float(sub)
        except:
            sub = None
        self.sub = sub

        div = self.ctldiv.GetValue()
        try:
            div = float(div)
        except:
            div = None
        self.div = div
        self.subdiv()
        self.make_plot()

    def change_type(self, e=None):
        self.replot()


if __name__ == "__main__":
    path = "C:\Python\\UniDec3\\unidec_bin\\Example Data\\POPC_Nanodiscs_unidecfiles\\POPC_Nanodiscs_mass.txt"
    data = np.loadtxt(path)

    pks = peakstructure.Peaks()
    peaks = ud.peakdetect(data, threshold=0.1)
    pks.add_peaks(peaks)

    app = wx.App()
    panel = SubDivFrame(None, data, pks)
    panel.replot()
    app.MainLoop()