当前位置: 首页>>代码示例>>Python>>正文


Python Helper.Helper类代码示例

本文整理汇总了Python中Helper.Helper的典型用法代码示例。如果您正苦于以下问题:Python Helper类的具体用法?Python Helper怎么用?Python Helper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Helper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: overallAnalytics

 def overallAnalytics(self):
     print('Total number of entries: ', end=' ')
     print(len(self.wordCountOfEntriesDict))
     print('First entry: ', end=' ')
     print(Helper.prettyPrintDate(self.firstDate))
     print('Last entry: ', end=' ')
     print(Helper.prettyPrintDate(self.mostRecentDate))
     print('Total days from first to last entry: ', end=' ')
     totalDays = self.mostRecentDate - self.firstDate #this is correct
     days = totalDays.days
     print(days)
     print('Percentage of days from first to last with an entry: ', end=' ')
     print(str(round(float(len(self.wordCountOfEntriesDict)) / days * 100, 2)) + '%')
     print('Average length per entry: ', end=' ')
     numberOfEntries = len(self.wordCountOfEntriesDict)
     sumOfLengths = 0
     longestEntryLength = 0
     for date in list(self.wordCountOfEntriesDict.keys()):
         length = self.wordCountOfEntriesDict[date]
         if length > longestEntryLength:
             longestEntryLength = length
             longestEntryDate = date
         sumOfLengths += length 
     print(round(float(sumOfLengths) / numberOfEntries, 2))
     print('Longest entry: ' + str(longestEntryLength) + ' words on ', end=' ')
     print(Helper.prettyPrintDate(longestEntryDate))
     print('Total number of words written: ', end=' ')
     print(locale.format("%d", self.totalNumberOfWords, grouping=True))
开发者ID:dirkstahlecker,项目名称:WordFrequencies,代码行数:28,代码来源:WordFrequenciesClass.py

示例2: _getSubsetForGP

    def _getSubsetForGP(self, S, random=True, normalize=True):
        Nsubset = min(self.numSamplesSubsetGP, S.shape[0])

        if random:
            return Helper.getRandomSubset(S, Nsubset)
        else:
            return Helper.getRepresentativeRows(S, Nsubset, normalize)
开发者ID:tu-darmstadt-kilobots,项目名称:kbMazerunner,代码行数:7,代码来源:learn_single_direction.py

示例3: example

def example():
	if request.method == 'GET':

		_file_a = request.args.get("file_a")
		_file_b = request.args.get("file_b")
		_file_c = request.args.get("file_c")
		
		_v = ViewRenderer("ml")
		_v.render()
		if(_file_a != None):
				
			#if you have ther parameters...
			#m = Ml("data/n2/n2_sample/1425405680330/","data/n2/n2_1/1425406094608/","data/n2/n2_2/1425407232389/")
			m = Ml(_file_a,_file_b,_file_c)
			_data = m.classify()
			h = Helper()
			_data = h.listToGrid(_data)
			_v = _v.inject("%%%checkboxes%%%",str(_data))
			return _v
		else:
			_v = _v.inject("%%%checkboxes%%%","")
			return _v

	else:
		return "Method nor supported"
开发者ID:panzerfausten,项目名称:CareMeTooServer,代码行数:25,代码来源:server.py

示例4: parseSummaryFile

def parseSummaryFile(sumFile,logFile=None,textField=0):
    '''
    Parses a .summary file from an rnaEditor output directory and returns it as an ordered dict
    Note: unedited Genes will be skipped
    :param sumFile: .summary file of rnaEditor
    :param logFile:
    :param textField:
    :return: OrderedDict {GeneName1:[GeneId1,3'UTR,5'UTR,EXON,Intron,Total]}
    '''
    
    
    if type(sumFile)==str:
        try:
            sumFile=open(sumFile,"r")
        except IOError:
            Helper.warning("Could not open %s to write Variant" % sumFile ,logFile,textField)
    elif type(sumFile)==file:
        pass
    else:
        raise TypeError("Summary file hat to be path or file object", logFile, textField)
    
    dict=OrderedDict()
    totalGenes=0
    for line in sumFile:
        if line.startswith("#"): continue #skip comments
        line = line.rstrip().split()
        totalGenes+=1
        if int(line[6])<1: continue #skip unedited genes
        try:
            v=map(int,line[2:7])
        except ValueError:
            v=line[2:7]
        dict[line[0]]=[line[1]]+v
        
    return dict,totalGenes
