-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added search for genomes + isolation sources/countries
- Loading branch information
Showing
4 changed files
with
307 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
{% extends "components/panel_universal.html" %} | ||
{% block panel_header %} | ||
<form action="{% url 'download_search_genomes_csv' %}" target="_blank" method="GET" style="display: inline"> | ||
<input type="hidden" name="q" value="{{ request.GET.q }}" /> | ||
<button class="btn btn-outline-dark btn-sm" type="submit"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="display: inline; position: relative; top: -2px;" fill="currentColor" class="bi bi-filetype-csv" viewBox="0 0 16 16"> | ||
<path fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5zM3.517 14.841a1.13 1.13 0 0 0 .401.823q.195.162.478.252.284.091.665.091.507 0 .859-.158.354-.158.539-.44.187-.284.187-.656 0-.336-.134-.56a1 1 0 0 0-.375-.357 2 2 0 0 0-.566-.21l-.621-.144a1 1 0 0 1-.404-.176.37.37 0 0 1-.144-.299q0-.234.185-.384.188-.152.512-.152.214 0 .37.068a.6.6 0 0 1 .246.181.56.56 0 0 1 .12.258h.75a1.1 1.1 0 0 0-.2-.566 1.2 1.2 0 0 0-.5-.41 1.8 1.8 0 0 0-.78-.152q-.439 0-.776.15-.337.149-.527.421-.19.273-.19.639 0 .302.122.524.124.223.352.367.228.143.539.213l.618.144q.31.073.463.193a.39.39 0 0 1 .152.326.5.5 0 0 1-.085.29.56.56 0 0 1-.255.193q-.167.07-.413.07-.175 0-.32-.04a.8.8 0 0 1-.248-.115.58.58 0 0 1-.255-.384zM.806 13.693q0-.373.102-.633a.87.87 0 0 1 .302-.399.8.8 0 0 1 .475-.137q.225 0 .398.097a.7.7 0 0 1 .272.26.85.85 0 0 1 .12.381h.765v-.072a1.33 1.33 0 0 0-.466-.964 1.4 1.4 0 0 0-.489-.272 1.8 1.8 0 0 0-.606-.097q-.534 0-.911.223-.375.222-.572.632-.195.41-.196.979v.498q0 .568.193.976.197.407.572.626.375.217.914.217.439 0 .785-.164t.55-.454a1.27 1.27 0 0 0 .226-.674v-.076h-.764a.8.8 0 0 1-.118.363.7.7 0 0 1-.272.25.9.9 0 0 1-.401.087.85.85 0 0 1-.478-.132.83.83 0 0 1-.299-.392 1.7 1.7 0 0 1-.102-.627zm8.239 2.238h-.953l-1.338-3.999h.917l.896 3.138h.038l.888-3.138h.879z"/> | ||
</svg></button> | ||
</form> | ||
{% endblock %} | ||
{% block panel_content %} | ||
<table id="genomes_table" class="table table-hover display" style="width: 100%;"> | ||
<thead> | ||
<tr> | ||
<th>Genome</th> | ||
<th>Stain (NCBI)</th> | ||
<th>Phylo Group</th> | ||
<th>%GC</th> | ||
<th>Country</th> | ||
<th>Broad Context</th> | ||
<th>Local Context</th> | ||
<th>Extra Context</th> | ||
<th>Isolation Source</th> | ||
</tr> | ||
</thead> | ||
<tbody id="tbody"> | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<th>Genome</th> | ||
<th>Stain (NCBI)</th> | ||
<th>Phylo Group</th> | ||
<th>%GC</th> | ||
<th>Country</th> | ||
<th>Broad Context</th> | ||
<th>Local Context</th> | ||
<th>Extra Context</th> | ||
<th>Isolation Source</th> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
<script> | ||
var genomes_table = null; | ||
|
||
$(document).ready(async function () { | ||
genomes_table = $('#genomes_table').DataTable({ | ||
ajax: { | ||
url: '{% url "search_genomes_json" %}?q={{ q }}', | ||
dataSrc: 'results', | ||
}, | ||
autoWidth: true, | ||
fixedColumns: true, | ||
scrollX: true, | ||
lengthMenu: [ | ||
[10, 20, 30, 40, 50, 100, -1], | ||
[10, 20, 30, 40, 50, 100, 'All'] | ||
], | ||
order: [], | ||
columns: [ | ||
{ | ||
data: '1', | ||
render: function (data, type, row) { | ||
return '<a href="{% url 'genome_info' %}?species=' + encodeURIComponent(row[0]) + '&genome_id=' + encodeURIComponent(data) + '">' + data + '</a>'; | ||
}, | ||
className: 'genome_id', | ||
}, | ||
{ | ||
data: '2', | ||
className: 'ncbi_strain', | ||
}, | ||
{ | ||
data: '3', | ||
}, | ||
{ | ||
data: '4', | ||
render: function (data, type, row) { | ||
return (data*100).toFixed(2) | ||
}, | ||
}, | ||
{ | ||
data: '5', | ||
render: function (data, type, row) { | ||
if (data == "?") { | ||
return "-" | ||
} else { | ||
return data | ||
} | ||
}, | ||
className: 'country', | ||
}, | ||
{ | ||
data: '6', | ||
className: 'broad_context', | ||
render: function (data, type, row) { | ||
if (data == "?" || data == "Missing" || data == "missing") { | ||
return "-" | ||
} else { | ||
return data | ||
} | ||
}, | ||
}, | ||
{ | ||
data: '7', | ||
className: 'local_context', | ||
render: function (data, type, row) { | ||
if (data == "?" || data == "Missing" || data == "missing") { | ||
return "-" | ||
} else { | ||
return data | ||
} | ||
}, | ||
}, | ||
{ | ||
data: '8', | ||
className: 'extra_context', | ||
render: function (data, type, row) { | ||
if (data == "?" || data == "Missing" || data == "missing") { | ||
return "-" | ||
} else { | ||
return data | ||
} | ||
}, | ||
}, | ||
{ | ||
data: '9', | ||
className: 'isolation_source', | ||
render: function (data, type, row) { | ||
if (data == "?" || data == "Missing" || data == "missing") { | ||
return "-" | ||
} else { | ||
return data | ||
} | ||
}, | ||
} | ||
], | ||
language: { | ||
loadingRecords: '<span class="spinner-border" aria-hidden="true"></span>', | ||
zeroRecords: 'Result not found.' | ||
}, | ||
initComplete: function () { | ||
this.api() | ||
.columns() | ||
.every(function () { | ||
var column = this; | ||
var title = column.footer().textContent; | ||
|
||
// Create input element and add event listener | ||
$('<input type="text" class="form-control" placeholder="' + title + '" />') | ||
.appendTo($(column.footer()).empty()) | ||
.on('keyup change clear', function () { | ||
if (column.search() !== this.value) { | ||
column.search(this.value).draw(); | ||
} | ||
}); | ||
}); | ||
|
||
let queryString = window.location.search; | ||
let urlParams = new URLSearchParams(queryString); | ||
let q = urlParams.get('q') | ||
highlightText(q); | ||
} | ||
}); | ||
|
||
genomes_table.on("draw", function () { | ||
let queryString = window.location.search; | ||
let urlParams = new URLSearchParams(queryString); | ||
let q = urlParams.get('q') | ||
highlightText(q); | ||
}); | ||
genomes_table.on('xhr.dt', function (e, settings, json, xhr) { | ||
let genomesFound = json.results.length > 0; | ||
update_results_overview_with_genomes(genomesFound); | ||
}); | ||
|
||
// Expand row on click | ||
$('#genomes_table tbody').on('click', 'td', function () { | ||
const row = $(this).closest('tr'); | ||
row.toggleClass('expanded-row'); | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} |