<!DOCTYPE html>


<html>



<head>
    {% load static %}
    {% load static %}
    {% load custom_tags %}
    {% get_static_prefix as STATIC_PREFIX %}
    {% include "chlamdb/header.html" %}
</head>

<body height="2000px">
<h3>Litterature search</h3>


        <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
            {% if paperblast_data  %}
                <li class="active"><a href="#tab1" data-toggle="tab">PaperBLAST  <span class="badge">{{paperblast_data|length}}</span></a></li>
            {% endif  %}
            {% if string_data and not paperblast_data %}
                <li class="active"><a href="#tab2" data-toggle="tab">String  <span class="badge">{{string_data|length}}</span></a></li>
            {% elif string_data and paperblast_data %}   
                <li><a href="#tab2" data-toggle="tab">String  <span class="badge">{{string_data|length}}</span></a></li>
            {% else %} 
            {% endif %}
        </ul>

        <div id="my-tab-content" class="tab-content">
            {% if paperblast_data %}
                <div class="tab-pane active" id="tab1">


                        <div class="panel panel-success" style="width:80%; top: 200px; margin: 10px 10px 10px 10px">
                                <div class="panel-heading" style="width:100%">
                                    <h3 class="panel-title">Help</h3>
                                </div>
                                <p style="margin: 10px 10px 10px 10px">
                                        <a href="http://papers.genomics.lbl.gov/cgi-bin/litSearch.cgi" target="_top">PaperBLAST</a> provides a database of protein sequences that are linked to scientific articles. </br>
                                        These links come from automated text searches against the articles in EuropePMC and from manually-curated information from GeneRIF, UniProtKB/Swiss-Prot, 
                                        BRENDA, CAZy (as made available by dbCAN), CharProtDB, MetaCyc, EcoCyc, REBASE, and the Fitness Browser.</br>
                                        The table below report the top 20 best hits of the considered protein in the PaperBLAST database. Each of the top 20 hit can be associated to one or multiple references to the litterature, 
                                        which is why multiple rows can have the same "hit" name. Identity values were extracted from BLASTp results.
                                </p>
                            </div>


                    <table class="table" id="paperblast">
                        <thead>
                            <tr>
                                <th>Hit</th>
                                <th>Organism</th>
                                <th>PaperBLAST description</th>
                                <th>Identity <a href="#" data-delay='{"show":"50", "hide":"1000"}' data-toggle="tooltip" title="Identity between {{locus_tag}} and the closest hits in the PaperBLAST database"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></th>
                                <th>Paper title</th>
                                <th>Journal</th>
                                <th>Year</th>
                                <th>Number of proteins <a href="#" data-delay='{"show":"50", "hide":"1000"}' data-toggle="tooltip" title="Number of proteins from this genome associated with the same pubmed entry. Click to access the list of proteins."><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></th>
                            </tr>
                        </thead>
                        <tbody>
                           {% for row in paperblast_data %} 
                                <tr>
                                    <!--accession,db_name,organism,description,query_cov,hit_cov,identity,evalue,score,pmid,title,journal,year-->
                                    {% if "VIM" in row.0 %}
                                        <td><a href="http://www.microbesonline.org/cgi-bin/fetchLocus.cgi?locus={{row.0}}" target="_top">{{row.0}}</a></td> 
                                    {% elif "WP_" in row.0 %}
                                        <td><a href="https://www.ncbi.nlm.nih.gov/protein/{{row.0}}" target="_top">{{row.0}}</a></td> 
                                    {% elif "XP_" in row.0 %}
                                        <td><a href="https://www.ncbi.nlm.nih.gov/protein/{{row.0}}" target="_top">{{row.0}}</a></td>                                         
                                    {% elif "YP_" in row.0 %}
                                        <td><a href="https://www.ncbi.nlm.nih.gov/protein/{{row.0}}" target="_top">{{row.0}}</a></td>   
                                    {% elif "NP_" in row.0 %}
                                        <td><a href="https://www.ncbi.nlm.nih.gov/protein/{{row.0}}" target="_top">{{row.0}}</a></td> 
                                    {% elif row.0|length == 6 %}
                                        <td><a href="https://www.uniprot.org/uniprot/{{row.0}}" target="_top">{{row.0}}</a></td> 
                                    {% else %}
                                        <td>{{row.0}}</td> 
                                    {% endif %}
                                    <td>{{row.2}}</td>
                                    <td>{{row.3}}</td> 
                                    <td>{{row.6}}</td>
                                    <td><a href="https://www.ncbi.nlm.nih.gov/pubmed/{{row.9}}" target="_top">{{row.10}}</a></td>
                                    <td>{{row.11}}</td>
                                    <td>{{row.12}}</td>

                                    <td> <a href="{% url 'pmid_associations' bioentry_id row.9 "PaperBlast" %}" target="_top"> {{ pmid2n_associated_proteins|keyvalue:row.9 }} </a></td>
                                </tr>
                           {% endfor %} 
                        </table>
                    </table>

                </div>
           {% endif %} 
           {% if string_data and not paperblast_data %}
                <div class="tab-pane active" id="tab2" style="height:8800px">
                        <div class="panel panel-success" style="width:80%; top: 200px; margin: 10px 10px 10px 10px">
                                <div class="panel-heading" style="width:100%">
                                    <h3 class="panel-title">Help</h3>
                                </div>
                                <p style="margin: 10px 10px 10px 10px">
                                        The <a href="https://string-db.org/" target="_top">STRING</a> database provides links to the litterature based on the automated analysis of scientific publications 
                                        (textmining). References to the litterature were retrieved from STRING for the top 20 best BLAST hits in the STRING database.
                                </p>
                            </div>

                            <table class="table" id="string">
                                <thead>
                                    <tr>
                                        <th>Hit</th>
                                        <th>Organism</th>
                                        <th>STRING Description</th>
                                        <th>Identity <a href="#" data-delay='{"show":"50", "hide":"1000"}' data-toggle="tooltip" title="Identity between {{locus_tag}} and the closest hits in the STRING database"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></th>
                                        <th>Paper title</th>
                                        <th>Journal</th>
                                        <th>Year</th>
                                        <th>Number of proteins <a href="#" data-delay='{"show":"50", "hide":"1000"}' data-toggle="tooltip" title="Number of proteins from this genome associated with the same pubmed entry. Click to access the list of proteins."><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></th>
                                    </tr>
                                </thead>
                                <tbody>
                                   {% for row in string_data %} 
                                        <tr>
                                            <!--accession,db_name,organism,description,query_cov,hit_cov,identity,evalue,score,pmid,title,journal,year-->
                                            <td><a href="http://string-db.org/newstring_cgi/show_network_section.pl?identifier={{row.0}}" target="_top">{{row.0}}</a></td> 
                                            <td>{{row.3}}</td>
                                            <td>{{row.4}}</td> 
                                            <td>{{row.5}}</td>
                                            <td><a href="https://www.ncbi.nlm.nih.gov/pubmed/{{row.8}}" target="_top">{{row.9}}</a></td>
                                            <td>{{row.10}}</td>
                                            <td>{{row.11}}</td>
        
                                            <td> <a href="{% url 'pmid_associations' bioentry_id row.8 "STRING" %}" target="_top"> {{ pmid2n_associated_proteins_string|keyvalue:row.8 }} </a></td>
                                        </tr>
                                   {% endfor %} 
                                </table>
                            </table>


                </div>
            {% elif string_data and paperblast_data %}   
                <div class="tab-pane" id="tab2" style="height:8800px">
                        <div class="panel panel-success" style="width:80%; top: 200px; margin: 10px 10px 10px 10px">
                                <div class="panel-heading" style="width:100%">
                                    <h3 class="panel-title">Help</h3>
                                </div>
                                <p style="margin: 10px 10px 10px 10px">
                                        The <a href="https://string-db.org/" target="_top">STRING</a> database provides links to the litterature based on the automated analysis of scientific publications 
                                        (textmining). References to the litterature were retrieved from STRING for the top 20 best BLAST hits in the STRING database.
                                </p>
                            </div>

                            <table class="table" id="string">
                                <thead>
                                    <tr>
                                        <th>Hit</th>
                                        <th>Organism</th>
                                        <th>STRING description</th>
                                        <th>Identity <a href="#" data-delay='{"show":"50", "hide":"1000"}' data-toggle="tooltip" title="Identity between {{locus_tag}} and the closest hits in the STRING database"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></th>
                                        <th>Paper title</th>
                                        <th>Journal</th>
                                        <th>Year</th>
                                        <th>Number of proteins <a href="#" data-delay='{"show":"50", "hide":"1000"}' data-toggle="tooltip" title="Number of proteins from this genome associated with the same pubmed entry. Click to access the list of proteins."><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></th>
                                    </tr>
                                </thead>
                                <tbody>
                                   {% for row in string_data %} 
                                        <tr>
                                            <!--accession,db_name,organism,description,query_cov,hit_cov,identity,evalue,score,pmid,title,journal,year-->
                                            <td><a href="http://string-db.org/newstring_cgi/show_network_section.pl?identifier={{row.0}}" target="_top">{{row.0}}</a></td> 
                                            <td>{{row.1}}</td>
                                            <td>{{row.2}}</td> 
                                            <td>{{row.5}}</td>
                                            <td><a href="https://www.ncbi.nlm.nih.gov/pubmed/{{row.8}}" target="_top">{{row.9}}</a></td>
                                            <td>{{row.10}}</td>
                                            <td>{{row.11}}</td>
        
                                            <td> <a href="{% url 'pmid_associations' bioentry_id row.8 "STRING" %}" target="_top"> {{ pmid2n_associated_proteins_string|keyvalue:row.8 }} </a></td>
                                        </tr>
                                   {% endfor %} 
                                </table>
                            </table>
                </div>         
            {% else %} 
            {% endif %}
                



        </div>
