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


Python Output.addMessage方法代码示例

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


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

示例1: syntax_checker

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def syntax_checker():
    """
    Parse the given variant and render the syntax checker HTML form.
    """
    # Backwards compatibility.
    if 'variant' in request.args:
        return redirect(url_for('.syntax_checker',
                                description=request.args['variant']),
                        code=301)

    description = request.args.get('description')

    if not description:
        return render_template('syntax-checker.html')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request syntaxCheck(%s) from %s'
                      % (description, request.remote_addr))
    stats.increment_counter('syntax-checker/website')

    grammar = Grammar(output)
    grammar.parse(description)

    parse_error = output.getOutput('parseError')
    messages = map(util.message_info, output.getMessages())

    output.addMessage(__file__, -1, 'INFO',
                      'Finished request syntaxCheck(%s)' % description)

    return render_template('syntax-checker.html',
                           description=description,
                           messages=messages,
                           parse_error=parse_error)
开发者ID:cchng,项目名称:mutalyzer,代码行数:36,代码来源:views.py

示例2: _processSNP

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [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

示例3: lovd_get_gs

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def lovd_get_gs():
    """
    LOVD bypass to get the correct GeneSymbol incl Transcript variant.

    Used by LOVD to get the correct transcript variant out of a genomic
    record. LOVD uses a genomic reference (``NC_``?) in combination with a
    gene symbol to pass variant info to mutalyzer. Mutalyzer 1.0 was only
    using the first transcript. LOVD supplies the NM of the transcript needed
    but this was ignored. This helper allows LOVD to get the requested
    transcript variant from a genomic reference.

    Parameters:

    mutationName
      The mutationname without gene symbol.
    variantRecord
      The NM reference of the variant.
    forward
      If set this forwards the request to the name checker.

    Returns: Output of name checker if `forward` is set, otherwise the
    gene symbol with the variant notation as string.
    """
    mutation_name = request.args['mutationName']
    variant_record = request.args['variantRecord']
    forward = request.args.get('forward')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request getGS(%s, %s, %s) from %s'
                      % (mutation_name, variant_record, forward,
                         request.remote_addr))

    variantchecker.check_variant(mutation_name, output)

    output.addMessage(__file__, -1, 'INFO',
                      'Finished request getGS(%s, %s, %s)'
                      % (mutation_name, variant_record, forward))

    legends = output.getOutput('legends')

    # Filter the transcript from the legend.
    legends = [l for l in legends if '_v' in l[0]]
    for l in legends:
        if l[1] == variant_record:
            if forward:
                p, a = mutation_name.split(':')
                return redirect(url_for('.name_checker',
                                        description='%s(%s):%s' % (p, l[0], a),
                                        standalone=1))
            else:
                response = make_response(l[0])
                response.headers['Content-Type'] = 'text/plain; charset=utf-8'
                return response

    response = make_response('Transcript not found')
    response.headers['Content-Type'] = 'text/plain; charset=utf-8'
    return response
开发者ID:cchng,项目名称:mutalyzer,代码行数:60,代码来源:views.py

示例4: _processSyntaxCheck

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [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

示例5: snp_converter

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def snp_converter():
    """
    SNP converter.

    Convert a dbSNP rs number to HGVS description(s) of the SNP specified on
    the reference sequence(s) used by dbSNP.
    """
    # Backwards compatibility.
    if 'rsId' in request.args:
        return redirect(url_for('.snp_converter',
                                rs_id=request.args['rsId']),
                        code=301)

    rs_id = request.args.get('rs_id')

    if not rs_id:
        return render_template('snp-converter.html')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request snpConvert(%s) from %s'
                      % (rs_id, request.remote_addr))
    stats.increment_counter('snp-converter/website')

    retriever = Retriever.Retriever(output)
    descriptions = retriever.snpConvert(rs_id)

    messages = map(util.message_info, output.getMessages())

    output.addMessage(__file__, -1, 'INFO',
                      'Finished request snpConvert(%s)' % rs_id)

    return render_template('snp-converter.html',
                           rs_id=rs_id,
                           descriptions=descriptions,
                           messages=messages,
                           summary=output.Summary()[2])
