Example #1
0
    def _initialize(self):
        """
        called in __init__ of msdialogcontroller
        
        """
        settings=QSettings('INRA/INSA', '-'.join([qApp.instance().APPLICATION_NAME_STR,
                                                  qApp.instance().VERSION_STR]))
        
        if isinstance(self.view, MSMatchedFilteredDialog):
            settings.beginGroup("matchedFilteredDialog")
            self.view.lineEdit_2.setText(settings.value("lineEdit_2", "30").toString())
            self.view.lineEdit_4.setText(settings.value("lineEdit_4", "2").toString())       
            self.view.lineEdit_5.setText(settings.value("lineEdit_5", "0.5").toString())
            self.view.lineEdit_6.setText(settings.value("lineEdit_6", "3").toString())
            self.view.lineEdit_3.setText(settings.value("lineEdit_3", "0.1").toString())
            self.view.spinBox.setValue(settings.value("spinBox", 5).toInt()[0])
            settings.endGroup()

        elif isinstance(self.view, MSCentWaveDialog):
            self.view.lineEdit_2.setText("300-3200")
            self.view.lineEdit_4.setText("10-22")       
            self.view.lineEdit_5.setText("1000")
            self.view.lineEdit_6.setText("1.2")
            self.view.spinBox.setValue(10)
            self.view.spinBox_2.setValue(10)
            self.view.checkBox.setChecked(True)
            
        self.view.lineEdit_7.setText("0.8")
        self.view.lineEdit_8.setText("5")
        self.view.lineEdit_9.setText("20")
        self.view.lineEdit_10.setText("0.002")
        self.view.obiwarp.setChecked(True)
        self.view.gb_2.setChecked(False)
        self.view.gb_3.setChecked(False)
Example #2
0
 def startTask(self):
     self.getParameters()#update parameters
     #self.view.close()#self.closeView()
     self.sampleList = self._buildSampleList(creation=self.creation)
     if not self.sampleList:
         qApp.instance().view.showInformationMessage("Error", "Empty selection")
         return
Example #3
0
 def setModels(self):#, sampleList):
     """
     closing function of the process
     
     """
     qApp.instance().view.showInformationMessage("Clustering done", "Clustering Done succesfully !")
     qApp.instance().view.tabWidget.setCurrentIndex(2)
Example #4
0
 def showSSHConnect(self):
     self.view.close()
     qApp.instance().view.showInformationMessage("Check resources availability", 
                                           "Please, check resources of the cluster availability \
                                           in order to select the best queue")
     web = MSWebBrowser(self.plateformSite, parent=qApp.instance().view)
     qApp.instance().view.addMdiSubWindow(web)
     return SSHHandle(self, parent=self.view).show()
Example #5
0
 def startTask(self):
     self.getParameters()  #update parameters
     #self.view.close()#self.closeView()
     self.sampleList = self._buildSampleList(creation=self.creation)
     if not self.sampleList:
         qApp.instance().view.showInformationMessage(
             "Error", "Empty selection")
         return
Example #6
0
 def smooth():
     window = dialog.a.value()
     order = dialog.b.value()
     method = dialog.a_.currentText()
     dialog.close()          
     qApp.instance().undoStack.push(SmoothUndoCommand(QApplication.instance().model, 
                                                method, window, order,
                                                "Smoothing #%s"%'1'))
Example #7
0
 def getStandardItem(self, peak):
     m=qApp.instance().view.peakModel
     for i in range(qApp.instance().view.peakModel.rowCount()):
         it=m.item(i)
         if it.text()==self.shortPathFiles(peak.sample.xmlfile):
             for i in range(it.rowCount()):
                 if it.child(i).text()=='/'.join([str(peak.mass()), str(peak.rt)]):
                     return it.child(i)
Example #8
0
 def setModels(self):  #, sampleList):
     """
     closing function of the process
     
     """
     qApp.instance().view.showInformationMessage(
         "Clustering done", "Clustering Done succesfully !")
     qApp.instance().view.tabWidget.setCurrentIndex(2)
Example #9
0
 def getStandardItem(self, peak):
     m = qApp.instance().view.peakModel
     for i in range(qApp.instance().view.peakModel.rowCount()):
         it = m.item(i)
         if it.text() == self.shortPathFiles(peak.sample.xmlfile):
             for i in range(it.rowCount()):
                 if it.child(i).text() == '/'.join(
                     [str(peak.mass()), str(peak.rt)]):
                     return it.child(i)
Example #10
0
 def notify_data(self, co, uc, svs, dis, ais, evs):
     '''
     Porpagación a travez de la aplicación de los datos para
     que las partes de la UI que necesiten refrescarse lo hagan
     tan pronto como puedan. De esta manera no es necesario 
     acceder a la base de datos.
     '''
     log.msg('Propagando datos a la GUI de COID: %.2d%.2d' % (co, uc))
     qApp.instance().emit(SIGNAL('data_available'), co, uc, svs, dis, ais, evs)
Example #11
0
 def __init__(self, model, polyDegree, rawData, errorRt, text, parent=None):
     QtGui.QUndoCommand.__init__(self, text, parent)
     self.qApp = QApplication.instance()
     self.model = deepcopy(model)
     self.spectraModel = QtGui.QStandardItemModel(qApp.instance().view.spectraModel)        
     self.peakModel = QtGui.QStandardItemModel(qApp.instance().view.peakModel)
     self.clusterModel = QtGui.QStandardItemModel(qApp.instance().view.clusterModel)        
     self.polyDegree = polyDegree
     self.rawData = rawData#boolean value working on raw data ?
     self.errorRt = errorRt#if we are working on peaks peakgrouping etc...
Example #12
0
 def showSSHConnect(self):
     self.view.close()
     qApp.instance().view.showInformationMessage(
         "Check resources availability",
         "Please, check resources of the cluster availability \
                                           in order to select the best queue"
     )
     web = MSWebBrowser(self.plateformSite, parent=qApp.instance().view)
     qApp.instance().view.addMdiSubWindow(web)
     return SSHHandle(self, parent=self.view).show()
Example #13
0
 def notify_data(self, co, uc, svs, dis, ais, evs):
     '''
     Porpagación a travez de la aplicación de los datos para
     que las partes de la UI que necesiten refrescarse lo hagan
     tan pronto como puedan. De esta manera no es necesario 
     acceder a la base de datos.
     '''
     log.msg('Propagando datos a la GUI de COID: %.2d%.2d' % (co, uc))
     qApp.instance().emit(SIGNAL('data_available'), co, uc, svs, dis, ais,
                          evs)
