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


Python Output.getBatchMessages方法代码示例

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


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

示例1: _processSNP

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getBatchMessages [as 别名]
    def _processSNP(self, batch_job, cmd, flags):
        """
        Process an entry from the SNP converter Batch, write the results
        to the job-file. If an Exception is raised, catch and continue.

        Side-effect:
            - Output written to outputfile.

        @arg cmd: The SNP converter input
        @type cmd:
        @arg i: The JobID
        @type i:
        @arg flags: Flags of the current entry
        @type flags:
        """
        O = Output(__file__)
        O.addMessage(__file__, -1, "INFO",
            "Received SNP converter batch rs" + cmd)

        stats.increment_counter('snp-converter/batch')

        #Read out the flags
        # Todo: Do something with the flags?
        skip = self.__processFlags(O, flags)

        descriptions = []
        if not skip :
            R = Retriever.Retriever(O)
            descriptions = R.snpConvert(cmd)

        # Todo: Is output ok?
        outputline =  "%s\t" % cmd
        outputline += "%s\t" % "|".join(descriptions)
        outputline += "%s\t" % "|".join(O.getBatchMessages(2))

        #Output
        filename = "%s/batch-job-%s.txt" % (settings.CACHE_DIR, batch_job.result_id)
        if not os.path.exists(filename) :
            # If the file does not yet exist, create it with the correct
            # header above it. The header is read from the config file as
            # a list. We need a tab delimited string.
            header = ['Input Variant',
                      'HGVS description(s)',
                      'Errors and warnings']
            handle = io.open(filename, mode='a', encoding='utf-8')
            handle.write("%s\n" % "\t".join(header))
        #if
        else :
            handle = io.open(filename, mode='a', encoding='utf-8')

        if flags and 'C' in flags:
            separator = '\t'
        else:
            separator = '\n'

        handle.write("%s%s" % (outputline, separator))
        handle.close()
        O.addMessage(__file__, -1, "INFO",
                     "Finished SNP converter batch rs%s" % cmd)
开发者ID:cchng,项目名称:mutalyzer,代码行数:61,代码来源:Scheduler.py

示例2: _processSyntaxCheck

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getBatchMessages [as 别名]
    def _processSyntaxCheck(self, batch_job, cmd, flags):
        """
        Process an entry from the Syntax Check, write the results
        to the job-file.

        Side-effect:
            - Output written to outputfile

        @arg cmd:   The Syntax Checker input
        @type cmd:
        @arg i:     The JobID
        @type i:
        @arg flags: Flags of the current entry
        @type flags:
        """
        output = Output(__file__)
        grammar = Grammar(output)

        output.addMessage(__file__, -1, "INFO",
                           "Received SyntaxChecker batchvariant " + cmd)

        stats.increment_counter('syntax-checker/batch')

        skip = self.__processFlags(output, flags)
        #Process
        if not skip :
            parsetree = grammar.parse(cmd)
        else :
            parsetree = None

        if parsetree :
            result = "OK"
        else :
            result = "|".join(output.getBatchMessages(2))

        #Output
        filename = "%s/batch-job-%s.txt" % (settings.CACHE_DIR, batch_job.result_id)
        if not os.path.exists(filename) :
            # If the file does not yet exist, create it with the correct
            # header above it. The header is read from the config file as
            # a list. We need a tab delimited string.
            header = ['Input', 'Status']
            handle = io.open(filename, mode='a', encoding='utf-8')
            handle.write("%s\n" % "\t".join(header))
        #if
        else :
            handle = io.open(filename, mode='a', encoding='utf-8')

        if flags and 'C' in flags:
            separator = '\t'
        else:
            separator = '\n'

        handle.write("%s\t%s%s" % (cmd, result, separator))
        handle.close()
        output.addMessage(__file__, -1, "INFO",
                          "Finished SyntaxChecker batchvariant " + cmd)
开发者ID:cchng,项目名称:mutalyzer,代码行数:59,代码来源:Scheduler.py