开发者ID:cchng,项目名称:mutalyzer,代码行数:39,代码来源:views.py

示例6: back_translator

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def back_translator():
    """
    Back translator.
    """
    output = Output(__file__)
    output.addMessage(
        __file__, -1, 'INFO',
        'Received Back Translate request from {}'.format(request.remote_addr))
    stats.increment_counter('back-translator/website')

    description = request.args.get('description')

    variants = []
    if description:
        variants = backtranslator.backtranslate(output, description)

    errors, warnings, summary = output.Summary()
    messages = map(util.message_info, output.getMessages())

    output.addMessage(__file__, -1, 'INFO', 'Finished Back Translate request')

    return render_template(
        'back-translator.html', errors=errors, summary=summary,
        description=description or '', messages=messages, variants=variants)
开发者ID:mutalyzer,项目名称:mutalyzer,代码行数:26,代码来源:views.py

示例7: snp_converter

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def snp_converter():
    """
    SNP converter.

    Convert a dbSNP rs number to HGVS description(s) of the SNP specified on
    the reference sequence(s) used by dbSNP.
    """
    # Backwards compatibility.
    if 'rsId' in request.args:
        return redirect(url_for('.snp_converter',
                                rs_id=request.args['rsId']),
                        code=301)

    rs_id = request.args.get('rs_id')

    if not rs_id:
        return render_template('snp-converter.html')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request snpConvert(%s) from %s'
                      % (rs_id, request.remote_addr))
    stats.increment_counter('snp-converter/website')

    try:
        descriptions = ncbi.rsid_to_descriptions(rs_id)
    except ncbi.ServiceError:
        output.addMessage(__file__, 4, 'EENTREZ',
                          'An error occured while communicating with dbSNP.')

    messages = map(util.message_info, output.getMessages())

    output.addMessage(__file__, -1, 'INFO',
                      'Finished request snpConvert(%s)' % rs_id)

    return render_template('snp-converter.html',
                           rs_id=rs_id,
                           descriptions=descriptions,
                           messages=messages,
                           summary=output.Summary()[2])
开发者ID:chenyu600,项目名称:mutalyzer,代码行数:42,代码来源:views.py

示例8: batch_jobs_submit

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def batch_jobs_submit():
    """
    Run batch jobs and render batch checker HTML form. The batch jobs are
    added to the database by the scheduler and ran by the BatchChecker
    daemon.
    """
    job_type = request.form.get('job_type')
    email = request.form.get('email')

    # Note that this is always a seekable binary file object.
    batch_file = request.files.get('file')

    assemblies = Assembly.query \
        .order_by(*Assembly.order_by_criteria) \
        .all()
    assembly_name_or_alias = request.form.get('assembly_name_or_alias',
                                              settings.DEFAULT_ASSEMBLY)

    errors = []

    if not email:
        errors.append('Please provide an email address.')

    if job_type not in BATCH_JOB_TYPES:
        errors.append('Invalid batch job type.')

    if not file:
        errors.append('Please select a local file for upload.')

    if job_type == 'position-converter':
        try:
            Assembly.by_name_or_alias(assembly_name_or_alias)
        except NoResultFound:
            errors.append('Not a valid assembly.')
        argument = assembly_name_or_alias
    else:
        argument = None

    output = Output(__file__)

    if not errors:
        stats.increment_counter('batch-job/website')

        scheduler = Scheduler.Scheduler()
        file_instance = File.File(output)
        job, columns = file_instance.parseBatchFile(batch_file)

        if job is None:
            errors.append('Could not parse input file, please check your '
                          'file format.')
        else:
            # Creates the result download URL from a job result_id.
            def create_download_url(result_id):
                return url_for('.batch_job_result',
                               result_id=result_id,
                               _external=True)

            result_id = scheduler.addJob(
                email, job, columns, job_type, argument=argument,
                create_download_url=create_download_url)

            # Todo: We now assume that the job was not scheduled if there are
            #   messages, which is probably not correct.
            if not output.getMessages():
                return redirect(url_for('.batch_job_progress',
                                        result_id=result_id))

    for error in errors:
        output.addMessage(__file__, 3, 'EBATCHJOB', error)

    messages = map(util.message_info, output.getMessages())

    return render_template('batch-jobs.html',
                           assemblies=assemblies,
                           assembly_name_or_alias=assembly_name_or_alias,
                           job_type=job_type,
                           max_file_size=settings.MAX_FILE_SIZE // 1048576,
                           messages=messages)