Example #14
0
    def baselineCorrection(self):
        if not self.model:
            self.view.showErrorMessage("Error", "No sample available...")
            return

        string, boolean = QtGui.QInputDialog.getDouble(self.view, "enter a baseline", "quantile value", value=2e3)
        if not boolean:
            return
        qApp.instance().undoStack.push(BaseLineCorrectionCommand(QApplication.instance().model, 
                                                           string,
                                                           "baselineCorrection #%s"%'1'))
Example #15
0
 def getParameters(self):    
     """
     will get all the parameters, 
     make the difference between 
     the two integration algorithm
     
     """
     settings=QSettings('INRA/INSA', '-'.join([qApp.instance().APPLICATION_NAME_STR,
                                               qApp.instance().VERSION_STR]))
     
     if isinstance(self.view, MSMatchedFilteredDialog):
         self.parameters["fwhm"]=str(self.view.lineEdit_2.text())
         self.parameters["step"]=str(self.view.lineEdit_3.text())
         self.parameters["steps"]=str(self.view.lineEdit_4.text())
         self.parameters["mzdiff"]=str(self.view.lineEdit_5.text())
         self.parameters["snthresh"]=str(self.view.lineEdit_6.text())
         self.parameters["max"]=str(self.view.spinBox.value())
         self.parameters["algorithm"]=0
         #start change
         settings.beginGroup("matchedFilteredDialog")
         settings.setValue("lineEdit_2", self.parameters["fwhm"])
         settings.setValue("lineEdit_4", self.parameters["steps"])       
         settings.setValue("lineEdit_5", self.parameters["mzdiff"])
         settings.setValue("lineEdit_6", self.parameters["snthresh"])
         settings.setValue("lineEdit_3", self.parameters["step"])
         settings.setValue("spinBox", int(self.parameters["max"]))
         settings.endGroup()
     
     elif isinstance(self.view, MSCentWaveDialog):
         self.parameters["scanrange"]=[float(x) for x in self.view.lineEdit_2.text().split('-')]
         self.parameters["integrate"]=1 if self.view.lineEdit_3.isChecked()else 0
         self.parameters["peakwidth"]=[float(x) for x in self.view.lineEdit_4.text().split('-')]
         self.parameters["noise"]=int(self.view.lineEdit_5.text())
         self.parameters["mzdiff"]=float(self.view.lineEdit_6.text())
         self.parameters["ppm"]=int(self.view.spinBox.value())
         self.parameters["snthresh"]=int(self.view.spinBox_2.value())
         self.parameters["fitgauss"]=[self.view.checkBox.isChecked()]
         self.parameters["algorithm"]=1
     #common parameters between the to algorithm
     self.parameters['doGrouping']=True if self.view.gb_2.isChecked()else False
     if self.parameters['doGrouping']:
         self.parameters["minfrac"]=float(self.view.lineEdit_7.text())
         self.parameters["bw"]=int(self.view.lineEdit_8.text())
         self.parameters["max"]=int(self.view.lineEdit_9.text())
         self.parameters["mzwid"]=float(self.view.lineEdit_10.text())
     self.parameters["doAlignment"]=True if self.view.gb_3.isChecked() else False
     if self.parameters["doAlignment"]:
         if self.view.obiwarp.isChecked():
             self.parameters["method"] ='obiwarp'
         if self.view.loess.isChecked():
             self.parameters["method"] ='loess'
Example #16
0
    def plotPeakSelection(self, index, boolean=False):
        """
        Allow to plot peak and peak tables
        
        """
        if not index.isValid():
            return
        data = index.data().toString().split("/")
        prec, rt = float(data[0]), float(data[1])
        peaks = self.getElementsToPlot(flags='peak', prec=prec, rt=rt)
        pw = MSQtCanvas(peaks,
                        "peak@%s/%s" % (str(prec), str(rt)),
                        labels={
                            'bottom': 'RT(s)',
                            'left': 'INTENSITY'
                        },
                        flags='peak')

        QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.redraw)
        title = "peak@%s/%s" % (str(prec), str(rt))
        win = self.view.mdiArea.activeSubWindow()
        isMax = False
        if win is not None and boolean:
            isMax = win.isMaximized()
            w = win.widget()
            #w.connect(w, SIGNAL('destroyed (QObject *)'), self.destroyed)
            #w.setParent(None)
            sip.delete(w)
            del w
            win.setWidget(MSView(pw))
            #win.close()
        else:
            self.view.addMdiSubWindow(MSView(pw), title, isMax)
            self.view.mdiArea.tileSubWindows()
Example #17
0
 def plotSelection(self, index, boolean=False):
     """
     Allow to plot spectrum
     
     """
     if not index.isValid():
         return
     chromas = self.getElementsToPlot(flags='spectra', index=index.row())
     title = "Spectrum@%s" % str(chromas[0].rtmin)
     legend = {'bottom': 'm/z', 'left': 'INTENSITY'}
     flags = 'spectra'
     #useOpenGL=False
     pw = MSQtCanvas(chromas, title, labels=legend,
                     flags=flags)  #, useOpenGL=useOpenGL)
     QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.redraw)
     a = self.view.mdiArea.activeSubWindow()
     isMax = False
     if a is not None and boolean:
         isMax = a.isMaximized()
         w = a.widget()
         #w.connect(w, SIGNAL('destroyed (QObject *)'), self.destroyed)
         #w.setParent(None)
         #print "parent of w just before elimination", w.parent()
         sip.delete(w)  #; del w
         del w
         a.setWidget(pw)
         #a.close()
     else:
         self.view.addMdiSubWindow(pw, title, isMax)
         self.view.mdiArea.tileSubWindows()
Example #18
0
 def startTask(self):  
     MSDialogController.startTask(self)
     self.task = MSIntegrationThread(self.sampleList, **self.parameters)
     
     def begin():
         self.view=None
         self.task.start()
         self.task.exec_()
     self.task.begin = begin
     
     #to avoid QObject::killTimers error, wait for the dialog to be deleted
     QObject.connect(self.view, SIGNAL('destroyed(QObject *)'), self.task.begin)
     QObject.connect(self.task, SIGNAL("started()"),qApp.instance().view.to_indetermined_mode)
     QObject.connect(self.task, SIGNAL("finished()"),self.setModels)
     QObject.connect(self.task, SIGNAL("finished()"),qApp.instance().view.to_determined_mode)
     self.view.close()