开发者ID:djhn75,项目名称:RNAEditor,代码行数:35,代码来源:createDiagrams.py

示例5: deleteOverlapsFromVcf

    def deleteOverlapsFromVcf(self,variants):
        '''
        delete the variants from 'variantsA' which also are in 'variantsB'
        '''

        variantSetA = set(self.variantDict.keys())
        
        #detrmine type of variantB
        if type(variants) == str:
            variantsB = open(variants)
        elif type(variants) != file:
            raise TypeError("variantB has wrong type, need str or file, %s found" % type(variantsB))
        #TODO: variants could also be another object of VariantsSet
        
        #get Start time
        startTime = Helper.getTime()
        Helper.info(" [%s] Delete overlapps from %s" % (startTime.strftime("%c"),variantsB.name),self.logFile,self.textField)

        for line in variantsB:
            if line.startswith("#"):
                continue
            for varTuple in self.getVariantTuble(line):
                if varTuple in variantSetA:
                #A.discard(varTuple)
                    variantSetA.remove(varTuple)
                    del self.variantDict[varTuple]
        
        #calculate duration 
        Helper.printTimeDiff(startTime,self.logFile,self.textField)
开发者ID:djhn75,项目名称:RNAEditor,代码行数:29,代码来源:VariantSet.py

示例6: __init__

    def __init__(self,rnaEdit):
        '''
        Constructor
        '''
        
        self.rnaEdit=rnaEdit

        """
        #check read Quality encoding and convert to phred33 quality if necessary
        for i in range(len(self.rnaEdit.fastqFiles)):
            if Helper.isPhred33Encoding(self.rnaEdit.fastqFiles[i], 1000000, self.rnaEdit.logFile, self.rnaEdit.textField) == False:
                self.rnaEdit.fastqFiles[i]=Helper.convertPhred64toPhred33(self.rnaEdit.fastqFiles[i],self.rnaEdit.params.output+ "_" + str(i+1) + "_phred33.fastq",self.rnaEdit.logFile,self.rnaEdit.textField)
        """
        
        
        #set fastQ files and check if the qualitys have to be converted
        if self.rnaEdit.params.paired==True:
            if Helper.isPhred33Encoding(self.rnaEdit.fastqFiles[0], 1000000, self.rnaEdit.logFile, self.rnaEdit.textField) == False or Helper.isPhred33Encoding(self.rnaEdit.fastqFiles[1], 1000000, self.rnaEdit.logFile, self.rnaEdit.textField) == False:
                self.fastqFile1 = Helper.convertPhred64toPhred33(self.rnaEdit.fastqFiles[0],self.rnaEdit.params.output+ "_1_phred33.fastq",self.rnaEdit.logFile,self.rnaEdit.textField)
                self.fastqFile2 = Helper.convertPhred64toPhred33(self.rnaEdit.fastqFiles[1],self.rnaEdit.params.output+ "_2_phred33.fastq",self.rnaEdit.logFile,self.rnaEdit.textField)
            else:
                self.fastqFile1=self.rnaEdit.fastqFiles[0]
                self.fastqFile2=self.rnaEdit.fastqFiles[1]
        elif self.rnaEdit.params.paired==False:
            if Helper.isPhred33Encoding(self.rnaEdit.fastqFiles[0], 1000000, self.rnaEdit.logFile, self.rnaEdit.textField) == False:
                self.fastqFile1 = Helper.convertPhred64toPhred33(self.rnaEdit.fastqFiles[0], self.rnaEdit.params.output + "_1_phred33.fastq", self.rnaEdit.logFile, self.rnaEdit.textField)
            else:
                self.fastqFile = self.rnaEdit.fastqFiles[0]
开发者ID:djhn75,项目名称:RNAEditor,代码行数:28,代码来源:MapFastq.py

示例7: parse_pls

def parse_pls(url):
    urls = []
    pls_content = Helper.downloadString(url)
    
    stream = Helper.parsePls(pls_content)
    if stream:
        urls.append(stream)
    return urls
开发者ID:dernico,项目名称:mediaschlingel,代码行数:8,代码来源:tunein.py

