<title>Loading {{ start_vars.tool_used }} Results</title>
<link REL="stylesheet" TYPE="text/css" href="{{ url_for('css', filename='bootstrap/css/bootstrap.css') }}" />
<link REL="stylesheet" TYPE="text/css" href="/static/new/css/bootstrap-custom.css" />
<form method="post" action="" name="loading_form" id="loading_form" class="form-horizontal">
  {% for key, value in start_vars.items() %}
  <input type="hidden" name="{{ key }}" value="{{ value }}">
  {% endfor %}
  <div class="container">
    <div>
      <div style="min-height: 80vh; display: flex; align-items: center; text-align: left;">
        <div style="margin-bottom: 5px; left: 50%; margin-right: -50%; top: 50%; transform: translate(-50%, -50%); position: absolute;">
          {% if start_vars.tool_used == "Mapping" %}
          <h1>Computing the Maps</h1>
          <br>
          <b>Time Elapsed:</b> <span class="timer"></span>
          <br>
          <b>Trait Metadata</b>
          <br>
          species = <b><i>{{ start_vars.species[0] | upper }}{{ start_vars.species[1:] }}</i></b>
          <br>
          group = <b><i>{{ start_vars.group[0] | upper }}{{ start_vars.group[1:] }}</i></b>
          <br>
          trait identifier = <b><i>{{ start_vars.trait_name }}</i></b>
          <br>
          n of sample = <b><i>{{ start_vars.n_samples }}</i></b>
          {% if start_vars.transform != "" %}
          <br>
          transformation = <b><i>{{ start_vars.transform }}</i></b>
          {% endif %}
          <br>
          hash of sample values = <b><i>{{ start_vars.vals_hash }}</i></b>
          <br><br>
          <b>Mapping Metadata</b>
          <br>
          mapping method = <b><i>{% if start_vars.method == "gemma" %}GEMMA {% if start_vars.use_loco == "True" %}using LOCO {% endif %}{% else %}{{ start_vars.method }}{% endif %}</i></b>
          {% if start_vars.maf != "" and start_vars.method != "reaper" %}
          <br>
          minor allele frequency lower limit = <b><i>{{ start_vars.maf }}</i></b>
          {% endif %}
          <br>
          {% if start_vars.covariates != "" and start_vars.method != "reaper" %}
          {% set covariate_list = start_vars.covariates.split(",") %}
          cofactors = <b><i>{% for covariate in covariate_list %}{% set this_covariate = covariate.split(":")[0] %}{{ this_covariate }}{% if not loop.last %}, {% endif %}{% endfor %}</i></b>
          {% else %}
          cofactors = <b><i>None</i></b>
          {% endif %}
          {% if start_vars.control_marker != "" and start_vars.do_control == "true" and start_vars.method != "gemma" %}
          <br>
          marker covariate = <b><i>{{ start_vars.control_marker }}</i></b>
          {% endif %}
          <br>
          {% if start_vars.genofile != "" %}
          {% set genofile_desc = start_vars.genofile.split(":")[1] %}
          genotype file = <b><i>{{ genofile_desc }}</i></b>
          {% else %}
          genotype file = <b><i>{{ start_vars.group[0] | upper }}{{ start_vars.group[1:] }}.geno</i></b>
          {% endif %}
          {% if start_vars.num_perm | int > 0 and start_vars.method != "gemma" %}
          <br>
          n of permutations = <b><i>{{ start_vars.num_perm }}</i></b>
          {% endif %}
          {% if num_bootstrap in start_vars %}
          {% if start_vars.num_bootstrap | int > 0 and start_vars.method == "reaper" %}
          <br>
          n of bootstrap = <b><i>{{ start_vars.num_bootstrap }}</i></b>
          {% endif %}
          {% endif %}
          {% else %}
          <h1>&nbsp;{{ start_vars.tool_used }}&nbsp;Computation in progress ...</h1>
          {% endif %}
          <br><br>
          <div style="text-align: center;">
            <img align="center" src="/static/gif/waitAnima2.gif">
          </div>
          {% if start_vars.vals_diff|length != 0 and start_vars.transform == "" %}
          <br><br>
          <button id="show_full_diff">Show Full Diff</button>
          <br>
          <div id="diff_table_container" style="display: none; height:200px; overflow:auto;">
          <table class="table table-hover">
            <thead>
              <th>Sample</th>
              <th>New Value</th>
              <th>Old Value</th>
            </thead>
            <tbody>
              {% for sample in start_vars.vals_diff %}
              <tr>
                <td>{{ sample }}</td>
                <td>{{ start_vars.vals_diff[sample].new_val }}</td>
                <td>{{ start_vars.vals_diff[sample].old_val }}</td>
              </tr>
              {% endfor %}
            </tbody>
          </table>
          </div>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
</form>
<script src="{{ url_for('js', filename='jquery/jquery.min.js') }}" type="text/javascript"></script>
<script src="{{ url_for('js', filename='bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>
<script  type="text/javascript">
$('#show_full_diff').click(function() {
  if ($('#diff_table_container').is(':visible')){
    $('#diff_table_container').hide();
  } else {
    $('#diff_table_container').show();
  }
})

var start = new Date;

setInterval(function() {
  minutes = Math.floor((new Date - start) / 1000 / 60)
  seconds = Math.round(((new Date - start) / 1000) % 60)
  if (seconds < 10 && minutes >= 1){
    seconds_text = "0" + seconds.toString()
  } else {
    seconds_text = seconds.toString()
  }
  if (minutes < 1) {
    $('.timer').text(seconds_text + " seconds");
  } else {
    $('.timer').text(minutes.toString() + ":" + seconds_text);
  }
}, 100);

$("#loading_form").attr("action", "{{ start_vars.form_url }}");
setTimeout(function(){ $("#loading_form").submit()}, 350);
</script>