Example #19
0
 def plotClusterSelection(self, index, boolean=False):
     """
     Allow to plot peak and cluster tables
     
     """
     if not index.isValid():
         return
     string = str(index.data().toString())#.model().data(index.parent(), Qt.DisplayRole).toString()
     if string in ("fragments/adducts:","isotopic cluster:"):
         return
     
     data = string.split('/')
     #print data
     prec=float(data[0])
     rt = float(data[1])
     #print prec, rt
     peaks=self.getElementsToPlot(flags='peak', prec=prec, rt=rt)
     pw = ClusterWidget(peaks, self.view)#MSQtCanvas(peaks, "peak@%s/%s"%(str(prec), str(rt)), labels={'bottom':'RT(s)', 'left':'INTENSITY'}, flags='peak')
     QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.widget.mainWidget.redraw)
     title="peak@%s/%s"%(str(prec), str(rt))
     win=self.view.mdiArea.activeSubWindow()
     isMax=False
     if win is not None and boolean:
         isMax=win.isMaximized()
         w=win.widget()
         #w.setParent(None)
         sip.delete(w)#
         #del w
         win.setWidget(pw)
     else:
         self.view.addMdiSubWindow(MSView(pw), title, isMax)
         self.view.mdiArea.tileSubWindows()
Example #20
0
 def startTask(self):
     """
     Main Function (model function) Clustering
     
     """
     MSDialogController.startTask(self)
     #qApp.instance().view.showInStatusBar("Clustering Step...Please Wait..",  5000)
     self.task = MSClusterThread(self.sampleList, **self.parameters)
     QObject.connect(self.view, SIGNAL('destroyed(QObject *)'), self.task.begin)
     #self.connect(self.view, SIGNAL('destroyed(QObject *)'), self.setViewToNone)
     QObject.connect(self.task, SIGNAL("started()"),qApp.instance().view.to_determined_mode)
     QObject.connect(self.task, SIGNAL('update_pb'), qApp.instance().view.updateProgressBar)
     #QObject.connect(self.task, SIGNAL("finished()"),qApp.instance().view.to_determined_mode)
     QObject.connect(self.task, SIGNAL("finished()"), self.setModels)
     #print "about to close"
     self.view.close()
Example #21
0
 def plotPeakSelection(self, index, boolean=False):
     """
     Allow to plot peak and peak tables
     
     """                
     if not index.isValid():
         return
     data = index.data().toString().split("/")
     prec, rt =float(data[0]), float(data[1])
     peaks=self.getElementsToPlot(flags='peak', prec=prec, rt=rt)
     pw = MSQtCanvas(peaks, "peak@%s/%s"%(str(prec), str(rt)),
                     labels={'bottom':'RT(s)', 'left':'INTENSITY'}, 
                     flags='peak')
     
     QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.redraw)
     title="peak@%s/%s"%(str(prec), str(rt))
     win=self.view.mdiArea.activeSubWindow()
     isMax=False
     if win is not None and boolean:
         isMax=win.isMaximized()
         w=win.widget()
         #w.connect(w, SIGNAL('destroyed (QObject *)'), self.destroyed)
         #w.setParent(None)
         sip.delete(w)
         del w
         win.setWidget(MSView(pw))
         #win.close()
     else:
         self.view.addMdiSubWindow(MSView(pw), title, isMax)
         self.view.mdiArea.tileSubWindows()
Example #22
0
 def plotSelection(self, index, boolean=False):
     """
     Allow to plot spectrum
     
     """
     if not index.isValid():
         return
     chromas=self.getElementsToPlot(flags='spectra', index=index.row())
     title="Spectrum@%s"%str(chromas[0].rtmin)
     legend={'bottom':'m/z', 'left':'INTENSITY'}
     flags='spectra'
     #useOpenGL=False                
     pw = MSQtCanvas(chromas, title, labels=legend, flags=flags)#, useOpenGL=useOpenGL)
     QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.redraw)            
     a=self.view.mdiArea.activeSubWindow()
     isMax=False
     if a is not None and boolean:
         isMax=a.isMaximized()
         w=a.widget()
         #w.connect(w, SIGNAL('destroyed (QObject *)'), self.destroyed)
         #w.setParent(None)
         #print "parent of w just before elimination", w.parent()
         sip.delete(w)#; del w
         del w
         a.setWidget(pw)
         #a.close()
     else:
         self.view.addMdiSubWindow(pw, title, isMax)
         self.view.mdiArea.tileSubWindows()
Example #23
0
    def _workingOn(self):
#        if self.acTree not in self.workingTrees: #can work by name too
#        qApp.instance().view.showErrorMessage("Error", """<br>Error when trying to select items from treeView</br>
#                                                        #<p>Select a tab corresponding to the action you want""")
        try:
            self.view.lineEdit.setText(self.stringFormatting([spl.xmlfile for spl in qApp.instance().model if spl.checked]))
        except AttributeError:
            pass
Example #24
0
    def __init__(self, data, title, flags="chroma", parent=None, **k):
        QWidget.__init__(self, parent)
        MSDialogController.__init__(self, 0, parent)

        self.model = self.qApp.model
        self.view = self.qApp.view

        self.data = data
        self.title = title
        self.flags = flags

        if self.flags == 'peak':
            if self.acTree not in (self.view.treeView_2, self.view.treeView_3):
                print "Unknown Error"
                return
            idx = self.acTree.selectedIndexes()[0]
            s = qApp.instance().dockControl.currentSample[
                1 if self.acTree is self.view.treeView_2 else 2]
            if s is None:
                print "unknow error"
                return
            values = map(float, idx.data().toString().split('/')[:2])
            self.currentPeak = s.peakAt(*values)
            #connection to update the selected Peak object
            self.connect(self.acTree, SIGNAL("changedLine"),
                         self.updateCurrentPeak)

        self.minX, self.maxX, self.maxY = [0] * 3
        #if flags != 'peak':
        #    self.minX, self.maxX, self.maxY = self.getMax()
        self.pw = PlotWidget(self.minX, self.maxX, self.maxY, parent=self,
                             **k)  #parent=self,
        #self.pw.setAttribute(Qt.WA_DeleteOnClose)#plotItem.setAttribute(Qt.WA_PaintOnScreen & Qt.WA_PaintUnclipped)
        if k.get('antialiased', False):
            self.pw.setRenderHint(0x01)  #antialiasing i suppose
        self.pw.setTitle(title)
        self.pw.updateGrid()

        self._setupUi()

        self.connect(self, SIGNAL('linePlotted'), self.updateContextMenu)
        self.connect(self.view.sampleTableView,
                     SIGNAL("disHighlightRequested(QModelIndex)"),
                     self.disHighlightOne)
        self.connect(self.view.sampleTableView,
                     SIGNAL("highlightRequested(QModelIndex)"), self.highlight)
        self.connect(self.view.sampleTableView,
                     SIGNAL("noHighlightRequested()"), self.disHighlight)
        self.connect(self.view.ppmEditer, SIGNAL('valueChanged(double)'),
                     self.redrawAll)

        self.drawnItems = {}
        self.trashItems = []  #why unecessary? nope to collect annotation stuff
        self.textLabels = []
        self.pixmaps = []
        self.dataPoints = None

        self._plotting(self.data)  #initial plotting