开发者ID:cchng,项目名称:mutalyzer,代码行数:80,代码来源:views.py

示例9: description_extractor_submit

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def description_extractor_submit():
    """
    The Variant Description Extractor (experimental service).

    There multiple ways for the user to provide two sequences, corresponding to
    the values for the `reference_method` and `sample_method` fields, each
    requiring some additional fields to be defined:

    `raw_method`
      The reference and sample sequences are pasted into the form fields.

      - `reference_sequence`: The reference sequence.
      - `sample_sequence`: The sample sequence.

    `file_method`
      The reference and sample sequences are uploaded.

      - `reference_file`: The reference file.
      - `sample_file`: The sample file.

    `refseq_method`
      The reference and sample sequences are given by RefSeq accession numbers.

      - `reference_accession_number`: RefSeq accession number for the reference
        sequence.
      - `sample_accession_number`: RefSeq accession number for the sample
        sequence.
    """
    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received Description Extract request from %s'
                      % request.remote_addr)
    stats.increment_counter('description-extractor/website')

    r = s = ''
    reference_method = request.form.get('reference_method')
    sample_method = request.form.get('sample_method')
    reference_sequence = request.form.get('reference_sequence')
    sample_sequence = request.form.get('sample_sequence')
    reference_file = request.files.get('reference_file')
    sample_file = request.files.get('sample_file')
    reference_filename = ''
    sample_filename = ''
    reference_accession_number = request.form.get('reference_accession_number')
    sample_accession_number = request.form.get('sample_accession_number')

    if reference_method == 'refseq_method':
        if reference_accession_number:
            retriever = Retriever.GenBankRetriever(output)
            genbank_record = retriever.loadrecord(reference_accession_number)
            if genbank_record:
                r = unicode(genbank_record.seq)
        else:
            output.addMessage(__file__, 3, 'EEMPTYFIELD',
                'Reference accession number input fields is empty.')
    elif reference_method == 'file_method':
        if reference_file:
            reference_filename = reference_file.filename
            r = util.read_dna(reference_file)
        else:
            output.addMessage(__file__, 3, 'EEMPTYFIELD',
                'No reference file provided.')
    else: # raw_method
        if reference_sequence:
            r = util.read_dna(StringIO.StringIO(reference_sequence))
        else:
            output.addMessage(__file__, 3, 'EEMPTYFIELD',
                'Reference sequence number input fields is empty.')

    if sample_method == 'refseq_method':
        if sample_accession_number:
            retriever = Retriever.GenBankRetriever(output)
            genbank_record = retriever.loadrecord(sample_accession_number)
            if genbank_record:
                s = unicode(genbank_record.seq)
        else:
            output.addMessage(__file__, 3, 'EEMPTYFIELD',
                'Sample accession number input fields is empty.')
    elif sample_method == 'file_method':
        if sample_file:
            sample_filename = sample_file.filename
            s = util.read_dna(sample_file)
        else:
            output.addMessage(__file__, 3, 'EEMPTYFIELD',
                'No sample file provided.')
    else: # raw_method
        if sample_sequence:
            s = util.read_dna(StringIO.StringIO(sample_sequence))
        else:
            output.addMessage(__file__, 3, 'EEMPTYFIELD',
                'Sample sequence number input fields is empty.')

    # Todo: Move this to the describe module.
    if not r or not util.is_dna(r):
        output.addMessage(__file__, 3, 'ENODNA',
                          'Reference sequence is not DNA.')
    if not s or not util.is_dna(s):
        output.addMessage(__file__, 3, 'ENODNA',
                          'Sample sequence is not DNA.')

