From b9d5ccec72c08d1530b33d984b50a101f1a2df86 Mon Sep 17 00:00:00 2001 From: sepro Date: Tue, 12 Sep 2017 16:40:13 +0200 Subject: [PATCH] graphs now use the networks hrr limit for the control panel's slider + fixed unit tests --- planet/controllers/custom_network.py | 4 +++- planet/controllers/expression_cluster.py | 4 +++- planet/controllers/expression_network.py | 3 ++- planet/controllers/graph_comparison.py | 4 +++- planet/templates/expression_graph.html | 4 ++-- tests/website.py | 3 +++ 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/planet/controllers/custom_network.py b/planet/controllers/custom_network.py index 34390f3..e46d32d 100644 --- a/planet/controllers/custom_network.py +++ b/planet/controllers/custom_network.py @@ -38,6 +38,7 @@ def custom_network_main(): # make probe list unique probes = list(set(probes)) + network_method = ExpressionNetworkMethod.query.get_or_404(method_id) network = ExpressionNetwork.get_custom_network(method_id, probes) network_cytoscape = CytoscapeHelper.parse_network(network) @@ -47,7 +48,8 @@ def custom_network_main(): network_cytoscape = CytoscapeHelper.add_cluster_data_nodes(network_cytoscape, cluster_method_id) network_cytoscape = CytoscapeHelper.add_specificity_data_nodes(network_cytoscape, specificity_method_id) - return render_template("expression_graph.html", graph_data=Markup(json.dumps(network_cytoscape))) + return render_template("expression_graph.html", graph_data=Markup(json.dumps(network_cytoscape)), + cutoff=network_method.hrr_cutoff) else: example = { diff --git a/planet/controllers/expression_cluster.py b/planet/controllers/expression_cluster.py index dab3925..2bef993 100644 --- a/planet/controllers/expression_cluster.py +++ b/planet/controllers/expression_cluster.py @@ -116,7 +116,9 @@ def expression_cluster_graph(cluster_id, family_method_id=None): else: family_method_id = None - return render_template("expression_graph.html", cluster=cluster, family_method_id=family_method_id) + return render_template("expression_graph.html", cluster=cluster, + family_method_id=family_method_id, + cutoff=cluster.method.network_method.hrr_cutoff) @expression_cluster.route('/json/') diff --git a/planet/controllers/expression_network.py b/planet/controllers/expression_network.py index fafd830..8774345 100644 --- a/planet/controllers/expression_network.py +++ b/planet/controllers/expression_network.py @@ -60,7 +60,8 @@ def expression_network_graph(node_id, family_method_id=None): depth = 1 if enable_second_level else 0 - return render_template("expression_graph.html", node=node, depth=depth, family_method_id=family_method_id) + return render_template("expression_graph.html", node=node, depth=depth, family_method_id=family_method_id, + cutoff=node.method.hrr_cutoff) @expression_network.route('/download/neighbors/') diff --git a/planet/controllers/graph_comparison.py b/planet/controllers/graph_comparison.py index 906d32c..f10d6b9 100644 --- a/planet/controllers/graph_comparison.py +++ b/planet/controllers/graph_comparison.py @@ -33,8 +33,10 @@ def graph_comparison_cluster(one, two, family_method_id=1): cluster_one = CoexpressionCluster.query.get_or_404(one) cluster_two = CoexpressionCluster.query.get_or_404(two) + cutoff = max([cluster_one.method.network_method.hrr_cutoff, cluster_two.method.network_method.hrr_cutoff]) + return render_template('expression_graph.html', cluster_one=cluster_one, cluster_two=cluster_two, - family_method_id=family_method_id) + family_method_id=family_method_id, cutoff=cutoff) @graph_comparison.route('/cluster/json//') diff --git a/planet/templates/expression_graph.html b/planet/templates/expression_graph.html index 833ab2a..c6d7a89 100644 --- a/planet/templates/expression_graph.html +++ b/planet/templates/expression_graph.html @@ -149,8 +149,8 @@ {% if not sequence %}
  • -

    HRR Score 30

    - +

    HRR Score {{cutoff}}

    +
  • {% endif %} diff --git a/tests/website.py b/tests/website.py index e7c30a5..53fa1e5 100644 --- a/tests/website.py +++ b/tests/website.py @@ -91,6 +91,9 @@ def setUp(self): db.session.commit() test_expression_network_method = ExpressionNetworkMethod(test_species.id, "Test network method") + test_expression_network_method.pcc_cutoff = 0.0 + test_expression_network_method.hrr_cutoff = 100 + test_expression_network_method.enable_second_level = 0 db.session.add(test_expression_network_method) db.session.commit()