Example #25
0
 def normalizeSamples(self):
     if not self.model:
         self.view.showErrorMessage("Error", "no sample found...")
         return
     class Dialog(QtGui.QDialog):
         def __init__(self, parent=None):
             QtGui.QDialog.__init__(self, parent)
             self.setupUi()
             self.connect(self.comboBox, SIGNAL('currentIndexChanged(const QString &)'), self.updateCombo)
             self.connect(self.comboBox_2, SIGNAL('currentIndexChanged(const QString &)'), self.updateLabel)
             self.peak = None
         def setupUi(self):
             v = QtGui.QVBoxLayout()
             f = QtGui.QFormLayout()
             self.comboBox = QtGui.QComboBox()
             self.items = [spl.shortName() for spl in QApplication.instance().model]
             self.comboBox.addItems(self.items)
             f.addRow("Choose One sample", self.comboBox)
             self.comboBox_2 = QtGui.QComboBox()
             f.addRow("Peak", self.comboBox_2)
             self.label = QtGui.QLabel()
             f.addRow("Area", self.label)
             self.checkBox = QtGui.QCheckBox("Apply to all", self)
             self.buttonBox = QtGui.QDialogButtonBox(self)
             self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
             v.addLayout(f)
             v.addWidget(self.checkBox)
             v.addWidget(self.buttonBox)                
             self.setLayout(v)
         
         def updateCombo(self, string):
             items = [str(p) for p in QApplication.instance().model.sample(string, fullNameEntry=False).irawPeaks()]
             self.comboBox_2.clear()
             self.comboBox_2.addItems(items)
         
         def updateLabel(self, string):
             self.peak = QApplication.instance().model.sample(self.comboBox.currentText(), 
                                    fullNameEntry=False).peakAt(*map(float, string.split('/')))
             self.label.setText(str(self.peak.area))
     
     dialog = Dialog(self.view)
     dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
     dialog.updateCombo(qApp.instance().model[0].shortName())
     def norm():
         applyToAll = dialog.checkBox.isChecked()
         samplesToTreat = [spl for spl in self.model] if applyToAll else [self.model.sample(dialog.comboBox.currentText(), 
                                                                                             fullNameEntry=False)]
         peak = dialog.peak
         if peak is None:
             return
         dialog.close()
         for spl in samplesToTreat:
             spl.normalize(peak)
             
     QObject.connect(dialog.buttonBox, SIGNAL('rejected()'), dialog.close)
     QObject.connect(dialog.buttonBox, SIGNAL('accepted()'), norm)
     dialog.exec_()
Example #26
0
 def startTask(self):
     """
     Main Function (model function) Clustering
     
     """
     MSDialogController.startTask(self)
     #qApp.instance().view.showInStatusBar("Clustering Step...Please Wait..",  5000)
     self.task = MSClusterThread(self.sampleList, **self.parameters)
     QObject.connect(self.view, SIGNAL('destroyed(QObject *)'),
                     self.task.begin)
     #self.connect(self.view, SIGNAL('destroyed(QObject *)'), self.setViewToNone)
     QObject.connect(self.task, SIGNAL("started()"),
                     qApp.instance().view.to_determined_mode)
     QObject.connect(self.task, SIGNAL('update_pb'),
                     qApp.instance().view.updateProgressBar)
     #QObject.connect(self.task, SIGNAL("finished()"),qApp.instance().view.to_determined_mode)
     QObject.connect(self.task, SIGNAL("finished()"), self.setModels)
     #print "about to close"
     self.view.close()
Example #27
0
    def _initialize(self):
        """
        called in __init__ of msdialogcontroller
        
        """
        settings = QSettings(
            'INRA/INSA', '-'.join([
                qApp.instance().APPLICATION_NAME_STR,
                qApp.instance().VERSION_STR
            ]))

        if isinstance(self.view, MSMatchedFilteredDialog):
            settings.beginGroup("matchedFilteredDialog")
            self.view.lineEdit_2.setText(
                settings.value("lineEdit_2", "30").toString())
            self.view.lineEdit_4.setText(
                settings.value("lineEdit_4", "2").toString())
            self.view.lineEdit_5.setText(
                settings.value("lineEdit_5", "0.5").toString())
            self.view.lineEdit_6.setText(
                settings.value("lineEdit_6", "3").toString())
            self.view.lineEdit_3.setText(
                settings.value("lineEdit_3", "0.1").toString())
            self.view.spinBox.setValue(settings.value("spinBox", 5).toInt()[0])
            settings.endGroup()

        elif isinstance(self.view, MSCentWaveDialog):
            self.view.lineEdit_2.setText("300-3200")
            self.view.lineEdit_4.setText("10-22")
            self.view.lineEdit_5.setText("1000")
            self.view.lineEdit_6.setText("1.2")
            self.view.spinBox.setValue(10)
            self.view.spinBox_2.setValue(10)
            self.view.checkBox.setChecked(True)

        self.view.lineEdit_7.setText("0.8")
        self.view.lineEdit_8.setText("5")
        self.view.lineEdit_9.setText("20")
        self.view.lineEdit_10.setText("0.002")
        self.view.obiwarp.setChecked(True)
        self.view.gb_2.setChecked(False)
        self.view.gb_3.setChecked(False)
Example #28
0
 def _workingOn(self):
     #        if self.acTree not in self.workingTrees: #can work by name too
     #        qApp.instance().view.showErrorMessage("Error", """<br>Error when trying to select items from treeView</br>
     #                                                        #<p>Select a tab corresponding to the action you want""")
     try:
         self.view.lineEdit.setText(
             self.stringFormatting([
                 spl.xmlfile for spl in qApp.instance().model if spl.checked
             ]))
     except AttributeError:
         pass
Example #29
0
    def startTask(self):
        MSDialogController.startTask(self)
        self.task = MSIntegrationThread(self.sampleList, **self.parameters)

        def begin():
            self.view = None
            self.task.start()
            self.task.exec_()

        self.task.begin = begin

        #to avoid QObject::killTimers error, wait for the dialog to be deleted
        QObject.connect(self.view, SIGNAL('destroyed(QObject *)'),
                        self.task.begin)
        QObject.connect(self.task, SIGNAL("started()"),
                        qApp.instance().view.to_indetermined_mode)
        QObject.connect(self.task, SIGNAL("finished()"), self.setModels)
        QObject.connect(self.task, SIGNAL("finished()"),
                        qApp.instance().view.to_determined_mode)
        self.view.close()