#.........这里部分代码省略.........
开发者ID:cchng,项目名称:mutalyzer,代码行数:103,代码来源:views.py

示例10: reference_loader_submit

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def reference_loader_submit():
    """
    Reference sequence loader.

    There are five ways for the user to load a reference sequence,
    corresponding to values for the `method` field, each requiring some
    additional fields to be defined.:

    `method=upload_method`
      The reference sequence file is uploaded from a local file.

      - `file`: Reference sequence file to upload.

    `method=url_method`
      The reference sequence file can be found at the specified URL.

      - `url`: URL of reference sequence file to load.

    `method=slice_gene_method`
      Retrieve part of the reference genome for an HGNC gene symbol.

      - `genesymbol`: Gene symbol.
      - `organism`: Organism.
      - `upstream`: Number of 5' flanking nucleotides.
      - `downstream`: Number of 3' flanking nucleotides.

    `method=slice_accession_method`
      Retrieve a range of a chromosome by accession number.

      - `accession`: Chromosome Accession Number.
      - `accession_start`: Start position.
      - `accession_stop`: Stop position.
      - `accession_orientation`: Orientation.

    `method=slice_chromosome_method`
      Retrieve a range of a chromosome by name.

      - `assembly_name_or_alias`: Genome assembly by name or by alias.
      - `chromosome`: Chromosome name.
      - `chromosome_start`: Start position.
      - `chromosome_stop`: Stop position.
      - `chromosome_orientation`: Orientation.
    """
    method = request.form.get('method')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request upload(%s) with arguments %s from %s'
                      % (method, unicode(request.form), request.remote_addr))

    assemblies = Assembly.query \
        .order_by(*Assembly.order_by_criteria) \
        .all()

    retriever = Retriever.GenBankRetriever(output)
    ud, errors = '', []

    class InputException(Exception):
        pass

    def check_position(position, field):
        position = position.replace(',', '').replace('.', '').replace('-', '')
        try:
            return int(position)
        except AttributeError, ValueError:
            raise InputException('Expected an integer in field: %s' % field)
开发者ID:cchng,项目名称:mutalyzer,代码行数:68,代码来源:views.py

示例11: position_converter

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def position_converter():
    """
    Position converter.
    """
    # Backwards compatibility.
    if 'variant' in request.args:
        return redirect(url_for('.position_converter',
                                description=request.args['variant']),
                        code=301)

    assemblies = Assembly.query \
        .order_by(*Assembly.order_by_criteria) \
        .all()

    assembly_name_or_alias = request.args.get('assembly_name_or_alias',
                                              settings.DEFAULT_ASSEMBLY)
    description = request.args.get('description')

    if not description:
        return render_template('position-converter.html',
                               assemblies=assemblies,
                               assembly_name_or_alias=assembly_name_or_alias)

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request positionConverter(%s, %s) from %s'
                      % (assembly_name_or_alias, description,
                         request.remote_addr))
    stats.increment_counter('position-converter/website')

    chromosomal_description = None
    transcript_descriptions = None

    try:
        assembly = Assembly.by_name_or_alias(assembly_name_or_alias)
    except NoResultFound:
        output.addMessage(__file__, 3, 'ENOASSEMBLY',
                          'Not a valid assembly.')
    else:
        converter = Converter(assembly, output)

        # Convert chromosome name to accession number.
        corrected_description = converter.correctChrVariant(description)

        if corrected_description:
            # Now we're ready to actually do position conversion.
            if not(':c.' in corrected_description or
                   ':n.' in corrected_description or
                   ':g.' in corrected_description or
                   ':m.' in corrected_description):
                grammar = Grammar(output)
                grammar.parse(corrected_description)

            if (':c.' in corrected_description or
                ':n.' in corrected_description):
                corrected_description = converter.c2chrom(
                        corrected_description)

            chromosomal_description = corrected_description

            if corrected_description and (':g.' in corrected_description or
                                          ':m.' in corrected_description):
                descriptions = converter.chrom2c(corrected_description, 'dict')
                if descriptions is None:
                    chromosomal_description = None
                elif descriptions:
                    transcript_descriptions = [
                        '%-10s:\t%s' % (key[:10], '\n\t\t'.join(value))
                        for key, value in descriptions.items()]

    messages = map(util.message_info, output.getMessages())

    output.addMessage(__file__, -1, 'INFO',
                      'Finished request positionConverter(%s, %s)'
                      % (assembly_name_or_alias, description))

    return render_template('position-converter.html',
                           assemblies=assemblies,
                           assembly_name_or_alias=assembly_name_or_alias,
                           description=description,
                           chromosomal_description=chromosomal_description,
                           transcript_descriptions=transcript_descriptions,
                           messages=messages)
