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 @@
<table class="gradiant"><tbody><tr>
{% for td in avg_std|make_list %}
{% 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 %}
<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 %}
<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 %}
{% endfor %}
</tr></tbody></table>
......@@ -282,7 +282,7 @@
</tr>
{% for distance in nearcavities %}
{% 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">
<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 @@
<td>{{ distance.cavity2.t120|floatformat:1 }}</td>
</tr>
{% 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">
<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):
@register.filter
def get_zscore(distance, avg_std):
value_max = avg_std.average + (avg_std.average - avg_std.minimum)
if distance > value_max:
distance = value_max
score = 1 - (distance - avg_std.minimum) / (value_max - avg_std.minimum)
std = float(avg_std.std)
mean = float(avg_std.average)
dist = float(distance)
score = np.exp(-((dist ** 2) / (2 * (std ** 2))))
return score
@register.filter
def get_color(distance, avg_std):
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
def get_color(ratio):
hsl = ratio * 120 / 360
rgb_color = colorsys.hls_to_rgb(hsl, 0.65, 0.7)
return "{}, {}, {}".format(
......@@ -285,7 +280,5 @@ def get_color(distance, avg_std):
@register.filter
def make_list(avg_std):
gradient_max = avg_std.average + (avg_std.average - avg_std.minimum)
step = (gradient_max - avg_std.minimum) / 25
return np.arange(avg_std.minimum, gradient_max + step, step)
step = 1 / 25
return np.flip(np.arange(0, 1 + 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