Example #30
0
 def cleaningRepository(self, c):
     in_, out, err =c.exec_command('cd work/ && ls')
     res = qApp.instance().view.showWarningMessage("Non Empty remote repository", 
                                                "the remote repository is not empty, do you want to remove all files?")
     if res!=4194304:
         #c.exec_command('cd work/ && rm -rf *')#to much agressive
         try:
             c.exec_command('cd work && rm %s && rm %s'%(self.XCMS_SCRIPT, self.SHELL_SCRIPT))
         except Exception:
             pass
         return True
     return False
Example #31
0
 def startConnection(self): 
     """
     connection to remote server
     can launch a thread checking every minute your mailbox...
     """
     #if not self.directory:return
     #self.parent().close()
     self.close()
     client = SSHClient()
     client.set_missing_host_key_policy(AutoAddPolicy())
     try:
         client.connect(str(self.host.text()), username=str(self.username.text()), password=str(self.password.text()))
     except SSHException: qApp.instance().showErrorMessage("Error", "The ssh session could not be established")
     except AuthenticationException: qApp.instance().showErrorMessage("Error","Authentication failed")
     except BadHostKeyException: qApp.instance().showErrorMessage("Error", "the server's host key could not be verified")
     
     sftpCp = self.cleaningRepository(client)
     if sftpCp:
         sftp = client.open_sftp()
         self.sftpCopying(sftp)
         sftp.close()
     else:
         self.retrieveDirTree(c, out)
     self.makeRScript(client)
     self.makeShellScript(client)
     if self.interactiveSession.isChecked():
         import interactive
         print ('invoking a shell')
         chan = client.invoke_shell()
         chan.send('bash\n')
         interactive.interactive_shell(chan)
         chan.close()
     else:
         self.launchCommand(client)
     client.close()
Example #32
0
 def annotate(self):
     text, bool_ = QInputDialog.getText(self.view, "Annotation dialog", "Annotation:")
     g=QGraphicsTextItem(str(text))
     g.setFlag(QGraphicsItem.ItemIgnoresTransformations)
     g.setFlag(QGraphicsItem.ItemIsMovable)
     g.setTextInteractionFlags(Qt.TextEditorInteraction)
     font=qApp.instance().font()
     font.setPointSizeF(10.)
     g.setFont(font)
     g.setDefaultTextColor(Qt.blue)
     g.setPos(500,1e4)
     self.trashItems.append(g)
     self.pw.addItem(g)
Example #33
0
    def __init__(self, data, title, flags="chroma", parent=None, **k):
        QWidget.__init__(self, parent)
        MSDialogController.__init__(self, 0, parent)
        
        self.model = self.qApp.model
        self.view =  self.qApp.view
      
        self.data=data
        self.title=title
        self.flags=flags
        
        if self.flags == 'peak':
            if self.acTree not in (self.view.treeView_2, self.view.treeView_3):
                print "Unknown Error"
                return
            idx=self.acTree.selectedIndexes()[0]
            s = qApp.instance().dockControl.currentSample[1 if self.acTree is self.view.treeView_2 else 2]
            if s is None:
                print "unknow error"
                return            
            values = map(float, idx.data().toString().split('/')[:2])
            self.currentPeak = s.peakAt(*values)
            #connection to update the selected Peak object
            self.connect(self.acTree, SIGNAL("changedLine"), self.updateCurrentPeak)
        
        self.minX, self.maxX, self.maxY  = [0] * 3
        #if flags != 'peak':
        #    self.minX, self.maxX, self.maxY = self.getMax()
        self.pw = PlotWidget(self.minX, self.maxX, self.maxY,  parent=self, **k)#parent=self,
        #self.pw.setAttribute(Qt.WA_DeleteOnClose)#plotItem.setAttribute(Qt.WA_PaintOnScreen & Qt.WA_PaintUnclipped)
        if k.get('antialiased', False):
            self.pw.setRenderHint(0x01)#antialiasing i suppose
        self.pw.setTitle(title)
        self.pw.updateGrid()

        
        self._setupUi()        
        
        self.connect(self, SIGNAL('linePlotted'), self.updateContextMenu)
        self.connect(self.view.sampleTableView, SIGNAL("disHighlightRequested(QModelIndex)"), self.disHighlightOne)
        self.connect(self.view.sampleTableView, SIGNAL("highlightRequested(QModelIndex)"), self.highlight)
        self.connect(self.view.sampleTableView, SIGNAL("noHighlightRequested()"), self.disHighlight)
        self.connect(self.view.ppmEditer, SIGNAL('valueChanged(double)'), self.redrawAll)
        
        self.drawnItems = {} 
        self.trashItems=[]#why unecessary? nope to collect annotation stuff
        self.textLabels = []
        self.pixmaps = []
        self.dataPoints = None
        
        self._plotting(self.data)#initial plotting
Example #34
0
 def setModels(self):
     """
     end processing 
     
     """
     qApp.instance().view.comparativeTableView.setModel(MSDialogController.actualizePeakModelComparative())
     qApp.instance().view.showInformationMessage("Integration Done", "Integration process finished...")
     qApp.instance().view.tabWidget.setCurrentIndex(1)
Example #35
0
 def activeTree(self, integer):
     window = qApp.instance().view
     if integer not in (0, 1, 2):
         #raise ValueError("TreeView numeroted from 0 to 2")
         return #no raising an error....
     if integer == 0:
         self.acTree = window.treeView
         self.acModel = window.spectraModel
     elif integer == 1:
         self.acTree = window.treeView_2
         self.acModel = window.peakModel
     elif integer == 2:
         self.acTree = window.treeView_3
         self.acModel = window.clusterModel
Example #36
0
 def activeTree(self, integer):
     window = qApp.instance().view
     if integer not in (0, 1, 2):
         #raise ValueError("TreeView numeroted from 0 to 2")
         return  #no raising an error....
     if integer == 0:
         self.acTree = window.treeView
         self.acModel = window.spectraModel
     elif integer == 1:
         self.acTree = window.treeView_2
         self.acModel = window.peakModel
     elif integer == 2:
         self.acTree = window.treeView_3
         self.acModel = window.clusterModel
Example #37
0
 def annotate(self):
     text, bool_ = QInputDialog.getText(self.view, "Annotation dialog",
                                        "Annotation:")
     g = QGraphicsTextItem(str(text))
     g.setFlag(QGraphicsItem.ItemIgnoresTransformations)
     g.setFlag(QGraphicsItem.ItemIsMovable)
     g.setTextInteractionFlags(Qt.TextEditorInteraction)
     font = qApp.instance().font()
     font.setPointSizeF(10.)
     g.setFont(font)
     g.setDefaultTextColor(Qt.blue)
     g.setPos(500, 1e4)
     self.trashItems.append(g)
     self.pw.addItem(g)