示例8: newAssay

    def newAssay(self):
        '''
        Function wich starts a new analysis
        '''
        
        inputTab = self.view.tabMainWindow.widget(0)
        
        #get Parameters 
        parameters=Parameters(inputTab)
        if parameters.paired==True:
            #fastqs=inputTab.dropList.dropFirstTwoItems()
            fastqs = inputTab.dropList.dropFirstItem()
            if fastqs[0]!=None:
                if not str(fastqs[0].text()).endswith(".bam"):
                    fastqs+=inputTab.dropList.dropFirstItem()
        else:
            fastqs = inputTab.dropList.dropFirstItem()        
        
        """
        check if droplist returned a value
        """
        if parameters.paired==True:
            if fastqs[-1] == None:
                QtGui.QMessageBox.information(self.view,"Warning","Warning:\nNot enough Sequencing Files for paired-end sequencing!!!\n\nDrop FASTQ-Files to the drop area!")
                return
        if fastqs[0] == None:
            QtGui.QMessageBox.information(self.view,"Warning","Warning:\nNo Sequencing Files found!!!\n\nDrop FASTQ-Files to the drop area!")
            return
        sampleName = Helper.getSampleName(str(fastqs[0].text()))
        if sampleName == None:
            QtGui.QMessageBox.information(self.view,"Warning","Warning:\nNo valid Sequencing File!!!\n\nDrop FASTQ-Files to the drop area!")
            return
        
        fastqFiles=[]
        for fastq in fastqs:
            fastqFiles.append(str(fastq.text()))

        
        
        runTab = RunTab(self)

        
        
        #initialize new Thread with new assay
        try:
            assay = RnaEdit(fastqFiles, parameters,runTab.commandBox)
        except Exception as err:
            QtGui.QMessageBox.information(self.view,"Error", str(err)+"Cannot start Analysis!")
            Helper.error(str(err) + "\n creating rnaEditor Object Failed!", textField=runTab.commandBox)
        currentIndex = self.view.tabMainWindow.count()

        # self.view.tabMainWindow.addTab(self.runTab, "Analysis"+ str(Helper.assayCount))
        self.view.tabMainWindow.addTab(runTab, sampleName + " " + str(currentIndex))
        Helper.runningThreads.append(assay)
        
        assay.start()
        
        self.view.connect(assay, QtCore.SIGNAL("taskDone"), self.openAnalysis)
开发者ID:djhn75,项目名称:RNAEditor,代码行数:58,代码来源:GuiControll.py

示例9: parse_m3u

def parse_m3u(url):

    urls = []
    m3u_content = Helper.downloadString(url)
    
    stream = Helper.parsem3u(m3u_content)
    if stream:
        urls.append(stream)
    return urls
开发者ID:dernico,项目名称:mediaschlingel,代码行数:9,代码来源:tunein.py

示例10: deleteNonEditingBases

 def deleteNonEditingBases(self):
     startTime=Helper.getTime()
     Helper.info("Delete non Editing Bases (keep only T->C and A->G)",self.logFile,self.textField)
     
     for varTuple in self.variantDict.keys():
         chr,pos,ref,alt = varTuple
         if (ref =="A" and alt == "G") or (ref=="T" and alt=="C"):
             pass
         else:
             del self.variantDict[varTuple]
开发者ID:djhn75,项目名称:RNAEditor,代码行数:10,代码来源:VariantSet.py

示例11: _updateBandwidthsGP

    def _updateBandwidthsGP(self, Ssub):
        bwNonKb = Helper.getBandwidth(Ssub[:, 0:self.NUM_NON_KB_DIM],
                Ssub.shape[0], self.bwFactorNonKbGP)

        kbPos = Ssub[:, self.NUM_NON_KB_DIM:]
        bwKb = Helper.getBandwidth(self._reshapeKbPositions(kbPos),
                Ssub.shape[0], self.bwFactorKbGP)

        self.policy.kernel.setBandwidth(bwNonKb, bwKb)
        self.policy.kernel.setWeighting(self.weightNonKbGP)
开发者ID:tu-darmstadt-kilobots,项目名称:kbMazerunner,代码行数:10,代码来源:learn_single_direction.py

