Exemplo n.º 1
0
 def test4(self):
     """
     Test 4.
     """
     result = describe.describe(
         'TAAGCACCAGGAGTCCATGAAGAAGATGGCTCCTGCCATGGAATCCCCTACTCTA',
         'TAAGCACCAGGAGTCCATGAAGAAGCCATGTCCTGCCATGAATCCCCTACTCTA')
     description = describe.alleleDescription(result)
     assert description == '[26_29inv;30C>G;41del]'
Exemplo n.º 2
0
 def test2(self):
     """
     Test 2.
     """
     result = describe.describe(
         'TAAGCACCAGGAGTCCATGAAGAAGATGGCTCCTGCCATGGAATCCCCTACTCTACTGTG',
         'TAAGCACCAGGAGTCCATGAAGAAGCTGGATCCTCCCATGGAATCCCCTACTCTACTGTG')
     description = describe.alleleDescription(result)
     assert description == '[26A>C;30C>A;35G>C]'
Exemplo n.º 3
0
 def test1(self):
     """
     Test 1.
     """
     result = describe.describe(
         'ATGATGATCAGATACAGTGTGATACAGGTAGTTAGACAA',
         'ATGATTTGATCAGATACATGTGATACCGGTAGTTAGGACAA')
     description = describe.alleleDescription(result)
     assert description == '[5_6insTT;17del;26A>C;35dup]'
Exemplo n.º 4
0
def description_extractor():
    """
    The Variant Description Extractor (experimental service).
    """
    reference_sequence = request.args.get('reference_sequence')
    variant_sequence = request.args.get('variant_sequence')

    if not (reference_sequence and variant_sequence):
        return render_template('description-extractor.html')

    output = Output(__file__)
    output.addMessage(__file__, -1, 'INFO',
                      'Received Description Extract request from %s'
                      % request.remote_addr)

    # Todo: Move this to the describe module.
    if not util.is_dna(reference_sequence):
        output.addMessage(__file__, 3, 'ENODNA',
                          'Reference sequence is not DNA.')
    if not util.is_dna(variant_sequence):
        output.addMessage(__file__, 3, 'ENODNA',
                          'Variant sequence is not DNA.')

    raw_vars = describe.describe(reference_sequence, variant_sequence)
    description = describe.alleleDescription(raw_vars)

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

    output.addMessage(__file__, -1, 'INFO',
                      'Finished Description Extract request')

    return render_template('description-extractor.html',
                           reference_sequence=reference_sequence,
                           variant_sequence=variant_sequence,
                           raw_vars=raw_vars,
                           description=description,
                           errors=errors,
                           summary=summary,
                           messages=messages)
Exemplo n.º 5
0
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)):
        extracted = extractedProt = '(skipped)'

        allele = describe.describe(output.getIndexedOutput('original', 0),
                                   output.getIndexedOutput('mutated', 0))
        if allele:
            extracted = describe.alleleDescription(allele)

        if output.getIndexedOutput('oldprotein', 0):
            prot_allele = describe.describe(
                output.getIndexedOutput('oldprotein', 0),
                output.getIndexedOutput('newprotein', 0, default=''),
                DNA=False)
            if prot_allele:
                extractedProt = describe.alleleDescription(prot_allele)

    else:
        extracted = extractedProt = ''

    # 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),
        'cdsStart_c'          : output.getIndexedOutput('cdsStart_c', 0),
        'cdsStop_g'           : output.getIndexedOutput('cdsStop_g', 0),
        'cdsStop_c'           : output.getIndexedOutput('cdsStop_c', 0),
        'restrictionSites'    : output.getOutput('restrictionSites'),
        'legends'             : output.getOutput('legends'),
        'reference_filename'  : reference_filename,  # Todo: Download link is not shown...
        'browserLink'         : browser_link,
        'extractedDescription': extracted,
        'extractedProtein'    : extractedProt,
        'standalone'          : bool(request.args.get('standalone'))
    }

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

    return render_template('name-checker.html', **arguments)