Example #38
0
 def cleaningRepository(self, c):
     in_, out, err = c.exec_command('cd work/ && ls')
     res = qApp.instance().view.showWarningMessage(
         "Non Empty remote repository",
         "the remote repository is not empty, do you want to remove all files?"
     )
     if res != 4194304:
         #c.exec_command('cd work/ && rm -rf *')#to much agressive
         try:
             c.exec_command('cd work && rm %s && rm %s' %
                            (self.XCMS_SCRIPT, self.SHELL_SCRIPT))
         except Exception:
             pass
         return True
     return False
Example #39
0
 def setModels(self):
     """
     end processing 
     
     """
     qApp.instance().view.comparativeTableView.setModel(
         MSDialogController.actualizePeakModelComparative())
     qApp.instance().view.showInformationMessage(
         "Integration Done", "Integration process finished...")
     qApp.instance().view.tabWidget.setCurrentIndex(1)
Example #40
0
 def getSftp(self):
     client = SSHClient()
     client.set_missing_host_key_policy(AutoAddPolicy())
     try:
         client.connect(str(self.host.text()), username=str(self.username.text()), password=str(self.password.text()))
     except SSHException: qApp.instance().showErrorMessage("Error", "The ssh session could not be established")
     except AuthenticationException: qApp.instance().showErrorMessage("Error","Authentication failed")
     except BadHostKeyException: qApp.instance().showErrorMessage("Error", "the server's host key could not be verified")
     sftp = client.open_sftp()
     sftp.get('/work/matrice', './matrice')
     sftp.close()
     client.close()
Example #41
0
 def plotTICS(self):
     chromas=self.getElementsToPlot(flags='chroma')
     title="TICS"
     legend={'bottom':'RT(s)', 'left':'INTENSITY'}
     flags='chroma'
     pw = MSQtCanvas(chromas, title, labels=legend, flags=flags)#, useOpenGL=useOpenGL)
     
     QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.redraw)            
     a=self.view.mdiArea.activeSubWindow()
     isMax=False
     if a is not None:
         isMax=a.isMaximized()
         w=a.widget()
         w.setParent(None)
         sip.delete(w)
         a.setWidget(pw)
     else:
         self.view.addMdiSubWindow(MSView(pw), title, isMax)
         self.view.mdiArea.tileSubWindows()
Example #42
0
    def __init__(self, model, view):
        """constructor
        @parameter view: the view (dialog)
        @parameter model: the model, data to manipulate, string,
        file, sample, sampleList...
        @parent: it is admitted the view is the parent of her
        controller

        """
        self.view = view
        self.model = model

        self.acModel = None
        self.acTree = None

        window = self.qApp.view  #to avoid error when using a QDialogController
        self.activeTree(window.tabWidget.currentIndex())
        QObject.connect(window.tabWidget, SIGNAL('currentChanged(int)'), self.activeTree)
        QObject.connect(qApp.instance(), SIGNAL('modelChanged'), self.setModel)  #update model, used for loading a project
        self._buildConnections()
Example #43
0
    def plotTICS(self):
        chromas = self.getElementsToPlot(flags='chroma')
        title = "TICS"
        legend = {'bottom': 'RT(s)', 'left': 'INTENSITY'}
        flags = 'chroma'
        pw = MSQtCanvas(chromas, title, labels=legend,
                        flags=flags)  #, useOpenGL=useOpenGL)

        QObject.connect(qApp.instance(), SIGNAL('redraw()'), pw.redraw)
        a = self.view.mdiArea.activeSubWindow()
        isMax = False
        if a is not None:
            isMax = a.isMaximized()
            w = a.widget()
            w.setParent(None)
            sip.delete(w)
            a.setWidget(pw)
        else:
            self.view.addMdiSubWindow(MSView(pw), title, isMax)
            self.view.mdiArea.tileSubWindows()
Example #44
0
 def  redo(self):
     m = QApplication.instance().model
     if self.rawData:
         m.alignRawData(m)
     else:
         m.alignPeaksInRTDimension(m, self.polyDegree, self.errorRt)
     for tree in (qApp.instance().view.treeView, qApp.instance().view.treeView_2, qApp.instance().view.treeView_3):
         tree.removeAll()
     for spl in qApp.instance().model:
         MSDialogController.actualizeSpectraModel(spl)
         if spl.rawPeaks:
             MSDialogController.actualizePeakModel(spl)
         if spl.mappedPeaks:
             MSDialogController.actualizeClusterModel(spl)
     qApp.instance().view.showInformationMessage('Alignment calculation done', "Alignment done")
Example #45
0
    def __init__(self, model, view):
        """constructor
        @parameter view: the view (dialog)
        @parameter model: the model, data to manipulate, string,
        file, sample, sampleList...
        @parent: it is admitted the view is the parent of her
        controller

        """
        self.view = view
        self.model = model

        self.acModel = None
        self.acTree = None

        window = self.qApp.view  #to avoid error when using a QDialogController
        self.activeTree(window.tabWidget.currentIndex())
        QObject.connect(window.tabWidget, SIGNAL('currentChanged(int)'),
                        self.activeTree)
        QObject.connect(
            qApp.instance(), SIGNAL('modelChanged'),
            self.setModel)  #update model, used for loading a project
        self._buildConnections()
Example #46
0
    def plotClusterSelection(self, index, boolean=False):
        """
        Allow to plot peak and cluster tables
        
        """
        if not index.isValid():
            return
        string = str(index.data().toString(
        ))  #.model().data(index.parent(), Qt.DisplayRole).toString()
        if string in ("fragments/adducts:", "isotopic cluster:"):
            return

        data = string.split('/')
        #print data
        prec = float(data[0])
        rt = float(data[1])
        #print prec, rt
        peaks = self.getElementsToPlot(flags='peak', prec=prec, rt=rt)
        pw = ClusterWidget(
            peaks, self.view
        )  #MSQtCanvas(peaks, "peak@%s/%s"%(str(prec), str(rt)), labels={'bottom':'RT(s)', 'left':'INTENSITY'}, flags='peak')
        QObject.connect(qApp.instance(), SIGNAL('redraw()'),
                        pw.widget.mainWidget.redraw)
        title = "peak@%s/%s" % (str(prec), str(rt))
        win = self.view.mdiArea.activeSubWindow()
        isMax = False
        if win is not None and boolean:
            isMax = win.isMaximized()
            w = win.widget()
            #w.setParent(None)
            sip.delete(w)  #
            #del w
            win.setWidget(pw)
        else:
            self.view.addMdiSubWindow(MSView(pw), title, isMax)
            self.view.mdiArea.tileSubWindows()