开发者ID:cchng,项目名称:mutalyzer,代码行数:85,代码来源:views.py

示例12: name_checker

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def name_checker():
    """
    Name checker.
    """
    # For backwards compatibility with older LOVD versions, we support the
    # `mutationName` argument. If present, we redirect and add `standalone=1`.
    #
    # Also for backwards compatibility, we support the `name` argument as an
    # alias for `description`.
    if 'name' in request.args:
        return redirect(url_for('.name_checker',
                                description=request.args['name'],
                                standalone=request.args.get('standalone')),
                        code=301)
    if 'mutationName' in request.args:
        return redirect(url_for('.name_checker',
                                description=request.args['mutationName'],
                                standalone=1),
                        code=301)

    description = request.args.get('description')

    if not description:
        return render_template('name-checker.html')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO', 'Received variant %s from %s'
                      % (description, request.remote_addr))
    stats.increment_counter('name-checker/website')

    variantchecker.check_variant(description, output)

    errors, warnings, summary = output.Summary()
    parse_error = output.getOutput('parseError')

    record_type = output.getIndexedOutput('recordType', 0, '')
    reference = output.getIndexedOutput('reference', 0, '')
    if reference:
        if record_type == 'LRG':
            reference_filename = reference + '.xml'
        else :
            reference_filename = reference + '.gb'
    else:
        reference_filename = None

    genomic_dna = output.getIndexedOutput('molType', 0) != 'n'
    genomic_description = output.getIndexedOutput('genomicDescription', 0, '')

    # Create a link to the UCSC Genome Browser.
    browser_link = None
    raw_variants = output.getIndexedOutput('rawVariantsChromosomal', 0)
    if raw_variants:
        positions = [pos
                     for descr, (first, last) in raw_variants[2]
                     for pos in (first, last)]
        bed_url = url_for('.bed', description=description, _external=True)
        browser_link = ('http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19&'
                        'position={chromosome}:{start}-{stop}&hgt.customText='
                        '{bed_file}'.format(chromosome=raw_variants[0],
                                            start=min(positions) - 10,
                                            stop=max(positions) + 10,
                                            bed_file=urllib.quote(bed_url)))

    # Experimental description extractor.
    if (output.getIndexedOutput('original', 0) and
        output.getIndexedOutput('mutated', 0)):
        allele = extractor.describe_dna(output.getIndexedOutput('original', 0),
                                        output.getIndexedOutput('mutated', 0))
        extracted = '(skipped)'
        if allele:
            extracted = unicode(allele)

    else:
        extracted = ''

    # Todo: Generate the fancy HTML views for the proteins here instead of in
    #   `mutalyzer.variantchecker`.
    arguments = {
        'description'         : description,
        'messages'            : map(util.message_info, output.getMessages()),
        'summary'             : summary,
        'parse_error'         : parse_error,
        'errors'              : errors,
        'genomicDescription'  : genomic_description,
        'chromDescription'    : output.getIndexedOutput(
                                  'genomicChromDescription', 0),
        'genomicDNA'          : genomic_dna,
        'visualisation'       : output.getOutput('visualisation'),
        'descriptions'        : output.getOutput('descriptions'),
        'protDescriptions'    : output.getOutput('protDescriptions'),
        'oldProtein'          : output.getOutput('oldProteinFancy'),
        'altStart'            : output.getIndexedOutput('altStart', 0),
        'altProtein'          : output.getOutput('altProteinFancy'),
        'newProtein'          : output.getOutput('newProteinFancy'),
        'transcriptInfo'      : output.getIndexedOutput('hasTranscriptInfo',
                                                        0, False),
        'transcriptCoding'    : output.getIndexedOutput('transcriptCoding', 0,
                                                        False),
        'exonInfo'            : output.getOutput('exonInfo'),
        'cdsStart_g'          : output.getIndexedOutput('cdsStart_g', 0),
#.........这里部分代码省略.........
开发者ID:cchng,项目名称:mutalyzer,代码行数:103,代码来源:views.py

示例13: lovd_variant_info

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [as 别名]
def lovd_variant_info():
    """
    The chromosomal to coding and vice versa conversion interface for LOVD.

    Search for an NM number in the database, if the version number matches,
    get the start and end positions in a variant and translate these positions
    to chromosomal notation if the variant is in coding notation and vice
    versa.

    - If no end position is present, the start position is assumed to be the
      end position.
    - If the version number is not found in the database, an error message is
      generated and a suggestion for an other version is given.
    - If the reference sequence is not found at all, an error is returned.
    - If no variant is present, the transcription start and end and CDS end
      in coding notation is returned.
    - If the variant is not accepted by the nomenclature parser, a parse error
      will be printed.

    Get variant info and return the result as plain text.

    Parameters:

    LOVD_ver
      The version of the calling LOVD.
    build
      The human genome build (hg19 assumed).
    acc
      The accession number (NM number).
    var
      A description of the variant.

    Returns:

    start_main
      The main coordinate of the start position in I{c.} (non-star) notation.
    start_offset
      The offset coordinate of the start position in I{c.} notation (intronic
      position).
    end_main
      The main coordinate of the end position in I{c.} (non-star) notation.
    end_offset
      The offset coordinate of the end position in I{c.} notation (intronic
      position).
    start_g
      The I{g.} notation of the start position.
    end_g
      The I{g.} notation of the end position.
    type
      The mutation type.

    Returns (alternative):

    trans_start
      Transcription start in I{c.} notation.
    trans_stop
      Transcription stop in I{c.} notation.
    CDS_stop
      CDS stop in I{c.} notation.
    """
    lovd_version = request.args['LOVD_ver']
    build = request.args['build']
    accession = request.args['acc']
    description = request.args.get('var')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received request variantInfo(%s:%s (LOVD_ver %s, '
                      'build %s)) from %s'
                      % (accession, description, lovd_version, build,
                         request.remote_addr))

    try:
        assembly = Assembly.by_name_or_alias(build)
    except NoResultFound:
        response = make_response('invalid build')
        response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        return response

    converter = Converter(assembly, output)

    result = ''

    # If no variant is given, return transcription start, transcription
    # end and CDS stop in c. notation.
    if description:
        ret = converter.mainMapping(accession, description)
    else:
        ret = converter.giveInfo(accession)
        if ret:
            result = '%i\n%i\n%i' % ret

    if not result and not getattr(ret, 'startmain', None):
        out = output.getOutput('LOVDERR')
        if out:
            result = out[0]
        else:
            result = 'Unknown error occured'

    output.addMessage(__file__, -1, 'INFO',
#.........这里部分代码省略.........
开发者ID:cchng,项目名称:mutalyzer,代码行数:103,代码来源:views.py

示例14: _processConversion

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [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

示例15: _processNameBatch

# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import addMessage [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.addMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。