Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaned up code a bit.
  • Loading branch information
proost committed Oct 25, 2016
1 parent e9c94d3 commit be16ce4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
20 changes: 15 additions & 5 deletions planet/controllers/expression_profile.py
Expand Up @@ -74,18 +74,24 @@ def expression_profile_find(probe, species_id=None):


@expression_profile.route('/compare/<first_profile_id>/<second_profile_id>')
@expression_profile.route('/compare/<first_profile_id>/<second_profile_id>/<int:normalize>')
@cache.cached()
def expression_profile_compare(first_profile_id, second_profile_id):
def expression_profile_compare(first_profile_id, second_profile_id, normalize=0):
"""
Gets expression profile data from the database and renders it.
:param profile_id: ID of the profile to show
:param first_profile_id: internal ID of the first profile
:param second_profile_id: internal ID of the second profile
:param normalize: 1 to normalize profiles (to max value), 0 to disable
:return:
"""
first_profile = ExpressionProfile.query.get_or_404(first_profile_id)
second_profile = ExpressionProfile.query.get_or_404(second_profile_id)

return render_template("compare_profiles.html", first_profile=first_profile,
second_profile=second_profile)
return render_template("compare_profiles.html",
first_profile=first_profile,
second_profile=second_profile,
normalize=normalize)


@expression_profile.route('/compare_probes/<probe_a>/<probe_b>/<int:species_id>')
Expand All @@ -95,7 +101,11 @@ def expression_profile_compare_probes(probe_a, probe_b, species_id, normalize=0)
"""
Gets expression profile data from the database and renders it.
:param profile_id: ID of the profile to show
:param probe_a: name of the first probe
:param probe_b: name of the second probe
:param species_id: internal id of the species the probes are linked with
:param normalize: 1 to normalize profiles (to max value), 0 to disable
:return:
"""
first_profile = ExpressionProfile.query.filter_by(probe=probe_a).filter_by(species_id=species_id).first_or_404()
second_profile = ExpressionProfile.query.filter_by(probe=probe_b).filter_by(species_id=species_id).first_or_404()
Expand Down
14 changes: 11 additions & 3 deletions planet/templates/compare_profiles.html
Expand Up @@ -3,10 +3,18 @@
{% block container %}
<div class="top-pad">
<h1>Comparing profiles of <strong>{{ first_profile.probe }}</strong> and <strong>{{ second_profile.probe }}</strong></h1>
{% if normalize == 1 %}
<a href="{{ url_for('expression_profile.expression_profile_compare_probes', probe_a=probe_a, probe_b=probe_b, species_id=species_id, normalize=0)}}">Disable normalization</a>
{% if species_id %}
{% if normalize == 1 %}
<span class="text-muted">Normalization: <strong>Enabled</strong></span> | (<a href="{{ url_for('expression_profile.expression_profile_compare_probes', probe_a=probe_a, probe_b=probe_b, species_id=species_id, normalize=0)}}">disable</a>)
{% else %}
<span class="text-muted">Normalization: <strong>Disabled</strong></span> | (<a href="{{ url_for('expression_profile.expression_profile_compare_probes', probe_a=probe_a, probe_b=probe_b, species_id=species_id, normalize=1)}}">enable</a>)
{% endif %}
{% else %}
<a href="{{ url_for('expression_profile.expression_profile_compare_probes', probe_a=probe_a, probe_b=probe_b, species_id=species_id, normalize=1)}}">Enable normalization</a>
{% if normalize == 1 %}
<span class="text-muted">Normalization: <strong>Enabled</strong></span> | (<a href="{{ url_for('expression_profile.expression_profile_compare', first_profile_id=first_profile.id, second_profile_id=second_profile.id, normalize=0)}}">disable</a>)
{% else %}
<span class="text-muted">Normalization: <strong>Disabled</strong></span> | (<a href="{{ url_for('expression_profile.expression_profile_compare', first_profile_id=first_profile.id, second_profile_id=second_profile.id, normalize=1)}}">enable</a>)
{% endif %}
{% endif %}
<p></p>
<div class="row">
Expand Down

0 comments on commit be16ce4

Please sign in to comment.