Skip to content
Snippets Groups Projects
Commit f289883b authored by Vermaat's avatar Vermaat
Browse files

Minor code cleanups

parent eb8def18
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,12 @@ from .. import output
from .. import variantchecker
class MyEncoder(json.JSONEncoder):
# TODO: This seems like a bit of a weird trick. In any case, we should
# follow the pattern from the `json` documentation to call
# `JSONEncoder.default(self, o)` as a fallback.
#
# https://docs.python.org/2/library/json.html#json.JSONEncoder.default
class AlleleEncoder(json.JSONEncoder):
def default(self, o):
json_object = o.__dict__
json_object.update({"hgvs": unicode(o), "weight": o.weight()})
......@@ -26,6 +31,7 @@ class MyEncoder(json.JSONEncoder):
#default
#MyEncoder
def check_name(description):
"""
Run the name checker.
......@@ -128,7 +134,7 @@ def check_name(description):
print json.dumps({
#"reference_sequence": reference_sequence,
#"sample_sequence": sample_sequence,
"allele_description": described_allele}, cls=MyEncoder)
"allele_description": described_allele}, cls=AlleleEncoder)
def main():
......
#!/usr/bin/env python
from __future__ import unicode_literals
import sys
import json
import describe
class MyEncoder(json.JSONEncoder):
def default(self, o):
return o.__dict__
def main():
if len(sys.argv) < 3:
print "usage: " + sys.argv[0] + " reference sample"
exit()
#if
f = open(sys.argv[1], "r")
ref = f.read()
f.close()
f = open(sys.argv[2], "r")
alt = f.read()
f.close()
extracted_allele = describe.describe_dna(ref, alt)
#print "Description Extractor Version " + describe.extractor.VERSION
print extracted_allele
#print "JSON: " + json.dumps({"reference_sequence": ref, "sample_sequence": alt, "allele_description": extracted_allele}, cls=MyEncoder)
#main
if __name__ == "__main__":
main()
#!/usr/bin/env python
from __future__ import unicode_literals
import json
import describe
class MyEncoder(json.JSONEncoder):
def default(self, o):
return o.__dict__
def main():
ref = "ACGTCGATTCGCTAGCTTCGGGGGATAGATAGAGATATAGAGATATTTTT"
alt = "ACGTCGGTTCGCTAGCTTCGGGGGATAGATAGATATATAGAGATATTTTT"
extracted_allele = describe.describe_dna(ref, alt)
print extracted_allele
print json.dumps({"reference_sequence": ref, "sample_sequence": alt,
"allele_description": extracted_allele}, cls=MyEncoder)
#main
if __name__ == "__main__":
main()
......@@ -215,7 +215,6 @@
{% if extractedDescription %}
<h4>Experimental services</h4>
<p>Genomic description: <code>{{ extractedDescription }}</code></p>
<p>Protein description: <code>{{ extractedProtein }}</code></p>
{% endif %}
</div>{# class="col-md-8 name-checker-left-column" #}
......
......@@ -273,19 +273,12 @@ def name_checker():
output.getIndexedOutput('mutated', 0)):
allele = extractor.describe_dna(output.getIndexedOutput('original', 0),
output.getIndexedOutput('mutated', 0))
#prot_allele = describe.describe_protein(
# output.getIndexedOutput('oldprotein', 0),
# output.getIndexedOutput('newprotein', 0, default=''))
prot_allele = ''
extracted = extractedProt = '(skipped)'
extracted = '(skipped)'
if allele:
extracted = unicode(allele) #describe.allele_description(allele)
if prot_allele:
extractedProt = unicode(prot_allele) #describe.allele_description(prot_allele)
extracted = unicode(allele)
else:
extracted = extractedProt = ''
extracted = ''
# Todo: Generate the fancy HTML views for the proteins here instead of in
# `mutalyzer.variantchecker`.
......@@ -320,7 +313,6 @@ def name_checker():
'reference_filename' : reference_filename, # Todo: Download link is not shown...
'browserLink' : browser_link,
'extractedDescription': extracted,
'extractedProtein' : extractedProt,
'standalone' : bool(request.args.get('standalone'))
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment