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


Python GenomeInfo.findBestMatchingChr方法代码示例

本文整理汇总了Python中quick.util.GenomeInfo.GenomeInfo.findBestMatchingChr方法的典型用法代码示例。如果您正苦于以下问题:Python GenomeInfo.findBestMatchingChr方法的具体用法?Python GenomeInfo.findBestMatchingChr怎么用?Python GenomeInfo.findBestMatchingChr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在quick.util.GenomeInfo.GenomeInfo的用法示例。


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

示例1: execute

# 需要导入模块: from quick.util.GenomeInfo import GenomeInfo [as 别名]
# 或者: from quick.util.GenomeInfo.GenomeInfo import findBestMatchingChr [as 别名]
    def execute(choices, galaxyFn=None, username=''):
        '''Is called when execute-button is pushed by web-user.
        Should print output as HTML to standard out, which will be directed to a results page in Galaxy history. If getOutputFormat is anything else than HTML, the output should be written to the file with path galaxyFn.gtr
        If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files).
        choices is a list of selections made by web-user in each options box.
        '''
        
        if choices.history:
            inputFile = open(ExternalTrackManager.extractFnFromGalaxyTN(choices.history.split(':')), 'r')
        else:
            inputFile = StringIO(choices.input)
        
        headers = TabularToGtrackTool._getHeaders(choices)
        for i,header in enumerate(headers):
            if header == 'seqid':
                seqIdCol = i
                break
        
        colIndexes = [i for i, header in enumerate(headers) if header != '']
        numSkipLines = TabularToGtrackTool._getNumSkipLines(choices)
        
        tempContents = ''
        
        if choices.indexing == '1-indexed, end inclusive':
            tempContents += '##1-indexed: true' + os.linesep
            tempContents += '##end inclusive: true' + os.linesep
        
        tempContents += '###' + '\t'.join([headers[i] for i in colIndexes]) + os.linesep
        
        
        for i in xrange(numSkipLines):
            inputFile.readline()
            
        splitChar = TabularToGtrackTool._getSplitChar(choices)
        numCols = TabularToGtrackTool._getFileContentsInfo(choices).numCols
        
        autoCorrectSeqId = choices.handleSeqId == 'Yes, auto-correct to the best match in the genome build'
        if autoCorrectSeqId:
            genome = choices.genome

        for i, line in enumerate(inputFile):
            cols = [x.strip() for x in line.strip().split(splitChar)]
            
            for j in colIndexes:
                if len(cols) <= j:
                    print >> sys.stderr, "Error in line #%s: %s" % (i+1, line)
                    print >> sys.stderr, "The line does not include the column #%s, which is defined with " \
                                         "the name '%s' (the number of columns is %s). Please fix the input " \
                                         "file or redefine the column names of this column." \
                                         % (j+1, headers[j], len(cols))
                    return
                
            if autoCorrectSeqId:
                from quick.util.GenomeInfo import GenomeInfo
                cols[seqIdCol] = GenomeInfo.findBestMatchingChr(genome, cols[seqIdCol])
                
            for j, col in enumerate(cols):
                if col == '':
                    cols[j] = '.'
                else:
                    cols[j] = ''.join([x if x in GtrackGenomeElementSource.ALLOWED_CHARS and x not in '#\t' \
                                         else '%' + '{:0>2X}'.format(ord(x)) for x in col])
                
            tempContents += '\t'.join(cols[j] for j in colIndexes) + os.linesep
        
        try:
            tempContents = expandHeadersOfGtrackFileAndReturnComposer('', strToUseInsteadOfFn=tempContents).returnComposed()
            geSource = GtrackGenomeElementSource('temp.gtrack', strToUseInsteadOfFn=tempContents, printWarnings=False)
            for ge in geSource:
                pass
            open(galaxyFn, 'w').write(tempContents)
            
        except Exception, e:
            print >> sys.stderr, e
开发者ID:Anderrb,项目名称:Dynamic-benchmark,代码行数:76,代码来源:TabularToGtrackTool.py


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