本文整理汇总了Python中mutalyzer.output.Output.getOutput方法的典型用法代码示例。如果您正苦于以下问题:Python Output.getOutput方法的具体用法?Python Output.getOutput怎么用?Python Output.getOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutalyzer.output.Output
的用法示例。
在下文中一共展示了Output.getOutput方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: syntax_checker
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getOutput [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)
示例2: lovd_get_gs
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getOutput [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
示例3: name_checker
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getOutput [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),
#.........这里部分代码省略.........
示例4: lovd_variant_info
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getOutput [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',
#.........这里部分代码省略.........
示例5: _processNameBatch
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getOutput [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)