Commit f8e49cd8 authored by Fabien  MAREUIL's avatar Fabien MAREUIL
Browse files

update score

parent 6ffa0e3c
Pipeline #47574 failed with stages
in 4 minutes and 8 seconds
...@@ -166,11 +166,11 @@ ...@@ -166,11 +166,11 @@
<table class="gradiant"><tbody><tr> <table class="gradiant"><tbody><tr>
{% for td in avg_std|make_list %} {% for td in avg_std|make_list %}
{% if forloop.first %} {% if forloop.first %}
<td style="background-color:rgb({{ td|get_color:avg_std }})" title="{{ td|get_zscore:avg_std }}">{{ td|get_zscore:avg_std|floatformat:2|intcomma }}</td> <td style="background-color:rgb({{ td|get_color }})" title="{{ td }}">{{ td|floatformat:2|intcomma }}</td>
{% elif forloop.last %} {% elif forloop.last %}
<td style="direction: rtl;background-color:rgb({{ td|get_color:avg_std }})" title="{{ td|get_zscore:avg_std }}">{{ td|get_zscore:avg_std|floatformat:2|intcomma }}</td> <td style="direction: rtl;background-color:rgb({{ td|get_color }})" title="{{ td }}">{{ td|floatformat:2|intcomma }}</td>
{% else %} {% else %}
<td style="background-color:rgb({{ td|get_color:avg_std }})" title="{{ td|get_zscore:avg_std }}"> </td> <td style="background-color:rgb({{ td|get_color }})" title="{{ td }}"> </td>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</tr></tbody></table> </tr></tbody></table>
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
</tr> </tr>
{% for distance in nearcavities %} {% for distance in nearcavities %}
{% if cavity == distance.cavity1 %} {% if cavity == distance.cavity1 %}
<tr class="collapse out collapseme{{ chaincount }}_{{ cavcount }}" style="background-color:rgb({{ distance.distance|get_color:avg_std }})"> <tr class="collapse out collapseme{{ chaincount }}_{{ cavcount }}" style="background-color:rgb({{ distance.distance|get_zscore:avg_std|get_color }})">
<th class="zui-sticky-col text-nowrap"> <th class="zui-sticky-col text-nowrap">
<a title="{{ distance.distance|get_zscore:avg_std|floatformat:3|intcomma }}" target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ distance.cavity2.chain.pdb.code }}">{{ distance.cavity2.chain.pdb.code }}</a> <a title="{{ distance.distance|get_zscore:avg_std|floatformat:3|intcomma }}" target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ distance.cavity2.chain.pdb.code }}">{{ distance.cavity2.chain.pdb.code }}</a>
...@@ -348,7 +348,7 @@ ...@@ -348,7 +348,7 @@
<td>{{ distance.cavity2.t120|floatformat:1 }}</td> <td>{{ distance.cavity2.t120|floatformat:1 }}</td>
</tr> </tr>
{% elif cavity == distance.cavity2 %} {% elif cavity == distance.cavity2 %}
<tr class="collapse out collapseme{{ chaincount }}_{{ cavcount }}" style="background-color:rgb({{ distance.distance|get_color:avg_std }})"> <tr class="collapse out collapseme{{ chaincount }}_{{ cavcount }}" style="background-color:rgb({{ distance.distance|get_zscore:avg_std|get_color }})">
<th class="zui-sticky-col text-nowrap"> <th class="zui-sticky-col text-nowrap">
<a title="{{ distance.distance|get_zscore:avg_std|floatformat:3|intcomma }}" target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ distance.cavity1.chain.pdb.code }}">{{ distance.cavity1.chain.pdb.code }}</a> <a title="{{ distance.distance|get_zscore:avg_std|floatformat:3|intcomma }}" target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ distance.cavity1.chain.pdb.code }}">{{ distance.cavity1.chain.pdb.code }}</a>
/ /
......
...@@ -262,20 +262,15 @@ def get_zscore_threshold(avg_std): ...@@ -262,20 +262,15 @@ def get_zscore_threshold(avg_std):
@register.filter @register.filter
def get_zscore(distance, avg_std): def get_zscore(distance, avg_std):
value_max = avg_std.average + (avg_std.average - avg_std.minimum) std = float(avg_std.std)
if distance > value_max: mean = float(avg_std.average)
distance = value_max dist = float(distance)
score = 1 - (distance - avg_std.minimum) / (value_max - avg_std.minimum) score = np.exp(-((dist ** 2) / (2 * (std ** 2))))
return score return score
@register.filter @register.filter
def get_color(distance, avg_std): def get_color(ratio):
value_max = avg_std.average + (avg_std.average - avg_std.minimum)
if distance > value_max:
distance = value_max
value = float((distance - avg_std.minimum) / (value_max - avg_std.minimum))
ratio = 1 - value
hsl = ratio * 120 / 360 hsl = ratio * 120 / 360
rgb_color = colorsys.hls_to_rgb(hsl, 0.65, 0.7) rgb_color = colorsys.hls_to_rgb(hsl, 0.65, 0.7)
return "{}, {}, {}".format( return "{}, {}, {}".format(
...@@ -285,7 +280,5 @@ def get_color(distance, avg_std): ...@@ -285,7 +280,5 @@ def get_color(distance, avg_std):
@register.filter @register.filter
def make_list(avg_std): def make_list(avg_std):
gradient_max = avg_std.average + (avg_std.average - avg_std.minimum) step = 1 / 25
step = (gradient_max - avg_std.minimum) / 25 return np.flip(np.arange(0, 1 + step, step))
return np.arange(avg_std.minimum, gradient_max + step, step)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment