aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/templates/show_trait.html
blob: 899ee3d836b75f6720dd8eb86dab073e182781a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
{% extends "base.html" %}
{%from "oauth2/display_error.html" import display_error%}

{% block title %}Trait Data and Analysis{% endblock %}

{% block css %}
  <link rel="stylesheet" type="text/css" href="/static/new/css/bar_chart.css" />
  <link rel="stylesheet" type="text/css" href="/static/new/css/box_plot.css" />
  <link rel="stylesheet" type="text/css" href="/static/new/css/prob_plot.css" />
  <link rel="stylesheet" type="text/css" href="/static/new/css/scatter-matrix.css" />
  <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='d3-tip/d3-tip.css') }}" />
  <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" />
  <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='nouislider/nouislider.min.css') }}" />
  <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='jquery-ui/jquery-ui.theme.css') }}"/>
  <link rel="stylesheet" type="text/css" href="/static/new/css/trait_list.css" />
  <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" />

{% endblock %}

{% block content %} <!-- Start of body -->

  {{flash_me()}}
  {%if "group:resource:view-resource" in trait_privileges or "system:resource:public-read" in trait_privileges%}
    <div class="container">
      <h2>Trait Data and Analysis for <b>{{ this_trait.display_name }}</b></h2>
      {% if this_trait.dataset.type != 'Publish' %}
	    <h3>
        {% set trait_description = this_trait.description_fmt[0]|upper + this_trait.description_fmt[1:]|safe %}
        {% if trait_description|length < 100 %}
        {{ trait_description }}
        {% else %}
        <span class="truncDesc" style="display: block;">{{ trait_description[:99] }}... (<a onclick="toggleDescription()" href="#">Show More</a>)</span><span class="fullDesc" style="display: none;">{{ trait_description }} (<a onclick="toggleDescription()" href="#">Show Less</a>)</span>
        {% endif %}
      </h3>
      {% endif %}

      <form method="post" action="" target="_blank" name="trait_page" id="trait_data_form" class="form-horizontal">
	<div id="hidden_inputs">
          <input type="hidden" name="trait_hmac" value="{{ data_hmac('{}:{}'.format(this_trait.name, dataset.name)) }}">
          {% for key in hddn %}
            <input type="hidden" name="{{ key }}" value="{{ hddn[key] }}">
          {% endfor %}
        </div>

        <input type="hidden" name="temp_uuid" id="temp_uuid" value="{{ temp_uuid }}">
        <input type="hidden" name="tool_used" value="">
        <input type="hidden" name="form_url" value="">
        <input type="hidden" name="wanted_inputs" value="">
        <input type="hidden" name="genofile" value="">
        <input type="hidden" name="covariates" value="">
        <input type="hidden" name="transform" value="">
        <input type="hidden" name="sample_vals" value="">

        <div class="container">
          <div class="panel-group" id="accordion">
            <div class="panel panel-default">
              <div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapseOne" aria-expanded="true">
                <h3 class="panel-title">
                  <span class="glyphicon glyphicon-chevron-down"></span> Details and Links
                </h3>
              </div>
              <div id="collapseOne" class="panel-collapse collapse" aria-expanded="true">
                <div class="panel-body">
                  {% include 'show_trait_details.html' %}
                </div>
              </div>
            </div>
            <div class="panel panel-default">
              <div class="panel-heading stats_panel" data-toggle="collapse" data-parent="#accordion" data-target="#collapseTwo">
                <h3 class="panel-title">
                  <span class="glyphicon glyphicon-chevron-down"></span> Statistics
                </h3>
              </div>
              <div id="collapseTwo" class="panel-collapse collapse in">
                <div class="panel-body">
                  {% include 'show_trait_statistics.html' %}
                </div>
              </div>
            </div>
            <div class="panel panel-default">
              <div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapseThree">
                <h3 class="panel-title">
                  <span class="glyphicon glyphicon-chevron-down"></span> Transform and Filter Data
                </h3>
              </div>
              <div id="collapseThree" class="panel-collapse collapse in">
                <div class="panel-body">
                  {% include 'show_trait_transform_and_filter.html' %}
                </div>
                <div id="transform_alert_placeholder"><div id="transform_alert" style="display: none;"class="alert alert-success outlier-alert"><a href="#" class="close" data-dismiss="alert"></a><span>Because there are some values between 0 and 1, log2 and log10 transforms will add 1 to each value.</span></div></div>
              </div>
            </div>
            <div class="panel panel-default">
              <div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapseFour">
                <h3 class="panel-title">
                  <span class="glyphicon glyphicon-chevron-down"></span> Calculate Correlations
                </h3>
              </div>
              <div id="collapseFour" class="panel-collapse collapse in">
                <div class="panel-body">
                  {% include 'show_trait_calculate_correlations.html' %}
                </div>
              </div>
            </div>                
            <div class="panel panel-default">
              <div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapseFive">
                <h3 class="panel-title">
                  <span class="glyphicon glyphicon-chevron-down"></span> Mapping Tools
                </h3>
              </div>
              <div id="collapseFive" class="panel-collapse collapse in">
                <div class="panel-body">
                  {% include 'show_trait_mapping_tools.html' %}
                </div>
                <div id="outlier_alert_placeholder"></div>
              </div>
            </div>
              <div class="panel panel-default" {%if (trait_table_width|int > 1100)%}style="min-width: {{trait_table_width|int + 30}}px;"{% endif %}>
		<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapseSix" aria-expanded="true">
                  <h3 class="panel-title">
                    <span class="glyphicon glyphicon-chevron-up"></span> Review and Edit Data
                  </h3>
		</div>
		<div id="collapseSix" class="panel-collapse collapse" aria-expanded="true">
                  <div class="panel-body">
                    {% include 'show_trait_edit_data.html' %}
                  </div>
		</div>
              </div>
          </div>
          {% include 'show_trait_progress_bar.html' %}
        </div>
      </form>
    </div>
  {%else%}
    {%if user.name == "Anonymous User"%}
    {{display_error("Access Denied", {"error": "AuthorisationError", "error_description": "This trait is not accessible for the general public yet. Please log in."})}}
    {%else%}
    {{display_error("Access Denied", {"error": "AuthorisationError", "error_description": "The user '" + user.name + "', does not currently possess the appropriate privileges to view this trait. If you know the owner of this trait, please request that they grant you access, or wait until it is made public."})}}
    {%endif%}
  {%endif%}

  <!-- End of body -->