Example #47
0
 def getSftp(self):
     client = SSHClient()
     client.set_missing_host_key_policy(AutoAddPolicy())
     try:
         client.connect(str(self.host.text()),
                        username=str(self.username.text()),
                        password=str(self.password.text()))
     except SSHException:
         qApp.instance().showErrorMessage(
             "Error", "The ssh session could not be established")
     except AuthenticationException:
         qApp.instance().showErrorMessage("Error", "Authentication failed")
     except BadHostKeyException:
         qApp.instance().showErrorMessage(
             "Error", "the server's host key could not be verified")
     sftp = client.open_sftp()
     sftp.get('/work/matrice', './matrice')
     sftp.close()
     client.close()
Example #48
0
    def startConnection(self):
        """
        connection to remote server
        can launch a thread checking every minute your mailbox...
        """
        #if not self.directory:return
        #self.parent().close()
        self.close()
        client = SSHClient()
        client.set_missing_host_key_policy(AutoAddPolicy())
        try:
            client.connect(str(self.host.text()),
                           username=str(self.username.text()),
                           password=str(self.password.text()))
        except SSHException:
            qApp.instance().showErrorMessage(
                "Error", "The ssh session could not be established")
        except AuthenticationException:
            qApp.instance().showErrorMessage("Error", "Authentication failed")
        except BadHostKeyException:
            qApp.instance().showErrorMessage(
                "Error", "the server's host key could not be verified")

        sftpCp = self.cleaningRepository(client)
        if sftpCp:
            sftp = client.open_sftp()
            self.sftpCopying(sftp)
            sftp.close()
        else:
            self.retrieveDirTree(c, out)
        self.makeRScript(client)
        self.makeShellScript(client)
        if self.interactiveSession.isChecked():
            import interactive
            print('invoking a shell')
            chan = client.invoke_shell()
            chan.send('bash\n')
            interactive.interactive_shell(chan)
            chan.close()
        else:
            self.launchCommand(client)
        client.close()
Example #49
0
 def stopped(self):
     qApp.instance().win.actionStart.setChecked(False)
     qApp.instance().win.statusbar.showMessage('Scada detenido')
Example #50
0
 def setParams():
     multiCore = d.multiCore.isChecked()
     lowMemory = d.lowMemory.isChecked()
     d.close()
     qApp.instance().multiCore = multiCore
     qApp.instance().lowMemory = lowMemory
Example #51
0
 def _buildConnections(self):
     #undo redo stuffs
     QObject.connect(qApp.instance().undoStack, 
                  SIGNAL('canRedoChanged(bool)'), 
                  self.view.editMenu.actions()[1].setEnabled)
     QObject.connect(qApp.instance().undoStack, 
                  SIGNAL('canUndoChanged(bool)'), 
                  self.view.editMenu.actions()[0].setEnabled)
     
     #tooltip emulation TODO
     QObject.connect(self.view.peakPickingMenu, 
                  SIGNAL("hovered(QAction *)"), 
                  self.view._actionHovered)
     QObject.connect(self.view.fileMenu, 
                  SIGNAL("hovered(QAction *)"), 
                  self.view._actionHovered)
     
     #file menu
     QObject.connect(self.view.op.actions()[0], 
                  SIGNAL("triggered()"), 
                  self.openFile)
     QObject.connect(self.view.op.actions()[1],
                  SIGNAL('triggered()'),
                  self.loadProject)
     
     QObject.connect(self.view.fileMenu.actions()[1], 
                  SIGNAL("triggered()"), 
                  self.saveProject)
     QObject.connect(self.view.fileMenu.actions()[2], 
                  SIGNAL("triggered()"), 
                  self.loadPeakList)
     QObject.connect(self.view.fileMenu.actions()[3], 
                  SIGNAL("triggered()"), 
                  self.convertParameters)
     QObject.connect(self.view.fileMenu.actions()[4], 
                  SIGNAL("triggered()"), 
                  self.launchBatch)
     QObject.connect(self.view.fileMenu.actions()[5], 
                  SIGNAL("triggered()"), 
                  self.mergeFile)
     QObject.connect(self.view.fileMenu.actions()[7], 
                  SIGNAL("triggered()"), 
                  self.quit)
      
     #edit menu
     QObject.connect(self.view.editMenu.actions()[0],
                  SIGNAL('triggered()'),
                  QApplication.instance().undoStack.undo)
     QObject.connect(self.view.editMenu.actions()[1],
                  SIGNAL('triggered()'),
                  QApplication.instance().undoStack.redo)
     QObject.connect(self.view.editMenu.actions()[3], 
                     SIGNAL('triggered()'),
                     self.showSettings)
     QObject.connect(self.view.exportMenu.actions()[0], 
                     SIGNAL('triggered()'),
                     self.exportPeakList)
     QObject.connect(self.view.exportMenu.actions()[1],
                     SIGNAL('triggered()'),
                     self.exportClusterMatrix)
     
     
     #algo menu
     QObject.connect(self.view.preProcessing.actions()[0], 
                 SIGNAL('triggered()'), 
                 self.smoothAllRawData)
     QObject.connect(self.view.preProcessing.actions()[1], 
                 SIGNAL('triggered()'), 
                 self.baselineCorrection)
     QObject.connect(self.view.preProcessing.actions()[2],
                  SIGNAL('triggered()'),
                  self.calibrate)
     QObject.connect(self.view.preProcessing.actions()[3],
                  SIGNAL('triggered()'),
                  self.resizeSample)
     
     
     
     QObject.connect(self.view.peakPickingMenu.actions()[0], 
                  SIGNAL("triggered()"), 
                  self.integrationParameters)
     QObject.connect(self.view.peakPickingMenu.actions()[1], 
                  SIGNAL("triggered()"), 
                  self.centWaveParameters)
     
     #alignment        
     QObject.connect(self.view.alignment.actions()[0],
                     SIGNAL("triggered()"),
                     self.alignmentByPolyFit)
     QObject.connect(self.view.alignment.actions()[1],
                     SIGNAL('triggered()'),
                     self.alignmentByDtw)
     QObject.connect(self.view.alignment.actions()[2],
                     SIGNAL("triggered()"),
                     self.alignmentByObiWarp)
     
     QObject.connect(self.view.algoMenu.actions()[3],
                     SIGNAL('triggered()'), 
                     self.normalizeSamples)
     QObject.connect(self.view.algoMenu.actions()[4], 
                  SIGNAL("triggered()"), 
                  self.clusteringParameters)
     QObject.connect(self.view.algoMenu.actions()[5], 
                  SIGNAL("triggered()"), 
                  self.identificationParameters)
     
     
     
     #view menu
     QObject.connect(self.view.plotting.actions()[0], 
                  SIGNAL("triggered()"),
                  self.show3DView)
     #QObject.connect(self.view.plotting.actions()[1], 
     #             SIGNAL("triggered()"),
     #             self.launchCytoscape)
     QObject.connect(self.view.plotting.actions()[1], 
                  SIGNAL("triggered()"),
                  self.showSpectrogramView)
     #self.connect(self.view.plotting.actions()[3], 
     #             SIGNAL("triggered()"),
     #             self.showAlignedData)
     
     #tools menu
     QObject.connect(self.view.toolsMenu.actions()[0], 
                  SIGNAL("triggered()"),
                  self.launchWebNavigator)
     #QObject.connect(self.view.toolsMenu.actions()[1], 
     #             SIGNAL("triggered()"),
     #             self.launchCytoscape)
     QObject.connect(self.view.toolsMenu.actions()[1], 
                  SIGNAL("triggered()"),
                  self.launchEricEditor)
     QObject.connect(self.view.toolsMenu.actions()[2], 
                  SIGNAL("triggered()"),
                  self.showPeriodicTable)
     
     
     #plugins menu
     QObject.connect(self.view.launchingMenu, 
                  SIGNAL('triggered(QAction*)'), 
                  self.loadPlugin)
     QObject.connect(self.view.pluginMenu.actions()[2], 
                  SIGNAL('triggered()'), 
                  self.deletePlugs)
     
     #about
     QObject.connect(self.view.aboutMenu.actions()[0], 
                  SIGNAL("triggered()"), 
                  self.view.showMetMSInformation)
     QObject.connect(self.view.aboutMenu.actions()[1], 
                  SIGNAL("triggered()"),
                  self.showQtInformation)
                  
     QObject.connect(self.view.aboutMenu.actions()[2], 
                  SIGNAL("triggered()"),
                  self.showDocumentation)