</body>
{% include "chlamdb/style_menu.html" %}
</html>
<script>

$(document).ready(function() {
    $('#paperblast').DataTable( {
      dom: 'Bfrtip',
      buttons: [
        {
            extend: 'excel',
            title: 'search'
        },
        {
            extend: 'csv',
            title: 'search'
        }
      ],
    "order": [[ 3, "desc" ]],
    "paging":   true,
    "ordering": true,
    "info":     false,
    colReorder: true,
    fixedHeader: true
    } );
  } );

  $(document).ready(function() {
    $('#string').DataTable( {
      dom: 'Bfrtip',
      buttons: [
        {
            extend: 'excel',
            title: 'search'
        },
        {
            extend: 'csv',
            title: 'search'
        }
      ],
    "order": [[ 3, "desc" ]],
    "paging":   true,
    "ordering": true,
    "info":     false,
    colReorder: true,
    fixedHeader: true
    } );
  } );


</script>

<script type="text/javascript" src="{% static 'js/mark.min.js' %}"></script>
<script>

var options = {
    "ignoreJoiners": true,
    "exclude": [
        "h3",
        ".byline *",
        "th"
    ]
};

var options2 = {
    "ignoreJoiners": true,
    separateWordSearch: false,
    "exclude": [
        "h3",
        ".byline *",
        "th"
    ]
};

var gene_list = "{{data.6}}";
{% if uniprot_annotation %}
gene_list = gene_list + " {{ uniprot_annotation.2 }}";
{% endif %}

$(document).ready(function() {
    var docu = document.getElementById("pmid_table");
    var instance = new Mark(docu);
    instance.mark(gene_list, options);
  } );

var str = "{{ data.12 }}"; 
var res = str.match(/^\s*(\w+)\s*,?\s*(\w+)/);

$(document).ready(function() {
    console.log("add pmid color");
    var docu = document.getElementById("pmid_table");
    console.log(res[1] + res[2]);
    var instance = new Mark(docu);
    instance.mark(res[1] + " " +res[2], options2);
    console.log(instance);
  } );

</script>

<style>
mark{
    background: orange;
    color: black;
}

.pfam_domain {
  background-color: #4CAF50; /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  border-radius: 8px;
}

</style>
