Ejemplo n.º 1
0
        def exeCompassXport(self, file2Convert,  newFileName = None):
            t1 = time.clock()
            self.cmdOut = ['CompassXport']

            filetype = str(self.outputFile).split('.')[-1]

            if filetype == 'mzXML':
                self.cmdOut.append(' -mode 0 ')
            elif filetype == 'None':
                self.cmdOut.append(' -mode 0 ')
            elif filetype == 'mzDATA':
                self.cmdOut.append(' -mode 1 ')

            inputFile = ' -a '+file2Convert
            self.cmdOut.append(inputFile)

            if newFileName != None:
                if filetype == 'None':
                    newFileName+='.mzXML'
                    newPath = os.path.join(str(self.fileData), newFileName)

                elif filetype != 'None' and self.useSingleFile == False:
                    newFileName += '.mzXML'
                    newPath = os.path.join(str(self.outputFile), newFileName)
                else:
                    newPath=str(self.outputFile)
            else:
                newFileName='analysis.mzXML'
                self.dir = os.path.dirname(str(self.fileData))
                newPath = os.path.join(self.dir, newFileName)

            #this small code block writes a peak list to a csv file
            try:
                peakList = brukerPeakList(file2Convert)#used for csv
                peakList.saveCSV(os.path.splitext(newPath)[0])#used for csv
            except:
                print "Error converting Bruker peaklist for %s"%file2Convert

            outFile = ' -o '+newPath
            self.cmdOut.append(outFile)

            cmdStr = ''
            for item in self.cmdOut:
                cmdStr += item
            cmdStr +='\n'
            try:

                subHandle = sub.Popen(cmdStr, bufsize = 0, shell = True,  stdout=sub.PIPE, stderr=sub.PIPE,  stdin = sub.PIPE)

                self.outMsg = subHandle.stdout.read()
                self.errMsg = subHandle.stderr.read()
                subHandle.stderr.close()
                subHandle.stdout.close()
                subHandle.stdin.close()
                self.retCode = subHandle.wait()

            ########BEGIN CONVERT TO CSV
                if self.writeCSV:
                    mzr = MzR(newPath)
                    mzr.saveCSV(os.path.splitext(newPath)[0])
            ###############################
                t2 = time.clock()
                runTime= '%s sec\n\n'%(t2-t1)
                if self.retCode != 0:
                    msg = self.outMsg+'\n'+self.errMsg
                    fileupdate = '%d of %d Finished\n'%(self.curFileNum+1, self.totalFiles)
                    msg +=fileupdate
                    msg += runTime
                    return msg
                else:
                    msg = self.outMsg+'\n'+self.errMsg
                    fileupdate = '%d of %d Finished\n'%(self.curFileNum+1, self.totalFiles)
                    msg +=fileupdate
                    msg += runTime
                    return msg
            except:
                print cmdStr
                raise
Ejemplo n.º 2
0
    def exeCompassXport(self, file2Convert,  newFileName = None):
        self.cmdOut = ['CompassXport']

        filetype = str(self.outputFile).split('.')[-1]

        if filetype == 'mzXML':
            self.cmdOut.append(' -mode 0 ')
        elif filetype == 'None':
            self.cmdOut.append(' -mode 0 ')
        elif filetype == 'mzDATA':
            self.cmdOut.append(' -mode 1 ')

        inputFile = ' -a '+file2Convert
        self.cmdOut.append(inputFile)

        if newFileName != None:
            if filetype == 'None':
                newFileName+='.mzXML'
                newPath = os.path.join(str(self.fileData), newFileName)

            elif filetype != 'None' and self.useSingleFile == False:
                newFileName += '.mzXML'
                newPath = os.path.join(str(self.outputFile), newFileName)
            else:
                newPath=str(self.outputFile)
        else:
            newFileName='analysis.mzXML'
            self.dir = os.path.dirname(str(self.fileData))
            newPath = os.path.join(self.dir, newFileName)

        #this small code block writes a peak list to a csv file
        peakList = brukerPeakList(file2Convert)#used for csv
        peakList.saveCSV(os.path.splitext(newPath)[0])#used for csv

        outFile = ' -o '+newPath
        self.cmdOut.append(outFile)

        cmdStr = ''
        for item in self.cmdOut:
            cmdStr += item
        cmdStr +='\n'
        try:

            subHandle = sub.Popen(cmdStr, bufsize = 0, shell = True,  stdout=sub.PIPE, stderr=sub.PIPE,  stdin = sub.PIPE)

            self.outMsg = subHandle.stdout.read()
            self.errMsg = subHandle.stderr.read()
            subHandle.stderr.close()
            subHandle.stdout.close()
            subHandle.stdin.close()
            self.retCode = subHandle.wait()

            if self.retCode != 0:
                self.outputTE.insertPlainText(QtCore.QString(cmdStr))
                msg = self.outMsg+'\n'+self.errMsg
                self.outputTE.insertPlainText(QtCore.QString(msg))
                self.outputTE.update()
            else:
                msg = self.outMsg+'\n'+self.errMsg
                self.outputTE.insertPlainText(QtCore.QString(msg))
                self.outputTE.update()
        except:
            print cmdStr
            raise