Example #52
0
 def packageRecieved(self, pkg):
     PicnetSCADAProtocol.packageRecieved(self, pkg)
     cadena = "%s\n" % pkg.hex_dump()
     qApp.instance().emit(SIGNAL('data_received'), cadena)
Example #53
0
 def undo(self):
     qApp.instance().model=self.model
     qApp.instance().currentModelChanged()
     qApp.instance().view.spectraModel = self.spectraModel
     qApp.instance().view.peakModel = self.peakModel
     qApp.instance().view.clusterModel = self.clusterModel
     qApp.instance().view.treeView.setModel(qApp.instance().view.spectraModel)
     qApp.instance().view.treeView_2.setModel(qApp.instance().view.peakModel)
     qApp.instance().view.treeView_3.setModel(qApp.instance().view.clusterModel)
     qApp.instance().view.showInformationMessage('Alignment Undone', 'Alignment Undone')
Example #54
0
    def _plotting(self, data):
        """
        refactor this shit
        c = Line(chrom.x_data, chrom.y_data, 
                 QColor.fromRgbF(*(self.ref.sample.color+(.7,))),
                 parent=self.pw.plotItem.vb, 
                 scene=self.pw.scene())
        
        #test scatter plot
        self.scatter = ScatterPlotItem(x=chrom.x_data, y=chrom.y_data)
        self.pw.addDataItem(self.scatter)
        self.scatter.sigClicked.connect(self.requestSpectra)
        
        """
        if self.flags == 'peak':

            self.connect(self.pw.plotItem.vb,
                         SIGNAL('showDiffOrSpectra(PyQt_PyObject)'),
                         self.drawSpectra)
            self.ref = sorted([e for e in data if e is not None],
                              key=lambda x: x.height)[-1]
            ppm = self.view.ppmEditer.value() if self.view.usePpm.isChecked(
            ) else self.ref.sample.ppm
            chrom = self.ref.sample.massExtraction(self.ref.mass(),
                                                   ppm,
                                                   asChromatogram=True)
            #show labels
            self.textLabels += self.showTextLabel(chrom.x_data, chrom.y_data)
            #drawing
            color = QColor.fromRgbF(*self.ref.sample.color + (.5, ))

            c = self.pw.plotItem.plot(chrom.x_data, chrom.y_data, pen=color)
            self.drawnItems[self.ref.sample] = c
            # peak's pixmap on the ref peak
            pix = PeakArrowItem(self.ref,
                                pen=color,
                                brush=color,
                                pos=(self.ref.rt, self.ref.height +
                                     (self.ref.height * 6) / 100.),
                                angle=-90,
                                parent=self.pw.plotItem.vb)
            pix.setZValue(1000)
            self.pw.addItem(pix)
            #both these connections are emitted
            #in peak Indicator by effictivamente qApp
            self.connect(qApp.instance(), SIGNAL("highlightRequested"),
                         c.setHighlighted)
            self.connect(qApp.instance(), SIGNAL('updateBarPlot'),
                         self.barPlot.setPeakGroup)  #
            self.emit(SIGNAL('linePlotted'), self.ref.sample.shortName())

            #if qApp.instance().lowMemory:
            #    chromatograms=[el.sample.loadAndExtract(el.mass(), el.sample.ppm, asChromatogram=True) \
            #                  for el in data if el != ref and el is not None]
            #else:
            ppm = self.view.ppmEditer.value() if self.view.usePpm.isChecked(
            ) else self.ref.sample.ppm
            chromatograms=[el.sample.massExtraction(el.mass(), ppm, asChromatogram=True) \
                          for el in data if el is not None and el != self.ref]
            self.drawEics(chromatograms)
            #initialisation zoom on the peak
            self.pw.setYRange(0.,
                              self.ref.height + (self.ref.height * 12) / 100.)
            self.pw.setXRange(self.ref.rtmin - 20, self.ref.rtmax + 20)

        elif self.flags == 'chroma':
            ref = [d for d in data if d is not None]
            if not ref:
                print "Error, empty data to plot"
                return
            self.ref = ref[0]
            self.textLabels += self.showTextLabel(self.ref.x_data,
                                                  self.ref.y_data)
            self.drawEics(data)

        else:  #spectrum
            if not data:
                #print "NOTHING TO PLOT"
                return
            self.ref = data[0]
            for el in data:
                c = SpectrumItem(el, centroid=True, scene=self.pw.scene())
                self.pw.addItem(c)
                self.drawnItems[el.sample] = c
                self.pw.plotItem.curves.append(c)
                self.emit(SIGNAL('linePlotted'), el.sample.shortName())
            #just put time information
            if data:
                i = 0
                while data[i] is None and i < len(data):
                    i += 1
                self.textLabels += self.showTextLabel(data[i].x_data,
                                                      data[i].y_data)
            #setting the range
            #warning: autoRange pw function does not work well
            #on spectrum item
            maxY = max([el.y_data.max() for el in data])
            minX, maxX = min([el.x_data.min() for el in data
                              ]), max([el.x_data.max() for el in data])
            self.pw.setXRange(minX, maxX, padding=0)
            self.pw.setYRange(0., maxY, padding=0)
Example #55
0
 def started(self):
     qApp.instance().win.statusbar.showMessage('Scada iniciado')