示例12: readFile

    def readFile(self, url):
        try:
            f = open(url, 'r')
        except:
            print('File not found')
            newPath = input('Enter new path > ');
            return self.readFile(newPath) #TODO: this doesn't work for entirely unknown reasons

        newdate = re.compile('\s*([0-9]{1,2}-[0-9]{1,2}-[0-9]{2})\s*')
        currentDateStr = None
        currentDateObj = None
        numWords = 0
        namesFound = set()
        totalWordNum = 0

        currentDayEntry = '' #holds all the lines for the current day, so we can compute a hash of the day later on
        
        line = f.readline()
        while (line != ''):
            if self.prefs.GUESS_NAMES:
                self.guessNames(line)
            #check a line to see if it's a date, therefore a new day
            dateFound = newdate.match(line)
            if dateFound != None: #it's a new date, so wrapup the previous date and set up to move onto the next one
                if namesFound != None:
                    self.addRelatedNames(namesFound)
                    namesFound = set()
                    self.dayEntryHashTable[currentDateObj] = hashlib.md5(currentDayEntry.encode()) #TODO: deal with first date

                if numWords > 0:
                    self.wordCountOfEntriesDict[currentDateObj] = numWords #should be here, since we want it triggered at the end
                totalWordNum += numWords
                numWords = 0
                currentDateStr = dateFound.group(0)
                currentDateStr = Helper.formatDateStringIntoCleanedString(currentDateStr)
                currentDateObj = Helper.makeDateObject(currentDateStr)

                if currentDateObj > self.mostRecentDate: #found a higher date than what we've seen so far
                    self.mostRecentDate = currentDateObj
                if currentDateObj < self.firstDate: #found a lower date than what we have now
                    self.firstDate = currentDateObj
                line = line[len(currentDateStr):] #remove date from line, so it's not a word

            if currentDateStr != None:
                (wordsFound, namesFoundThisLine) = self.addLine(line, currentDateObj)
                for name in namesFoundThisLine:
                    namesFound.add(name)
                numWords += wordsFound
            line = f.readline()
            currentDayEntry += line #add line to the day's entry

        #need to capture the last date for the entry length
        self.wordCountOfEntriesDict[currentDateObj] = numWords 
        self.totalNumberOfWords = totalWordNum + numWords #need to get words from last line
        f.close()
开发者ID:dirkstahlecker,项目名称:WordFrequencies,代码行数:55,代码来源:WordFrequenciesClass.py

示例13: stopImmediately

 def stopImmediately(self):
     if hasattr(self, 'callEditSites'):
         self.callEditSites.cleanUp()
     self.isTerminated=True
     
     if self.runningCommand != False:
         self.runningCommand.kill()
     else:
         self.terminate()
         self.wait()
     Helper.error("Analysis was terminated by User", self.logFile, self.textField)
开发者ID:djhn75,项目名称:RNAEditor,代码行数:11,代码来源:RNAEditor.py

示例14: run

 def run(self):
     try:
         self.startAnalysis()
     except Exception:
         Helper.error("RnaEditor Failed",self.logFile,self.textField)
     
     """ At this point the RnaEditor has succesfully finished """
     fileDir = os.path.dirname(os.path.realpath(__file__))
     cmd=["python",fileDir+"/createDiagrams.py","-o", self.params.output]
     a=subprocess.call(cmd)
     self.emit(QtCore.SIGNAL("taskDone"), self.params.output+".html")
开发者ID:djhn75,项目名称:RNAEditor,代码行数:11,代码来源:RNAEditor.py

示例15: startAnalysis

    def startAnalysis(self):
        """
        START MAPPING
        """
        if self.fastqFiles[0].endswith("bam"):
            if self.fastqFiles[0].endswith("noDup.realigned.recalibrated.bam"):
                Helper.info("Bam File given. Skip mapping", self.logFile, self.textField)
                self.mapFastQ=None
                mapResultFile=self.fastqFiles[0]
            else: 
                Helper.error("Bam File was not mapped with RnaEditor, this is not supported. Please provide the fastq Files to RnaEditor", self.logFile, self.textField, "red")
        else:
            self.mapFastQ=MapFastq(self)
            mapResultFile=self.mapFastQ.startAnalysis()

        """
        START CALLING EDITING SITES
        """
        self.callEditSites=CallEditingSites(mapResultFile,self)
        result = self.callEditSites.startAnalysis()
        
        
        
        #finished
        self.isTerminated=True
        
        
        
        Helper.status("rnaEditor Finished with %s" % self.params.output, self.logFile, self.textField,"green",True)
        Helper.status("Open %s to see the results" % self.params.output+".html", self.logFile, self.textField,"green",True)
        self.cleanUp()
开发者ID:djhn75,项目名称:RNAEditor,代码行数:31,代码来源:RNAEditor.py


注:本文中的Helper.Helper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。