<!DOCTYPE html>


<html>



<head>
{% load static %}
{% load custom_tags %}
{% get_static_prefix as STATIC_PREFIX %}

{% include "chlamdb/header.html" %}
</head>
<body>

<div class="container-fluid" id="main_container">
  <div class="row">
    <div id="wrapper">
      <div id="page-content-wrapper">
        <div class="row">
          <div class="col-lg-12">
            {% include "chlamdb/menu.html" %}
                  
          </div>
        </div>
        <p class="page-title"><b>
          {{ fam }}

          {% if object_type == 'pfam' %}

            <a href="https://zdb.readthedocs.io/en/latest/tutorial/website.html#cog-pfam-annotation-summary" id="show-option" target="_blank" title="help with the overview page"><i class="fab fa-info-circle " style="size: 5em;" ></i></a>

          {% elif object_type == 'ko' %}

            <a href="https://zdb.readthedocs.io/en/latest/tutorial/website.html#kegg-module-overview-page" id="show-option" target="_blank" title="help with the overview page"><i class="fab fa-info-circle " style="size: 5em;" ></i></a>

          {% endif %}

        </b></p>

        <hr class="lines-home">
        {% if no_match %}
          <div class="alert alert-warning" role="alert" style="width:50%"><a>{{fam}} not present in the database</a></div>

        {% else %}
          <div class="panel panel-success" style="width:100%; top: 200px; float: left;">
            <div class="panel-heading" style="width:100%">
            <h3 class="panel-title">Help to interpret the results</h3>
            </div>
            <p style="margin: 10px 10px 10px 10px; line-height: 180%">Three outputs have been generated:
              <br> <b>General</b>:  this result contains the description and frequency of the selected {{ object_name }} {{ fam }}, of which KO pathways and KO modules it is part. Additionally, its occurence in the database is reported.
              <br> <b>Proteins list</b>: list of occurences of the {{ object_name }}
              within the database. {{ all_locus_data|length }} occurences are identified.
              The table reports the orthogroup, the organism in which each occurrence has been found, and the locus tag enriched by start and stop position, strand, gene name and product.
              <br>Clicking on the Ortohgroup name or locus you will be redirected to further info.
              <br><b> Profiles</b>: Phylogenetic tree annotated with
              <br>- the presence of the {{ object_name_singular_or_plural }} of interest within all the genomes of the database (first column)

              <br>- the size of the orthogroup(s) in which the reported {{ object_name }} has been clustered.

              <br>In red the <font size="2" color="red">{{object_name}} with positive hit(s)</font> in the corresponding genome.
              <br>In green <font size="2" color="green">the discrepencies between orthogroup clustering and {{object_name}} prediction</font>.
              Green homologs (same orthogroup) <strong>are not</strong> positive hit(s) for the considered {{object_name}}.
              <br><br>Variations within orthogroups may be due to the clustering of multi domain proteins or because of erroneous homolog clustering or {{object_name}} prediction.
            </p>
          </div>

          <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
              <li class="active"><a href="#tab1" data-toggle="tab">General</a></li>
              <li><a href="#tab2" data-toggle="tab">Protein list</a></li>
              <li><a href="#tab3" data-toggle="tab">Profile</a></li>
          </ul>

          <div id="my-tab-content" class="tab-content" style="margin-top: 1em;">
            <div class="tab-pane active" id="tab1">
              <div class="col-md-12 col-lg-10" style="padding-right:30px;">
                <div class="row">
                  <div class="panel panel-default">
                    <div class="panel-heading">
                      <h3 class="panel-title">Description</h3>
                    </div>
                    <table class="table table-striped" style="width: 100%">
                      {% if object_type == 'pfam' %}
                        <tr>
                          <th>External link</th>
                          <td><a href="https://www.ebi.ac.uk/interpro/entry/pfam/{{ fam }}" target="_blank"> {{ fam }} <i class="fas fa-external-link-alt"></i></a></td>
                        </tr>

                      {% elif object_type == 'interpro' %}
                        <tr>
                          <th>External link</th>
                          <td><a href="http://www.ebi.ac.uk/interpro/entry/{{ fam }}" target="_blank"> {{ fam }} <i class="fas fa-external-link-alt"></i></a></td>
                        </tr>

                      {% elif object_type == 'ko' %}
                        <tr>
                          <th>External link</th>
                          <td><a href="http://www.genome.jp/dbget-bin/www_bget?{{ fam }}" target="_blank"> {{ fam }} <i class="fas fa-external-link-alt"></i></a></td>
                        </tr>

                      {% elif object_type == 'EC' %}
                        <tr>
                          <th>External link</th>
                          <td><a href="{{ external_link }}" target="_blank">  {{ fam }} <i class="fas fa-external-link-alt"></i></a></td>
                        </tr>

                      {% elif object_type == 'amr' %}
                        <tr>
                          <th>Gene</th>
                          <td><a href="https://www.ncbi.nlm.nih.gov/pathogens/refgene/#gene_family:{{ fam }}" target="_blank">  {{ fam }} <i class="fas fa-external-link-alt"></i></a></td>
                        </tr>

                      {% endif %}

                      {% for key, value in info.items %}
                        <tr>
                          <th>{{key}}</th>
                          <td>{{value|safe}}</td>
                        </tr>
                      {% endfor %}

                    </table>
                  </div>
                </div>

                {% if object_type == 'ko'%}
                  <div class="row">
                    <div class="panel panel-default">
                      <div class="panel-heading">
                        <h3 class="panel-title">KO part of <strong>{{pathway_data|length }} pathways</strong></h3>
                      </div>

                      {% if pathway_data|length > 0 %}
                        <table class="table table-striped" style="width: 100%">
                          <tbody>

                            {% for path in pathway_data %}
                              <tr>
                                <td>{{path|safe}}</td>
                              </tr>
                            {% endfor %}

                          </tbody>
                        </table>
                      {% endif %}

                      <div class="panel-heading">
                        <h3 class="panel-title">KO part of <strong>{{module_data|length }} modules </strong></h3>
                      </div>

                      {% if module_data|length > 0 %}
                        <table class="table table-striped" style="width: 100%">
                          <tbody>

                            {% for path in module_data %}
                              <tr>
                                <td>{{path.0|safe}}</td>
                                <td>{{path.1}}</td>
                                <td>{{path.2}}</td>
                              </tr>
                            {% endfor %}

                          </tbody>
                        </table>
                      {% endif %}

                    </div>
                  </div>
                {% endif %}

                <div class="row">
                  <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Occurence in the database</h3>
                    </div>

                    <table class="table table-striped" style="width: 100%">
                      <tr>
                        <td>{{ fam }} is associated with <strong>{{ all_locus_data|length }} different proteins</strong> (see tab "<a href="#tab2" data-toggle="tab">Protein list</a>" and "<a href="#tab3" data-toggle="tab">Profile</a>")</td>
                      </tr>
                      <tr>
                        <td>
                          The {{ all_locus_data|length }} proteins are classified into <strong>{{ group_count|length }} different orthogroup(s)</strong>
                          <div style="padding-left:20px">
                            <ul style="list-style-type:disc; width:100%;">
                              {% for group in group_count %}
                                <li style="float:left;margin-right:10px;width:120px;">{{group|safe}}</li>
                              {% endfor %}
                            </ul>
                          </div>
                        </td>
                      </tr>
                    </table>

                  </div>
                </div>

              </div>
            </div>

            <div class="tab-pane" id="tab2">
              <table id="fam_table">
                <thead>
                  <tr>
                    <th>#</th>
                    <th>Orthogroup</th>
                    <th>Locus</th>
                    <th>Start</th>
                    <th>Stop</th>
                    <th>S.</th>
                    <th>Gene</th>
                    <th>Product</th>
                    <th>Organism</th>
                  </tr>
                </thead>
                <tbody>
                  {% for values in all_locus_data %}
                    <tr>
                      <td>{{values.0}}</td>
                      <td>{{values.1|safe}}</td>
                      <td><a href='{% url "locusx" values.2 True %}' target="_top">{{values.2}}</a></td>
                      <td>{{values.4}}</td>
                      <td>{{values.5}}</td>
                      <td>{{values.6}}</td>
                      <td>{{values.7}}</td>
                      <td>{{values.8}}</td>
                      <td>{{values.9}}</td>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>

            <div class="tab-pane" id="tab66" style="height:100%">
              <iframe name="orthoIDframe2" id="orthoIDframe2" scrolling="no" width="100%" height="2800px"></iframe>
            </div>

            <div class="tab-pane" id="tab3">
              <div class="row">
                <a download="profile_{{fam}}.svg" class="btn" href="{% static asset_path %}"> <i class="fa fa-download"></i> Download SVG
                </a>
                <object type="image/svg+xml" data="{% static asset_path %}" id="cog_tree"></object>
              </div>
            </div>
          </div> <!--tabs-->
        {% endif %}
      </div>
    </div>
  </div>
</div>
</body>

{% include "chlamdb/style_menu.html" %}

<script>

// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
    $('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
}

// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
    window.location.hash = e.target.hash;
})

$(document).ready(function() {

    // Javascript to enable link to tab
    var url = document.location.toString();
    if (url.match('#')) {
        $('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
    } 

    $('#fam_table').DataTable( {
            dom: 'Bfrtip',
            "pageLength": 15,
            "paging":   true,
            "ordering": true,
            "info":     false,
            buttons: [
            {
                extend: 'excel',
                title: '{{ fam }}'
            },
            {
                extend: 'csv',
                title: '{{ fam }}'
            }
            ],
        } );
} );

</script>

</html>
