本文整理汇总了Python中mutalyzer.output.Output.getMessages方法的典型用法代码示例。如果您正苦于以下问题:Python Output.getMessages方法的具体用法?Python Output.getMessages怎么用?Python Output.getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutalyzer.output.Output
的用法示例。
在下文中一共展示了Output.getMessages方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: syntax_checker
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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: snp_converter
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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])
示例3: snp_converter
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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])
示例4: back_translator
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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)
示例5: batch_jobs_submit
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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)
示例6: description_extractor_submit
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [as 别名]
#.........这里部分代码省略.........
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.')
raw_vars = None
if r and s:
if (len(r) > settings.EXTRACTOR_MAX_INPUT_LENGTH or
len(s) > settings.EXTRACTOR_MAX_INPUT_LENGTH):
output.addMessage(__file__, 3, 'EMAXSIZE',
'Input sequences are restricted to {:,} bp.'
.format(settings.EXTRACTOR_MAX_INPUT_LENGTH))
else:
raw_vars = extractor.describe_dna(r, s)
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',
extractor_max_input_length=settings.EXTRACTOR_MAX_INPUT_LENGTH,
reference_sequence=reference_sequence or '',
sample_sequence=sample_sequence or '',
reference_accession_number=reference_accession_number or '',
sample_accession_number=sample_accession_number or '',
reference_filename=reference_filename or '',
sample_filename=sample_filename or '',
raw_vars=raw_vars, errors=errors, summary=summary, messages=messages,
reference_method=reference_method, sample_method=sample_method)
示例7: position_converter
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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)
示例8: name_checker
# 需要导入模块: from mutalyzer.output import Output [as 别名]
# 或者: from mutalyzer.output.Output import getMessages [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),
#.........这里部分代码省略.........