{% endblock %}

{% block js %}
    <script>
        js_data = {{ js_data | safe }}
        $('.collapse').collapse()
    </script>

    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='d3js/d3.min.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='underscore-string/underscore.string.min.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='d3-tip/d3-tip.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/jstat.min.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='shapiro-wilk/shapiro-wilk.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='plotly/plotly.min.js') }}"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/colorbrewer.js"></script>

    <script language="javascript" type="text/javascript" src="/static/new/javascript/stats.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/scatter-matrix.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/plotly_probability_plot.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/compare_traits_scatterplot.js"></script>


    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/scroller/js/dataTables.scroller.min.js') }}"></script>
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='nouislider/nouislider.js') }}"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/table_functions.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/create_datatable.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/initialize_show_trait_tables.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/show_trait_mapping_tools.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/show_trait.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/validation.js"></script>
    <script language="javascript" type="text/javascript" src="/static/new/javascript/get_covariates_from_collection.js"></script>

    <script type="text/javascript" charset="utf-8">

            $.fn.dataTable.ext.order['dom-checkbox'] = function  ( settings, col )
            {
              return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
                return $('input', td).prop('checked') ? '1' : '0';
              } );
            };
            
            function getValue(x) {
                if (x == 'x') {
                    return "x";
                }
                else {
                   return parseFloat(x);
                }
            }

            $.fn.dataTable.ext.order['dom-input'] = function (settings, col) {
              return this.api().column(col, { order: 'index' }).nodes().map(function (td, i) {
                return $('input', td).val();
              });
            }

            $.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) {
                var x = getValue(a);
                var y = getValue(b);

                if (x == 'x' || x === '') {
                    return 1;
                }
                else if (y == 'x' || y === '') {
                    return -1;
                }
                else {
                    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
                }
            };

            $.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) {
                var x = getValue(a);
                var y = getValue(b);
                return ((x < y) ? 1 : ((x > y) ? -1 : 0));
            };

            $(document).ready( function () {
                $('.panel-heading').click(function () {
                   if ($(this).hasClass('collapsed')){
                       $(this).find('.glyphicon-chevron-down').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
                   }
                   else {
                       $(this).find('.glyphicon-chevron-up').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
                   }
                });

                $('#samples_primary, #samples_other').find("tr.outlier").css('background-color', 'orange')

                $('.edit_sample_checkbox:checkbox').change(function() {
                    if ($(this).is(":checked")) {
                        if (!$(this).closest('tr').hasClass('selected')) {
                            $(this).closest('tr').addClass('selected')
                        }
                    }
                    else {
                        if ($(this).closest('tr').hasClass('selected')) {
                            $(this).closest('tr').removeClass('selected')
                        }
                    }
                });

                var slider = document.getElementById('p_range_slider');
                noUiSlider.create(slider, {
                    start: [-1.0, 1.0],
                    range: {
                        'min': [-1.0],
                        'max': [1.0]
                    }
                });

                var slider_display =  [
                    document.getElementById('p_range_lower'),
                    document.getElementById('p_range_upper')
                ];
                var slider_values =  [
                    $('input[name=p_range_lower]'),
                    $('input[name=p_range_upper]')
                ];                

                slider.noUiSlider.on('update', function( values, handle ) {
                    slider_display[handle].innerHTML = values[handle];
                    slider_values[handle].val(values[handle]);
                });
            });
    </script>
    
{% endblock %}