Skip to content

Commit

Permalink
integration of oligotype distribution per sample in pie chart form vi…
Browse files Browse the repository at this point in the history
…suals and various little corrections
  • Loading branch information
meren committed Apr 4, 2012
1 parent 1409860 commit fddb3fb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
32 changes: 20 additions & 12 deletions utils/html/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,26 @@ def get_list_item(l, index):
return l[index]
return ''

@register.filter(name='mod')
def mod(value, arg):
return value % arg

@register.filter(name='multiply')
def multiply(value, arg):
return int(value) * int(arg)

@register.filter(name='var')
def multiply(arg):
return 'x_' + arg.replace(' ', '_').replace('-', '_').replace('+', '_')

@register.filter(name='cleangaps')
def celangaps(arg):
return arg.replace('-', '')

@register.filter(name='sumvals')
def sumvals(arg):
return pretty_print(sum(arg.values()))

@register.filter(name='mklist')
def celangaps(arg):
return range(0, int(arg))
Expand All @@ -77,6 +89,9 @@ def generate_html_output(run_info_dict, html_output_directory = None, entropy_fi
shutil.copy2(os.path.join(absolute, 'static/header.png'), os.path.join(html_output_directory, 'header.png'))
shutil.copy2(os.path.join(absolute, 'scripts/jquery-1.7.1.js'), os.path.join(html_output_directory, 'jquery-1.7.1.js'))
shutil.copy2(os.path.join(absolute, 'scripts/popup.js'), os.path.join(html_output_directory, 'popup.js'))
shutil.copy2(os.path.join(absolute, 'scripts/g.pie.js'), os.path.join(html_output_directory, 'g.pie.js'))
shutil.copy2(os.path.join(absolute, 'scripts/g.raphael.js'), os.path.join(html_output_directory, 'g.raphael.js'))
shutil.copy2(os.path.join(absolute, 'scripts/raphael.js'), os.path.join(html_output_directory, 'raphael.js'))

def copy_as(source, dest_name):
dest = os.path.join(html_output_directory, dest_name)
Expand Down Expand Up @@ -120,18 +135,11 @@ def copy_as(source, dest_name):
html_dict['oligo_reps_dict'] = get_oligo_reps_dict(html_dict, html_output_directory)
html_dict['component_reference'] = ''.join(['<a onmouseover="popup(\'\#%d\', 50)" href="">|</a>' % i for i in range(0, html_dict['alignment_length'])])

# get datasets dict
if html_dict.has_key('output_directory_for_datasets'):
dataset_network_figures = {}
for dataset in html_dict['datasets']:
src = os.path.join(run_info_dict['output_directory_for_datasets'], dataset + '.png')
dest = dataset + '.png'
if os.path.exists(src):
dataset_network_figures[dataset] = copy_as(src, dest)
else:
dataset_network_figures[dataset] = None
html_dict['dataset_network_figures'] = dataset_network_figures

# get javascript code for dataset pie-charts
html_dict['pie_charts_js'] = render_to_string('pie_charts_js.tmpl', html_dict)

# FIXME: code below is very inefficient and causes a huge
# memory issue. fix it by not using deepcopy.
# generate individual oligotype pages
if html_dict.has_key('output_directory_for_reps'):
for oligo in html_dict['oligos']:
Expand Down
29 changes: 19 additions & 10 deletions utils/html/templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript" src="popup.js"></script>
<script type="text/javascript" src="raphael.js"></script>
<script type="text/javascript" src="g.raphael.js"></script>
<script type="text/javascript" src="g.pie.js"></script>

{{ pie_charts_js }}

</head>

<body >
Expand Down Expand Up @@ -45,6 +51,7 @@
</table>
</div>


<div class="smallhead">Download</div>
<p class="smallheadtitle">» Files to analyze results further via third partry applications
<div class="info_table">
Expand All @@ -67,22 +74,13 @@
<p class="smallheadtitle">» Oligotype Profiles Among Datasets
<p align="center"><a href="{{ stackbar_figure }}"><img src="{{ stackbar_figure }}" style="max-width:1200px" border="0"></a>

<div class="smallhead">Datasets</div>
<p class="smallheadtitle">» Overview of datasets.

<div class="wrap_regular"><p style="line-height: 2em;">
{% for dataset in datasets %}
<span style="padding: 5px; margin-right: 5px; background-color: #EEE;" onmouseover="popup('<img src={{dataset_network_figures|lookup:dataset}} style=max-width:790px;>', 800); style.backgroundColor='#AAA';" onmouseout="style.backgroundColor='#EEE';">{{dataset}}&nbsp;</span>
{% endfor %}
</div>


<div class="smallhead">Oligotypes</div><p class="smallheadtitle">» Abundan oligotypes with their frequencies within the dataset are shown below along with the most frequent sequence within the group of oligotype. {% if blast_results_found %}<span class="check">✓</span> indicates that the most frequent sequence which was represented by the given oligotype hit something duing the BLAST search with 100% identity. In contrary, <span class="cross">✗</span> sign means that there was no perfect hit during the BLAST search. <br /><br /> Here are the oligotypes with a perfect hit: {% for oligo in oligos %} {% if oligo_reps_dict.blast_results|lookup:oligo|lookup:0|lookup:"identity" == 100.0 %} {{oligo}}, {% endif %}{% endfor %}{% else %}BLAST results are missing for this analysis.{% endif %}

{% if output_directory_for_reps %}
<div class="wrap">
<div id='sequences' style="height: auto;">
<div style="width: {{alignment_length|multiply:10}}px; position: relative;">
<div style="width: {% if alignment_length|multiply:8 > 800 %}{{alignment_length|multiply:8}}{% else %}800{%endif%}px; position: relative;">
<p>
<span class="check">&nbsp;</span>
<span class="frequency">&nbsp;</span>
Expand Down Expand Up @@ -121,6 +119,17 @@

</div>
</div>

<div class="smallhead">Datasets</div>
<p class="smallheadtitle">» Overview of datasets.
{% for dataset in datasets %}
{% if forloop.counter0|mod:3 == 0 %}
<div id="p_container_{{forloop.counter0}}"></div>
{% endif %}
{% endfor %}



<div class="footer"><p>For questions and comments: meren / mbl.edu</div>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion utils/html/templates/oligo.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<p class="smallheadtitle">» First 20 Unique sequences
<div class="wrap">
<div id='sequences' style="height: auto;">
<div style="width: {{alignment_length|multiply:10}}px; position: relative;">
<div style="width: {% if alignment_length|multiply:8 > 800 %}{{alignment_length|multiply:8}}{% else %}800{%endif%}px; position: relative;">
<p><span class="frequency">&nbsp;</span><span style="background-color:{{white}}; border: 1px solid white;">&nbsp;&nbsp;</span> <span style="color: white;"> b <strong>{{oligos.0}}</strong> {{ oligo_reps_dict.component_references|lookup:oligo|safe }} </span>
{% for i in oligo_reps_dict.fancy_seqs|lookup:oligo|length|mklist %}
<p><span class="frequency">{{ oligo_reps_dict.frequency|lookup:oligo|get_list_item:i }}</span><span style="background-color:{{color_dict|lookup:oligo}}; border: 1px solid black;">&nbsp;&nbsp;</span> <span style="border-bottom:1px solid {{ color_dict|lookup:oligo }}"> <strong>{{oligo}}</strong> <em><a title="BLAST search this sequence in NCBI" href="http://blast.ncbi.nlm.nih.gov/Blast.cgi?PROGRAM=blastn&BLAST_PROGRAMS=megaBlast&PAGE_TYPE=BlastSearch&SHOW_DEFAULTS=on&LINK_LOC=blasthome&DATABASE=nr&QUERY=>{{ oligo }}_{{i}}%0d{{ oligo_reps_dict.clear_seqs|lookup:oligo|get_list_item:i|cleangaps }}">b</a></em> {{ oligo_reps_dict.fancy_seqs|lookup:oligo|get_list_item:i|safe }}</span>
Expand Down

0 comments on commit fddb3fb

Please sign in to comment.