示例3: _processConversion

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getBatchMessages [as 别名]
    def _processConversion(self, batch_job, cmd, flags):
        """
        Process an entry from the Position Converter, write the results
        to the job-file. The Position Converter is wrapped in a try except
        block which ensures that he Batch Process keeps running. Errors
        are caught and the user will be notified.

        Side-effect:
            - Output written to outputfile.

        @arg cmd: The Syntax Checker input
        @type cmd: unicode
        @arg i: The JobID
        @type i: integer
        @arg build: The build to use for the converter
        @type build: unicode
        @arg flags: Flags of the current entry
        @type flags:
        """
        O = Output(__file__)
        variant = cmd
        variants = None
        gName = ""
        cNames = [""]

        O.addMessage(__file__, -1, "INFO",
            "Received PositionConverter batchvariant " + cmd)

        stats.increment_counter('position-converter/batch')

        skip = self.__processFlags(O, flags)
        if not skip :
            try :
                #process
                try:
                    assembly = Assembly.by_name_or_alias(batch_job.argument)
                except NoResultFound:
                    O.addMessage(__file__, 3, 'ENOASSEMBLY',
                                 'Not a valid assembly: ' + batch_job.argument)
                    raise

                converter = Converter(assembly, O)

                #Also accept chr accNo
                variant = converter.correctChrVariant(variant)

                #TODO: Parse the variant and check for c or g. This is ugly
                if not(":c." in variant or ":n." in variant or ":g." in variant) :
                    #Bad name
                    grammar = Grammar(O)
                    grammar.parse(variant)
                #if

                if ":c." in variant or ":n." in variant :
                    # Do the c2chrom dance
                    variant = converter.c2chrom(variant)
                    # NOTE:
                    # If we received a coding reference convert that to the
                    # genomic position variant. Use that variant as the input
                    # of the chrom2c.

                # If the input is a genomic variant or if we converted a
                # coding variant to a genomic variant we try to find all
                # other affected coding variants.
                if variant and ":g." in variant :
                    # Do the chrom2c dance
                    variants = converter.chrom2c(variant, "dict")
                    if variants :
                        gName = variant
                        # Due to the cyclic behavior of the Position Converter
                        # we know for a fact that if a correct chrom name is
                        # generated by the converter.c2chrom that we will at
                        # least find one variant with chrom2c. Collect the
                        # variants from a nested lists and store them.
                        cNames = [cName for cName2 in variants.values() \
                                for cName in cName2]
            except Exception:
                #Catch all exceptions related to the processing of cmd
                O.addMessage(__file__, 4, "EBATCHU",
                        "Unexpected error occurred, dev-team notified")
            #except
        #if

        error = "%s" % "|".join(O.getBatchMessages(2))

        #Output
        filename = "%s/batch-job-%s.txt" % (settings.CACHE_DIR, batch_job.result_id)
        if not os.path.exists(filename) :
            # If the file does not yet exist, create it with the correct
            # header above it. The header is read from the config file as
            # a list. We need a tab delimited string.
            header = ['Input Variant',
                      'Errors',
                      'Chromosomal Variant',
                      'Coding Variant(s)']
            handle = io.open(filename, mode='a', encoding='utf-8')
            handle.write("%s\n" % "\t".join(header))
        #if
        else :
            handle = io.open(filename, mode='a', encoding='utf-8')
#.........这里部分代码省略.........
开发者ID:cchng,项目名称:mutalyzer,代码行数:103,代码来源:Scheduler.py

示例4: _processNameBatch

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getBatchMessages [as 别名]
    def _processNameBatch(self, batch_job, cmd, flags):
        """
        Process an entry from the Name Batch, write the results
        to the job-file. If an Exception is raised, catch and continue.

        Side-effect:
            - Output written to outputfile.

        @arg cmd: The NameChecker input
        @type cmd:
        @arg i: The JobID
        @type i:
        @arg flags: Flags of the current entry
        @type flags:
        """
        O = Output(__file__)
        O.addMessage(__file__, -1, "INFO",
            "Received NameChecker batchvariant " + cmd)

        stats.increment_counter('name-checker/batch')

        #Read out the flags
        skip = self.__processFlags(O, flags)

        if not skip :
            #Run mutalyzer and get values from Output Object 'O'
            try :
                variantchecker.check_variant(cmd, O)
            except Exception:
                #Catch all exceptions related to the processing of cmd
                O.addMessage(__file__, 4, "EBATCHU",
                        "Unexpected error occurred, dev-team notified")
                import traceback
                O.addMessage(__file__, 4, "DEBUG", unicode(repr(traceback.format_exc())))
            #except
            finally :
                #check if we need to update the database
                self._updateDbFlags(O, batch_job.id)
        #if

        batchOutput = O.getOutput("batchDone")

        outputline =  "%s\t" % cmd
        outputline += "%s\t" % "|".join(O.getBatchMessages(2))

        if batchOutput :
            outputline += batchOutput[0]

        #Output
        filename = "%s/batch-job-%s.txt" % (settings.CACHE_DIR, batch_job.result_id)
        if not os.path.exists(filename) :
            # If the file does not yet exist, create it with the correct
            # header above it. The header is read from the config file as
            # a list. We need a tab delimited string.
            header = ['Input',
                      'Errors and warnings',
                      'AccNo',
                      'Genesymbol',
                      'Variant',
                      'Reference Sequence Start Descr.',
                      'Coding DNA Descr.',
                      'Protein Descr.',
                      'GeneSymbol Coding DNA Descr.',
                      'GeneSymbol Protein Descr.',
                      'Genomic Reference',
                      'Coding Reference',
                      'Protein Reference',
                      'Affected Transcripts',
                      'Affected Proteins',
                      'Restriction Sites Created',
                      'Restriction Sites Deleted']
            handle = io.open(filename, mode='a', encoding='utf-8')
            handle.write("%s\n" % "\t".join(header))
        #if
        else :
            handle = io.open(filename, mode='a', encoding='utf-8')

        if flags and 'C' in flags:
            separator = '\t'
        else:
            separator = '\n'

        handle.write("%s%s" % (outputline, separator))
        handle.close()
        O.addMessage(__file__, -1, "INFO",
            "Finished NameChecker batchvariant " + cmd)
开发者ID:cchng,项目名称:mutalyzer,代码行数:88,代码来源:Scheduler.py


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