• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python output.Output类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: bed

def bed():
    """
    Create a BED track for the given variant, listing the positions of its raw
    variants, e.g., for use in the UCSC Genome Browser.

    This basically just runs the variant checker and extracts the raw variants
    with positions.
    """
    # Backwards compatibility.
    if 'name' in request.args:
        return redirect(url_for('.bed',
                                description=request.args['name']),
                        code=301)

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

    if not description:
        abort(404)

    output = Output(__file__)

    variantchecker.check_variant(description, output)

    raw_variants = output.getIndexedOutput('rawVariantsChromosomal', 0)
    if not raw_variants:
        abort(404)

    # Todo: Hard-coded hg19.
    fields = {
        'name'       : 'Mutalyzer',
        'description': 'Mutalyzer track for ' + description,
        'visibility' : 'pack',
        'db'         : 'hg19',
        'url'        : url_for('.name_checker',
                               description=description,
                               _external=True),
        'color':       '255,0,0'}

    bed = ' '.join(['track'] +
                   ['%s="%s"' % field for field in fields.items()]) + '\n'

    for descr, positions in raw_variants[2]:
        bed += '\t'.join([raw_variants[0],
                          unicode(min(positions) - 1),
                          unicode(max(positions)),
                          descr,
                          '0',
                          raw_variants[1]]) + '\n'

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


示例2: syntax_checker

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,代码行数:34,代码来源:views.py


示例3: _processSNP

    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,代码行数:59,代码来源:Scheduler.py


示例4: lovd_get_gs

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,代码行数:58,代码来源:views.py


示例5: _processSyntaxCheck

    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,代码行数:57,代码来源:Scheduler.py


示例6: snp_converter

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,代码行数:40,代码来源:views.py


示例7: snp_converter

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,代码行数:37,代码来源:views.py


示例8: back_translator

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,代码行数:24,代码来源:views.py


示例9: batch_jobs_submit

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,代码行数:78,代码来源:views.py


示例10: description_extractor_submit

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,代码行数:101,代码来源:views.py


示例11: reference_loader_submit

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,代码行数:66,代码来源:views.py


示例12: position_converter

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,代码行数:83,代码来源:views.py


示例13: TestConverter

class TestConverter(MutalyzerTest):
    """
    Test the Converter class.
    """
    fixtures = (database, hg19, hg19_transcript_mappings)

    def setup(self):
        super(TestConverter, self).setup()
        self.output = Output(__file__)

    def _converter(self, assembly_name_or_alias):
        """
        Create a Converter instance for a given genome assembly.
        """
        assembly = Assembly.query \
            .filter(or_(Assembly.name == assembly_name_or_alias,
                        Assembly.alias == assembly_name_or_alias)) \
            .one()
        return Converter(assembly, self.output)

    def test_converter(self):
        """
        Simple test.
        """
        converter = self._converter('hg19')
        genomic = converter.c2chrom('NM_003002.2:c.274G>T')
        assert genomic == 'NC_000011.9:g.111959695G>T'
        coding = converter.chrom2c(genomic, 'list')
        assert 'NM_003002.2:c.274G>T' in coding
        # Fix for r536: disable the -u and +d convention.
        #assert 'NR_028383.1:c.1-u2173C>A' in coding
        assert 'NR_028383.1:n.-2173C>A' in coding

    def test_converter_non_coding(self):
        """
        Test with variant on non-coding transcript.
        """
        converter = self._converter('hg19')
        genomic = converter.c2chrom('NR_028383.1:n.-2173C>A')
        assert genomic == 'NC_000011.9:g.111959695G>T'
        coding = converter.chrom2c(genomic, 'list')
        assert 'NM_003002.2:c.274G>T' in coding
        # Fix for r536: disable the -u and +d convention.
        #assert 'NR_028383.1:c.1-u2173C>A' in coding
        assert 'NR_028383.1:n.-2173C>A' in coding

    def test_converter_compound(self):
        """
        Test with compound variant.
        """
        converter = self._converter('hg19')
        genomic = converter.c2chrom('NM_003002.2:c.[274G>T;278A>G]')
        assert genomic == 'NC_000011.9:g.[111959695G>T;111959699A>G]'
        coding = converter.chrom2c(genomic, 'list')
        assert 'NM_003002.2:c.[274G>T;278A>G]' in coding
        assert 'NR_028383.1:n.[-2173C>A;-2177T>C]' in coding

    def test_hla_cluster(self):
        """
        Convert to primary assembly.

        Transcript NM_000500.5 is mapped to different chromosome locations,
        but we like to just see the primary assembly mapping to chromosome 6.

        See also bug #58.
        """
        # Todo: This test is bogus now that we use a fixture that has just the
        #   mapping to chromosome 6. However, I think we only get this mapping
        #   from our current source (NCBI seq_gene.md) anyway, so I'm not sure
        #   where we got the other mappings from in the past (but haven't
        #   investigated really).
        converter = self._converter('hg19')
        genomic = converter.c2chrom('NM_000500.5:c.92C>T')
        assert genomic == 'NC_000006.11:g.32006291C>T'
        coding = converter.chrom2c(genomic, 'list')
        assert 'NM_000500.5:c.92C>T' in coding

    def test_converter_del_length_reverse(self):
        """
        Position converter on deletion (denoted by length) on transcripts
        located on the reverse strand.
        """
        converter = self._converter('hg19')
        coding = converter.chrom2c('NC_000022.10:g.51016285_51017117del123456789', 'list')
        # Fix for r536: disable the -u and +d convention.
        #assert 'NM_001145134.1:c.-138-u21_60del123456789' in coding
        #assert 'NR_021492.1:c.1-u5170_1-u4338del123456789' in coding
        assert 'NM_001145134.1:c.-159_60del123456789' in coding
        assert 'NR_021492.1:n.-5170_-4338del123456789' in coding

    def test_S_Venkata_Suresh_Kumar(self):
        """
        Test for correct mapping information on genes where CDS start or stop
        is exactly on the border of an exon.

        Bug reported February 24, 2012 by S Venkata Suresh Kumar.
        """
        converter = self._converter('hg19')
        coding = converter.chrom2c('NC_000001.10:g.115259837_115259837delT', 'list')
        assert 'NM_001007553.1:c.3863delA' not in coding
#.........这里部分代码省略.........
开发者ID:cchng,项目名称:mutalyzer,代码行数:101,代码来源:test_mapping.py


示例14: name_checker

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,代码行数:101,代码来源:views.py


示例15: lovd_variant_info

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,代码行数:101,代码来源:views.py


示例16: setup

 def setup(self):
     super(TestConverter, self).setup()
     self.output = Output(__file__)
开发者ID:cchng,项目名称:mutalyzer,代码行数:3,代码来源:test_mapping.py


示例17: _processConversion

    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( 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mutex.mutex函数代码示例发布时间:2022-05-27
下一篇:
Python ogg.OggPage类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap