Spaces:
Sleeping
Sleeping
Upload templates/index.html
Browse files- templates/index.html +239 -456
templates/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 9 |
<style>
|
|
@@ -47,20 +47,9 @@ textarea::placeholder,input::placeholder{color:var(--faint);}
|
|
| 47 |
.btn-p{background:var(--accent);color:#fff;}.btn-p:hover{background:#1d4ed8;}
|
| 48 |
.btn-o{background:var(--surface);color:var(--text);border:1px solid var(--border);}.btn-o:hover{background:var(--bg);}
|
| 49 |
.btn:disabled{opacity:.4;cursor:not-allowed;}
|
| 50 |
-
|
| 51 |
-
/* ── Gene pills: multi-select ── */
|
| 52 |
.gpills{display:flex;flex-wrap:wrap;gap:5px;}
|
| 53 |
-
.gpill{
|
| 54 |
-
font-family:var(--mono);font-size:12px;font-weight:500;
|
| 55 |
-
padding:3px 9px;
|
| 56 |
-
background:var(--al);color:var(--accent);
|
| 57 |
-
border:1px solid var(--ab);border-radius:5px;
|
| 58 |
-
cursor:pointer;transition:background .12s,border-color .12s,color .12s;
|
| 59 |
-
user-select:none;
|
| 60 |
-
}
|
| 61 |
.gpill:hover{background:#dbeafe;}
|
| 62 |
-
.gpill.selected{background:var(--accent);color:#fff;border-color:var(--accent);}
|
| 63 |
-
|
| 64 |
.main{display:flex;flex-direction:column;overflow:hidden;}
|
| 65 |
.tabs{background:var(--surface);border-bottom:1px solid var(--border);display:flex;padding:0 24px;flex-shrink:0;}
|
| 66 |
.tab{padding:16px;font-size:14px;font-weight:500;cursor:pointer;color:var(--muted);border-bottom:2px solid transparent;transition:all .15s;}
|
|
@@ -94,21 +83,11 @@ tr:last-child td{border-bottom:none;}tr:hover td{background:#fafbfc;}
|
|
| 94 |
.tdt{max-width:360px;}.tdt a{color:var(--text);font-weight:500;}.tdt a:hover{color:var(--accent);}
|
| 95 |
.tdm{font-size:12px;color:var(--faint);margin-top:3px;}
|
| 96 |
.badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500;}
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
.
|
| 100 |
-
.
|
| 101 |
-
|
| 102 |
-
.bb{background:var(--al);color:var(--accent);}
|
| 103 |
-
.bvt{background:var(--pl);color:var(--purple);}
|
| 104 |
-
.bvv{background:#fff7ed;color:#c2410c;}
|
| 105 |
-
|
| 106 |
-
/* Cancer badges — pancreatic = amber, gi = green, cancer = NEUTRAL (not red), unknown = neutral */
|
| 107 |
-
.bpanc{background:var(--aml);color:var(--amber);}
|
| 108 |
-
.bgi{background:var(--gl);color:var(--green);}
|
| 109 |
-
.bca{background:#fdf2f8;color:#9d174d;} /* pink */
|
| 110 |
.bunk{background:var(--bg);color:var(--faint);border:1px solid var(--border);}
|
| 111 |
-
|
| 112 |
.bdis{font-size:11px;color:var(--amber);background:var(--aml);border-radius:4px;padding:1px 6px;margin-left:4px;font-weight:500;}
|
| 113 |
.cbar{display:flex;align-items:center;gap:8px;}.cbg{flex:1;height:4px;background:var(--bg);border-radius:2px;min-width:48px;}
|
| 114 |
.cfg{height:100%;border-radius:2px;}.cnum{font-family:var(--mono);font-size:12px;color:var(--muted);white-space:nowrap;}
|
|
@@ -119,6 +98,14 @@ tr:last-child td{border-bottom:none;}tr:hover td{background:#fafbfc;}
|
|
| 119 |
.ev-lbl{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--faint);margin-bottom:6px;}
|
| 120 |
.ev-txt{font-family:var(--mono);font-size:12px;color:var(--text);line-height:1.7;}
|
| 121 |
.ev-note{font-size:13px;color:var(--muted);line-height:1.6;font-style:italic;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
.pages{display:flex;align-items:center;justify-content:center;gap:6px;padding:16px;}
|
| 123 |
.pgbtn{padding:6px 13px;border-radius:6px;border:1px solid var(--border);background:var(--surface);color:var(--text);cursor:pointer;font-size:13px;font-family:var(--sans);transition:all .12s;}
|
| 124 |
.pgbtn:hover{border-color:var(--accent);color:var(--accent);}.pgbtn.on{background:var(--accent);color:#fff;border-color:var(--accent);}
|
|
@@ -153,41 +140,44 @@ tr:last-child td{border-bottom:none;}tr:hover td{background:#fafbfc;}
|
|
| 153 |
<body>
|
| 154 |
<div class="shell">
|
| 155 |
<header class="topbar">
|
| 156 |
-
<div class="logo">
|
|
|
|
|
|
|
| 157 |
<div class="dbstat"><span class="pulse"></span><span id="db-summary">Loading…</span></div>
|
| 158 |
</header>
|
| 159 |
<aside class="sidebar">
|
| 160 |
<div class="sbsec">
|
| 161 |
<div class="sblbl">Search genes</div>
|
| 162 |
<textarea id="gene-input" rows="4" placeholder="TP53 BRCA1 KRAS one per line"></textarea>
|
| 163 |
-
<div id="search-csv-drop" style="margin-top:8px;border:1.5px dashed var(--border);border-radius:var(--r);padding:9px 12px;text-align:center;cursor:pointer;font-size:12px;color:var(--faint);transition:border-color .15s;background:var(--bg);"
|
| 164 |
-
onclick="document.getElementById('search-csv-file').click()"
|
| 165 |
-
ondragover="event.preventDefault();this.style.borderColor='var(--accent)'"
|
| 166 |
-
ondragleave="this.style.borderColor='var(--border)'"
|
| 167 |
-
ondrop="handleSearchCsvDrop(event)">
|
| 168 |
-
Upload CSV <span id="search-csv-fname" style="color:var(--accent);font-family:var(--mono);"></span>
|
| 169 |
-
</div>
|
| 170 |
-
<input type="file" id="search-csv-file" accept=".csv,.txt" style="display:none" onchange="handleSearchCsvFile(this)">
|
| 171 |
<div class="filters">
|
| 172 |
<div>
|
| 173 |
<label class="flabel">Cancer type</label>
|
| 174 |
-
<select id="f-cancer"
|
| 175 |
<option value="all">All types</option><option value="pancreatic">Pancreatic</option>
|
| 176 |
<option value="gi">GI cancers</option><option value="cancer">Other cancer</option>
|
| 177 |
</select>
|
| 178 |
</div>
|
| 179 |
<div>
|
| 180 |
<label class="flabel">Study type</label>
|
| 181 |
-
<select id="f-func"
|
| 182 |
<option value="all">All papers</option><option value="true">Functional only</option>
|
| 183 |
<option value="false">Non-functional only</option>
|
| 184 |
</select>
|
| 185 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
<div>
|
| 187 |
<label class="flabel">Min confidence: <span id="confv" style="color:var(--accent);font-weight:600;">0.00</span></label>
|
| 188 |
<div class="conf-row">
|
| 189 |
<input type="range" id="f-conf" min="0" max="1" step="0.05" value="0"
|
| 190 |
-
oninput="document.getElementById('confv').textContent=parseFloat(this.value).toFixed(2)
|
| 191 |
</div>
|
| 192 |
</div>
|
| 193 |
<button class="btn btn-p" onclick="doSearch()">Search Database</button>
|
|
@@ -195,7 +185,7 @@ tr:last-child td{border-bottom:none;}tr:hover td{background:#fafbfc;}
|
|
| 195 |
</div>
|
| 196 |
</div>
|
| 197 |
<div class="sbsec" style="flex:1;overflow-y:auto;">
|
| 198 |
-
<div class="sblbl">Genes in DB
|
| 199 |
<div class="gpills" id="db-genes"></div>
|
| 200 |
</div>
|
| 201 |
</aside>
|
|
@@ -228,70 +218,32 @@ tr:last-child td{border-bottom:none;}tr:hover td{background:#fafbfc;}
|
|
| 228 |
</div>
|
| 229 |
</div>
|
| 230 |
<div class="pane" id="pane-submit">
|
| 231 |
-
<div
|
| 232 |
-
|
| 233 |
-
<
|
| 234 |
-
<div class="
|
| 235 |
-
<
|
| 236 |
-
<
|
| 237 |
-
|
| 238 |
-
<label>Gene symbol</label>
|
| 239 |
-
<input type="text" id="req-gene" placeholder="e.g. MSI1" maxlength="20"
|
| 240 |
-
oninput="this.value=this.value.toUpperCase()" onkeydown="if(event.key==='Enter')submitRequest()">
|
| 241 |
-
</div>
|
| 242 |
-
<div class="field">
|
| 243 |
-
<label>Max papers to process</label>
|
| 244 |
-
<select id="req-max">
|
| 245 |
-
<option value="100">100 papers (faster)</option>
|
| 246 |
-
<option value="200">200 papers</option>
|
| 247 |
-
<option value="300" selected>300 papers (recommended)</option>
|
| 248 |
-
</select>
|
| 249 |
-
</div>
|
| 250 |
-
<button class="subbtn" id="req-btn" onclick="submitRequest()">Submit Request</button>
|
| 251 |
-
<div class="rbox" id="req-result"></div>
|
| 252 |
</div>
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
<textarea id="bulk-genes" rows="5" placeholder="TP53 KRAS BRCA1 MSI1"></textarea>
|
| 261 |
-
</div>
|
| 262 |
-
<div class="field">
|
| 263 |
-
<label>Or upload a CSV file <span style="color:var(--faint);font-weight:400;">(one gene per row, first column used)</span></label>
|
| 264 |
-
<div id="csv-drop" style="border:2px dashed var(--border);border-radius:var(--r);padding:18px;text-align:center;cursor:pointer;transition:border-color .15s;background:var(--bg);"
|
| 265 |
-
onclick="document.getElementById('csv-file').click()"
|
| 266 |
-
ondragover="event.preventDefault();this.style.borderColor='var(--accent)'"
|
| 267 |
-
ondragleave="this.style.borderColor='var(--border)'"
|
| 268 |
-
ondrop="handleCsvDrop(event)">
|
| 269 |
-
<div style="font-size:22px;opacity:.3;margin-bottom:6px;">📄</div>
|
| 270 |
-
<div style="font-size:13px;color:var(--muted);">Click to upload or drag & drop a CSV</div>
|
| 271 |
-
<div id="csv-fname" style="font-size:12px;color:var(--accent);margin-top:4px;font-family:var(--mono);"></div>
|
| 272 |
-
</div>
|
| 273 |
-
<input type="file" id="csv-file" accept=".csv,.txt" style="display:none" onchange="handleCsvFile(this)">
|
| 274 |
-
</div>
|
| 275 |
-
<div class="field">
|
| 276 |
-
<label>Max papers per gene</label>
|
| 277 |
-
<select id="bulk-max">
|
| 278 |
-
<option value="100">100 papers (faster)</option>
|
| 279 |
-
<option value="200">200 papers</option>
|
| 280 |
-
<option value="300" selected>300 papers (recommended)</option>
|
| 281 |
-
</select>
|
| 282 |
-
</div>
|
| 283 |
-
<button class="subbtn" id="bulk-btn" onclick="submitBulk()">Submit All Genes</button>
|
| 284 |
-
<div class="rbox" id="bulk-result"></div>
|
| 285 |
</div>
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
|
|
|
| 295 |
</div>
|
| 296 |
</div>
|
| 297 |
</div>
|
|
@@ -309,13 +261,7 @@ tr:last-child td{border-bottom:none;}tr:hover td{background:#fafbfc;}
|
|
| 309 |
</div>
|
| 310 |
<script>
|
| 311 |
// ── Base URL — works whether served direct or inside HF iframe ─────────────
|
| 312 |
-
const BASE =
|
| 313 |
-
const h = window.location.hostname;
|
| 314 |
-
if (h === 'huggingface.co' || h.endsWith('.huggingface.co')) {
|
| 315 |
-
return 'https://shenovad-reyalab.hf.space';
|
| 316 |
-
}
|
| 317 |
-
return '';
|
| 318 |
-
})();
|
| 319 |
|
| 320 |
// ── Auth token ─────────────────────────────────────────────────────────────
|
| 321 |
const TOKEN = new URLSearchParams(window.location.search).get('token')
|
|
@@ -331,10 +277,7 @@ function api(path, extra) {
|
|
| 331 |
}
|
| 332 |
|
| 333 |
// ── State ──────────────────────────────────────────────────────────────────
|
| 334 |
-
const S = {page:1,perPage:25,genes:[],cancer:'all',func:'all',conf:0,total:0,pages:1};
|
| 335 |
-
|
| 336 |
-
// ── Multi-select gene pills state ─────────────────────────────────────────
|
| 337 |
-
const selectedPills = new Set();
|
| 338 |
|
| 339 |
window.addEventListener('DOMContentLoaded', () => { loadStats(); setInterval(loadStats, 60000); });
|
| 340 |
|
|
@@ -354,75 +297,26 @@ async function loadStats() {
|
|
| 354 |
document.getElementById('s-func').textContent = fmt(d.functional_papers);
|
| 355 |
document.getElementById('db-summary').textContent =
|
| 356 |
`${fmt(d.total_papers)} papers · ${fmt(d.total_genes)} genes · synced ${d.last_sync||'—'}`;
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
const pillsEl = document.getElementById('db-genes');
|
| 360 |
-
pillsEl.innerHTML = (d.all_genes||[]).map(g => {
|
| 361 |
-
const sel = selectedPills.has(g) ? ' selected' : '';
|
| 362 |
-
return `<span class="gpill${sel}" onclick="togglePill('${g}',this)">${g}</span>`;
|
| 363 |
-
}).join('');
|
| 364 |
} catch(e) {
|
| 365 |
document.getElementById('db-summary').textContent = 'DB unavailable';
|
| 366 |
}
|
| 367 |
}
|
| 368 |
|
| 369 |
-
// ── Toggle a gene pill on/off and update the textarea ─────────────────────
|
| 370 |
-
function togglePill(gene, el) {
|
| 371 |
-
if (selectedPills.has(gene)) {
|
| 372 |
-
selectedPills.delete(gene);
|
| 373 |
-
el.classList.remove('selected');
|
| 374 |
-
} else {
|
| 375 |
-
selectedPills.add(gene);
|
| 376 |
-
el.classList.add('selected');
|
| 377 |
-
}
|
| 378 |
-
|
| 379 |
-
// All genes that exist as sidebar pills
|
| 380 |
-
const allPillGenes = new Set(
|
| 381 |
-
Array.from(document.querySelectorAll('#db-genes .gpill'))
|
| 382 |
-
.map(p => p.textContent.trim().toUpperCase())
|
| 383 |
-
);
|
| 384 |
-
// Keep only genes the user typed manually (not pill-managed)
|
| 385 |
-
const manualGenes = document.getElementById('gene-input').value
|
| 386 |
-
.split(/[\n,]+/)
|
| 387 |
-
.map(g => g.trim().toUpperCase())
|
| 388 |
-
.filter(g => g && !allPillGenes.has(g));
|
| 389 |
-
const all = [...manualGenes, ...Array.from(selectedPills)];
|
| 390 |
-
document.getElementById('gene-input').value = all.join('\n');
|
| 391 |
-
|
| 392 |
-
switchTab('results', document.querySelector('.tab'));
|
| 393 |
-
|
| 394 |
-
// If nothing left, reset to empty state instead of searching
|
| 395 |
-
if (all.length === 0) {
|
| 396 |
-
document.getElementById('tbl-wrap').style.display = 'none';
|
| 397 |
-
document.getElementById('gcards').style.display = 'none';
|
| 398 |
-
document.getElementById('s-match').textContent = '\u2014';
|
| 399 |
-
const empty = document.getElementById('results-empty');
|
| 400 |
-
empty.style.display = 'block';
|
| 401 |
-
empty.innerHTML = '<div class=\"empty-icon\">\ud83e\uddec</div>Enter gene symbols and click <strong>Search Database</strong><br>or use <strong>Request gene</strong> to add a new gene.';
|
| 402 |
-
return;
|
| 403 |
-
}
|
| 404 |
-
|
| 405 |
-
doSearch();
|
| 406 |
-
}
|
| 407 |
-
|
| 408 |
function quickSearch(gene) {
|
| 409 |
document.getElementById('gene-input').value = gene;
|
| 410 |
switchTab('results', document.querySelector('.tab'));
|
| 411 |
doSearch();
|
| 412 |
}
|
| 413 |
|
| 414 |
-
let _searchTimer = null;
|
| 415 |
-
function debounceSearch(ms) {
|
| 416 |
-
clearTimeout(_searchTimer);
|
| 417 |
-
_searchTimer = setTimeout(() => doSearch(), ms || 400);
|
| 418 |
-
}
|
| 419 |
-
|
| 420 |
async function doSearch(page) {
|
| 421 |
const genes = document.getElementById('gene-input').value
|
| 422 |
.split(/[\n,]+/).map(g=>g.trim().toUpperCase()).filter(Boolean);
|
| 423 |
if (!genes.length) { alert('Enter at least one gene symbol.'); return; }
|
| 424 |
S.genes=genes; S.cancer=document.getElementById('f-cancer').value;
|
| 425 |
S.func=document.getElementById('f-func').value;
|
|
|
|
| 426 |
S.conf=parseFloat(document.getElementById('f-conf').value);
|
| 427 |
S.page=page||1;
|
| 428 |
const btn = document.querySelector('.btn-p');
|
|
@@ -430,13 +324,13 @@ async function doSearch(page) {
|
|
| 430 |
try {
|
| 431 |
const url = api('/api/query', {
|
| 432 |
genes: genes.join(','), cancer_type: S.cancer,
|
| 433 |
-
functional: S.func, min_conf: S.conf,
|
| 434 |
page: S.page, per_page: S.perPage
|
| 435 |
});
|
| 436 |
const d = await fetch(url).then(r=>r.json());
|
| 437 |
S.total=d.total; S.pages=d.pages;
|
| 438 |
document.getElementById('s-match').textContent = fmt(d.total);
|
| 439 |
-
renderCards(genes, d.summaries||{}
|
| 440 |
renderTable(d.rows||[], d.total);
|
| 441 |
renderPages(d.page, d.pages);
|
| 442 |
document.getElementById('results-empty').style.display = (d.rows&&d.rows.length)?'none':'block';
|
|
@@ -444,94 +338,34 @@ async function doSearch(page) {
|
|
| 444 |
finally { btn.disabled=false; btn.textContent='Search Database'; }
|
| 445 |
}
|
| 446 |
|
| 447 |
-
|
| 448 |
-
function renderCards(genes, summaries, rows) {
|
| 449 |
const el = document.getElementById('gcards');
|
| 450 |
-
const funcFilter = S.func; // 'all' | 'true' | 'false'
|
| 451 |
-
|
| 452 |
el.innerHTML = genes.map(gene => {
|
| 453 |
const s = summaries[gene]||{};
|
| 454 |
if (!s.total) return `<div class="gcard" onclick="submitGene('${gene}')">
|
| 455 |
<div class="gcname">${gene}</div>
|
| 456 |
<div class="gcinfo" style="color:var(--amber);margin-top:6px;">Not in database</div>
|
| 457 |
<div class="gcinfo" style="font-size:13px;margin-top:3px;">Click to request</div></div>`;
|
| 458 |
-
|
| 459 |
-
// Build display counts based on active filter
|
| 460 |
-
let displayTotal, displayFunctional, displayPancreatic, displayGi, displayOther;
|
| 461 |
-
let methodCounts;
|
| 462 |
-
|
| 463 |
-
if (funcFilter === 'true') {
|
| 464 |
-
// Functional only: count from rows for this gene that are functional
|
| 465 |
-
const geneRows = rows.filter(r => r.gene === gene && r.functional_study);
|
| 466 |
-
displayTotal = geneRows.length;
|
| 467 |
-
displayFunctional = geneRows.length;
|
| 468 |
-
displayPancreatic = geneRows.filter(r=>r.cancer_type==='pancreatic').length;
|
| 469 |
-
displayGi = geneRows.filter(r=>r.cancer_type==='gi').length;
|
| 470 |
-
displayOther = geneRows.filter(r=>r.cancer_type==='cancer').length;
|
| 471 |
-
methodCounts = {
|
| 472 |
-
knockout: geneRows.filter(r=>r.knockout).length,
|
| 473 |
-
knockdown: geneRows.filter(r=>r.knockdown).length,
|
| 474 |
-
shrna: geneRows.filter(r=>r.shrna).length,
|
| 475 |
-
sirna: geneRows.filter(r=>r.sirna).length,
|
| 476 |
-
crispr: geneRows.filter(r=>r.crispr).length,
|
| 477 |
-
};
|
| 478 |
-
} else if (funcFilter === 'false') {
|
| 479 |
-
// Non-functional only: count from rows for this gene that are NOT functional
|
| 480 |
-
const geneRows = rows.filter(r => r.gene === gene && !r.functional_study);
|
| 481 |
-
displayTotal = geneRows.length;
|
| 482 |
-
displayFunctional = 0;
|
| 483 |
-
displayPancreatic = geneRows.filter(r=>r.cancer_type==='pancreatic').length;
|
| 484 |
-
displayGi = geneRows.filter(r=>r.cancer_type==='gi').length;
|
| 485 |
-
displayOther = geneRows.filter(r=>r.cancer_type==='cancer').length;
|
| 486 |
-
methodCounts = {knockout:0,knockdown:0,shrna:0,sirna:0,crispr:0};
|
| 487 |
-
} else {
|
| 488 |
-
// All papers: use full summary from API
|
| 489 |
-
displayTotal = s.total;
|
| 490 |
-
displayFunctional = s.functional;
|
| 491 |
-
displayPancreatic = s.pancreatic;
|
| 492 |
-
displayGi = s.gi;
|
| 493 |
-
displayOther = s.other_cancer || 0;
|
| 494 |
-
methodCounts = s.methods || {};
|
| 495 |
-
}
|
| 496 |
-
|
| 497 |
const tags=[
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
].join('');
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
if (funcFilter !== 'false' && displayFunctional > 0) {
|
| 508 |
-
vt = Math.round(100*(s.in_vitro_only||0)/displayFunctional);
|
| 509 |
-
vv = Math.round(100*(s.in_vivo_only||0)/displayFunctional);
|
| 510 |
-
bt = Math.round(100*(s.both||0)/displayFunctional);
|
| 511 |
-
}
|
| 512 |
-
|
| 513 |
-
const paperLabel = funcFilter === 'true' ? 'functional studies'
|
| 514 |
-
: funcFilter === 'false' ? 'non-functional papers'
|
| 515 |
-
: 'papers';
|
| 516 |
-
const funcLine = funcFilter === 'all'
|
| 517 |
-
? ` · <strong>${displayFunctional}</strong> functional studies`
|
| 518 |
-
: '';
|
| 519 |
-
|
| 520 |
return `<div class="gcard sel">
|
| 521 |
<div class="gcname">${gene}</div>
|
| 522 |
-
<div class="gcinfo"
|
| 523 |
-
|
| 524 |
-
<
|
| 525 |
-
<div class="gcinfo" style="margin-top:4px;font-size:13px;">
|
| 526 |
-
Pancreatic: <strong>${displayPancreatic}</strong>
|
| 527 |
-
GI: <strong>${displayGi}</strong>
|
| 528 |
-
Other: <strong>${displayOther}</strong>
|
| 529 |
-
</div>
|
| 530 |
-
${funcFilter !== 'false' ? `<div class="minibar" style="margin-top:10px;">
|
| 531 |
<div style="width:${vt}%;background:var(--purple);"></div>
|
| 532 |
<div style="width:${vv}%;background:#f97316;"></div>
|
| 533 |
<div style="width:${bt}%;background:var(--accent);"></div>
|
| 534 |
-
</div>
|
| 535 |
${tags?`<div class="tags">${tags}</div>`:''}
|
| 536 |
</div>`;
|
| 537 |
}).join('');
|
|
@@ -544,252 +378,201 @@ function submitGene(gene) {
|
|
| 544 |
}
|
| 545 |
|
| 546 |
function renderTable(rows, total) {
|
| 547 |
-
const wrap=document.getElementById('tbl-wrap');
|
| 548 |
-
if (!rows.length){wrap.style.display='none';return;}
|
| 549 |
-
wrap.style.display='block';
|
| 550 |
-
document.getElementById('tbl-title').textContent=`${fmt(total)} paper${total!==1?'s':''}`;
|
| 551 |
-
let html=`<table><thead><tr>
|
| 552 |
<th>Gene</th><th>Title</th><th>Year</th><th>Cancer</th>
|
| 553 |
-
<th>Functional</th><th>Where
|
| 554 |
</tr></thead><tbody>`;
|
| 555 |
-
rows.forEach((row,i)=>{
|
| 556 |
-
const uid='r'+
|
| 557 |
-
const
|
| 558 |
-
|
| 559 |
-
const
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
const
|
| 563 |
-
|
| 564 |
-
row.where_functional==='
|
| 565 |
-
`<span class="badge
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
const cb=`<span class="badge b${ct==='pancreatic'?'panc':ct==='gi'?'gi':ct==='cancer'?'ca':'unk'}">${ct}</span>`;
|
| 569 |
-
const ttl=row.pubmed_link?`<a href="${row.pubmed_link}" target="_blank" rel="noopener">${esc(row.title)}</a>`:esc(row.title);
|
| 570 |
-
const dis=row.llm_rules_disagree?`<span class="bdis">
|
| 571 |
-
html+=`<tr>
|
| 572 |
-
<td class="tdg">${esc(row.gene||'')}</td>
|
| 573 |
-
<td class="tdt">${ttl}<div class="tdm">${esc(row.journal||'')}${row.doi?'
|
| 574 |
-
<td style="font-family:var(--mono);font-size:13px;color:var(--muted);white-space:nowrap;">${esc(row.year||'')}</td>
|
| 575 |
<td>${cb}</td><td>${fb}${dis}</td><td>${wb}</td>
|
| 576 |
-
<td><div class="cbar"><div class="cbg"><div class="cfg" style="width:${Math.round(conf*100)}%;background:${cc};"></div></div>
|
| 577 |
-
<span class="cnum">${conf.toFixed(2)}</span></div></td>
|
| 578 |
-
<td><
|
|
|
|
| 579 |
</tr>
|
| 580 |
-
<tr class="ev-row" id="${uid}"><td colspan="
|
| 581 |
});
|
| 582 |
-
document.getElementById('tbl-body').innerHTML=html+'</tbody></table>';
|
| 583 |
}
|
| 584 |
|
| 585 |
-
function buildEv(row) {
|
| 586 |
-
const parts=[];
|
| 587 |
if (row.llm_reasoning) parts.push(`<div class="ev-lbl">LLM reasoning</div><div class="ev-note">${esc(row.llm_reasoning)}</div>`);
|
| 588 |
-
[['evidence_perturbation','Perturbation'],['evidence_in_vitro','In vitro'],
|
| 589 |
-
['evidence_in_vivo','In vivo'],['evidence_crispr_screen','CRISPR screen']].forEach(([f,l])=>{
|
| 590 |
-
if (row[f])
|
| 591 |
-
|
|
|
|
|
|
|
| 592 |
});
|
| 593 |
-
const
|
| 594 |
-
|
| 595 |
-
row.
|
| 596 |
-
row.
|
| 597 |
-
row.
|
| 598 |
-
|
|
|
|
|
|
|
| 599 |
if (meta) parts.push(`<div class="ev-lbl" style="margin-top:12px;">Diagnostics</div><div class="ev-txt">${esc(meta)}</div>`);
|
| 600 |
-
|
| 601 |
-
}
|
| 602 |
-
|
| 603 |
-
function toggleEv(uid,btn){
|
| 604 |
-
const open=document.getElementById(uid).classList.toggle('open');
|
| 605 |
-
btn.textContent=open?'▾':'▸';
|
| 606 |
}
|
| 607 |
|
| 608 |
-
function
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 619 |
}
|
| 620 |
|
| 621 |
-
function
|
| 622 |
-
|
| 623 |
-
.split(/[\n,]+/).map(g=>g.trim().toUpperCase()).filter(Boolean);
|
| 624 |
-
if(!genes.length){alert('Enter at least one gene first.');return;}
|
| 625 |
-
window.location.href=api('/api/export',{
|
| 626 |
-
genes:genes.join(','),
|
| 627 |
-
cancer_type:document.getElementById('f-cancer').value,
|
| 628 |
-
functional:document.getElementById('f-func').value,
|
| 629 |
-
min_conf:document.getElementById('f-conf').value
|
| 630 |
-
});
|
| 631 |
}
|
| 632 |
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
const
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 645 |
}
|
| 646 |
|
| 647 |
-
function
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
const file = e.dataTransfer.files[0];
|
| 651 |
-
if (!file) return;
|
| 652 |
-
document.getElementById('search-csv-fname').textContent = file.name;
|
| 653 |
-
const reader = new FileReader();
|
| 654 |
-
reader.onload = ev => {
|
| 655 |
-
const genes = parseGeneList(ev.target.result);
|
| 656 |
-
document.getElementById('gene-input').value = genes.join('\n');
|
| 657 |
-
document.getElementById('search-csv-drop').style.borderColor = 'var(--green)';
|
| 658 |
-
};
|
| 659 |
-
reader.readAsText(file);
|
| 660 |
}
|
| 661 |
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
}
|
| 668 |
|
| 669 |
-
function
|
| 670 |
-
const
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
document.getElementById('
|
| 677 |
-
|
| 678 |
-
|
|
|
|
| 679 |
}
|
| 680 |
|
| 681 |
-
function
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
const
|
| 685 |
-
|
| 686 |
-
document.getElementById('
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 693 |
}
|
| 694 |
|
| 695 |
-
async function
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
const box = document.getElementById('bulk-result');
|
| 702 |
-
const maxPapers = parseInt(document.getElementById('bulk-max').value);
|
| 703 |
-
|
| 704 |
-
btn.disabled = true;
|
| 705 |
-
btn.innerHTML = '<span class="spin"></span> Submitting 0/' + genes.length + '…';
|
| 706 |
-
box.style.display = 'none';
|
| 707 |
-
|
| 708 |
-
const results = { queued: [], already: [], skipped: [], errors: [] };
|
| 709 |
-
|
| 710 |
-
for (let i = 0; i < genes.length; i++) {
|
| 711 |
-
const gene = genes[i];
|
| 712 |
-
btn.innerHTML = `<span class="spin"></span> Submitting ${i+1}/${genes.length}: ${gene}…`;
|
| 713 |
-
try {
|
| 714 |
-
const d = await fetch(api('/api/request'), {
|
| 715 |
-
method: 'POST', headers: {'Content-Type':'application/json'},
|
| 716 |
-
body: JSON.stringify({ gene, max_papers: maxPapers })
|
| 717 |
-
}).then(r => r.json());
|
| 718 |
-
|
| 719 |
-
if (d.error) results.errors.push(gene);
|
| 720 |
-
else if (d.status === 'queued') results.queued.push(gene);
|
| 721 |
-
else if (d.status === 'already_processed') results.already.push(gene);
|
| 722 |
-
else results.skipped.push(gene);
|
| 723 |
-
} catch(e) {
|
| 724 |
-
results.errors.push(gene);
|
| 725 |
}
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
btn.disabled = false;
|
| 729 |
-
btn.textContent = 'Submit All Genes';
|
| 730 |
-
|
| 731 |
-
const lines = [];
|
| 732 |
-
if (results.queued.length) lines.push(`✓ Queued (${results.queued.length}): ${results.queued.join(', ')}`);
|
| 733 |
-
if (results.already.length) lines.push(`ℹ Already in DB (${results.already.length}): ${results.already.join(', ')}`);
|
| 734 |
-
if (results.skipped.length) lines.push(`⚠ Already pending (${results.skipped.length}): ${results.skipped.join(', ')}`);
|
| 735 |
-
if (results.errors.length) lines.push(`✗ Errors (${results.errors.length}): ${results.errors.join(', ')}`);
|
| 736 |
-
|
| 737 |
-
const cls = results.errors.length ? 'err' : results.queued.length ? 'ok' : 'info';
|
| 738 |
-
box.className = `rbox ${cls}`;
|
| 739 |
-
box.style.display = 'block';
|
| 740 |
-
box.innerHTML = lines.join('<br>');
|
| 741 |
-
|
| 742 |
-
if (results.queued.length) loadStats();
|
| 743 |
-
}
|
| 744 |
-
|
| 745 |
-
async function submitRequest(){
|
| 746 |
-
const gene=document.getElementById('req-gene').value.trim().toUpperCase();
|
| 747 |
-
if(!gene){alert('Enter a gene symbol.');return;}
|
| 748 |
-
const btn=document.getElementById('req-btn');
|
| 749 |
-
btn.disabled=true;btn.innerHTML='<span class="spin"></span> Submitting…';
|
| 750 |
-
const box=document.getElementById('req-result');
|
| 751 |
-
try{
|
| 752 |
-
const d=await fetch(api('/api/request'),{
|
| 753 |
-
method:'POST',headers:{'Content-Type':'application/json'},
|
| 754 |
-
body:JSON.stringify({gene,max_papers:parseInt(document.getElementById('req-max').value)})
|
| 755 |
-
}).then(r=>r.json());
|
| 756 |
-
if(d.error){box.className='rbox err';box.style.display='block';box.textContent=d.error;return;}
|
| 757 |
-
const cls=d.status==='already_processed'?'info':d.status==='queued'?'ok':'warn';
|
| 758 |
-
box.className=`rbox ${cls}`;box.style.display='block';box.textContent=d.message;
|
| 759 |
-
if(d.status==='queued')loadStats();
|
| 760 |
-
}catch(e){box.className='rbox err';box.style.display='block';box.textContent='Network error: '+e.message;}
|
| 761 |
-
finally{btn.disabled=false;btn.textContent='Submit Request';}
|
| 762 |
-
}
|
| 763 |
-
|
| 764 |
-
async function loadQueue(){
|
| 765 |
-
try{
|
| 766 |
-
const d=await fetch(api('/api/queue')).then(r=>r.json());
|
| 767 |
-
const tbody=document.getElementById('queue-body');
|
| 768 |
-
if(!d.queue||!d.queue.length){
|
| 769 |
-
tbody.innerHTML='<tr><td colspan="6" style="text-align:center;padding:30px;color:var(--faint);">No requests yet.</td></tr>';return;}
|
| 770 |
-
tbody.innerHTML=d.queue.map(q=>`<tr>
|
| 771 |
<td style="font-weight:600;color:var(--text);font-family:var(--mono);">${esc(q.gene)}</td>
|
| 772 |
-
<td><span class="qs-${q.status}">${q.status}</span></td>
|
| 773 |
-
<td>${(q.requested_at||'').slice(0,16)}</td>
|
| 774 |
-
<td>${(q.started_at||'
|
| 775 |
-
<td>${(q.finished_at||'
|
| 776 |
-
<td style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${esc(q.error||'')}</td>
|
| 777 |
</tr>`).join('');
|
| 778 |
-
document.getElementById('tab-q').textContent=d.pending_count>0?`Queue (${d.pending_count})`:'Queue';
|
| 779 |
-
}catch(e){
|
| 780 |
-
document.getElementById('queue-body').innerHTML=
|
| 781 |
-
`<tr><td colspan="6" style="text-align:center;padding:20px;color:var(--red);">Error: ${esc(e.message)}</td></tr>`;
|
|
|
|
| 782 |
}
|
| 783 |
|
| 784 |
-
function showEmpty(msg){
|
| 785 |
-
document.getElementById('tbl-wrap').style.display='none';
|
| 786 |
-
document.getElementById('gcards').style.display='none';
|
| 787 |
-
const el=document.getElementById('results-empty');
|
| 788 |
-
el.style.display='block';el.innerHTML=`<div class="empty-icon">
|
| 789 |
}
|
| 790 |
|
| 791 |
-
function fmt(n){return(n||0).toLocaleString();}
|
| 792 |
-
function esc(s){return String(s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');}
|
| 793 |
-
</script>
|
| 794 |
</body>
|
| 795 |
-
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Gene Function Lab</title>
|
| 7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 9 |
<style>
|
|
|
|
| 47 |
.btn-p{background:var(--accent);color:#fff;}.btn-p:hover{background:#1d4ed8;}
|
| 48 |
.btn-o{background:var(--surface);color:var(--text);border:1px solid var(--border);}.btn-o:hover{background:var(--bg);}
|
| 49 |
.btn:disabled{opacity:.4;cursor:not-allowed;}
|
|
|
|
|
|
|
| 50 |
.gpills{display:flex;flex-wrap:wrap;gap:5px;}
|
| 51 |
+
.gpill{font-family:var(--mono);font-size:12px;font-weight:500;padding:3px 9px;background:var(--al);color:var(--accent);border:1px solid var(--ab);border-radius:5px;cursor:pointer;transition:background .12s;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
.gpill:hover{background:#dbeafe;}
|
|
|
|
|
|
|
| 53 |
.main{display:flex;flex-direction:column;overflow:hidden;}
|
| 54 |
.tabs{background:var(--surface);border-bottom:1px solid var(--border);display:flex;padding:0 24px;flex-shrink:0;}
|
| 55 |
.tab{padding:16px;font-size:14px;font-weight:500;cursor:pointer;color:var(--muted);border-bottom:2px solid transparent;transition:all .15s;}
|
|
|
|
| 83 |
.tdt{max-width:360px;}.tdt a{color:var(--text);font-weight:500;}.tdt a:hover{color:var(--accent);}
|
| 84 |
.tdm{font-size:12px;color:var(--faint);margin-top:3px;}
|
| 85 |
.badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500;}
|
| 86 |
+
.by{background:var(--gl);color:var(--green);}.bn{background:var(--bg);color:var(--faint);border:1px solid var(--border);}
|
| 87 |
+
.bb{background:var(--al);color:var(--accent);}.bvt{background:var(--pl);color:var(--purple);}
|
| 88 |
+
.bvv{background:#fff7ed;color:#c2410c;}.bpanc{background:var(--aml);color:var(--amber);}
|
| 89 |
+
.bgi{background:var(--gl);color:var(--green);}.bca{background:var(--rl);color:var(--red);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
.bunk{background:var(--bg);color:var(--faint);border:1px solid var(--border);}
|
|
|
|
| 91 |
.bdis{font-size:11px;color:var(--amber);background:var(--aml);border-radius:4px;padding:1px 6px;margin-left:4px;font-weight:500;}
|
| 92 |
.cbar{display:flex;align-items:center;gap:8px;}.cbg{flex:1;height:4px;background:var(--bg);border-radius:2px;min-width:48px;}
|
| 93 |
.cfg{height:100%;border-radius:2px;}.cnum{font-family:var(--mono);font-size:12px;color:var(--muted);white-space:nowrap;}
|
|
|
|
| 98 |
.ev-lbl{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--faint);margin-bottom:6px;}
|
| 99 |
.ev-txt{font-family:var(--mono);font-size:12px;color:var(--text);line-height:1.7;}
|
| 100 |
.ev-note{font-size:13px;color:var(--muted);line-height:1.6;font-style:italic;}
|
| 101 |
+
.review-box{margin-top:14px;padding:12px;border:1px solid var(--border);border-radius:8px;background:var(--surface);}
|
| 102 |
+
.review-grid{display:grid;grid-template-columns:160px 160px 1fr 110px;gap:8px;align-items:start;}
|
| 103 |
+
.review-grid select,.review-grid input{font-size:13px;padding:7px 9px;}
|
| 104 |
+
.review-save{height:35px;border:1px solid var(--ab);background:var(--al);color:var(--accent);border-radius:6px;font-family:var(--sans);font-weight:500;cursor:pointer;}
|
| 105 |
+
.review-save:hover{background:#dbeafe;}
|
| 106 |
+
.review-msg{font-size:12px;color:var(--muted);margin-top:8px;}
|
| 107 |
+
.bprio-high{background:var(--rl);color:var(--red);}.bprio-medium{background:var(--aml);color:var(--amber);}.bprio-low{background:var(--gl);color:var(--green);}.bprio-reviewed{background:var(--al);color:var(--accent);}
|
| 108 |
+
@media (max-width:900px){.review-grid{grid-template-columns:1fr;}.review-save{width:100%;}}
|
| 109 |
.pages{display:flex;align-items:center;justify-content:center;gap:6px;padding:16px;}
|
| 110 |
.pgbtn{padding:6px 13px;border-radius:6px;border:1px solid var(--border);background:var(--surface);color:var(--text);cursor:pointer;font-size:13px;font-family:var(--sans);transition:all .12s;}
|
| 111 |
.pgbtn:hover{border-color:var(--accent);color:var(--accent);}.pgbtn.on{background:var(--accent);color:#fff;border-color:var(--accent);}
|
|
|
|
| 140 |
<body>
|
| 141 |
<div class="shell">
|
| 142 |
<header class="topbar">
|
| 143 |
+
<div class="logo">Gene Function <em>Lab</em></div>
|
| 144 |
+
<div class="div"></div>
|
| 145 |
+
<span class="tagline">PubMed · BioMistral-7B</span>
|
| 146 |
<div class="dbstat"><span class="pulse"></span><span id="db-summary">Loading…</span></div>
|
| 147 |
</header>
|
| 148 |
<aside class="sidebar">
|
| 149 |
<div class="sbsec">
|
| 150 |
<div class="sblbl">Search genes</div>
|
| 151 |
<textarea id="gene-input" rows="4" placeholder="TP53 BRCA1 KRAS one per line"></textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
<div class="filters">
|
| 153 |
<div>
|
| 154 |
<label class="flabel">Cancer type</label>
|
| 155 |
+
<select id="f-cancer">
|
| 156 |
<option value="all">All types</option><option value="pancreatic">Pancreatic</option>
|
| 157 |
<option value="gi">GI cancers</option><option value="cancer">Other cancer</option>
|
| 158 |
</select>
|
| 159 |
</div>
|
| 160 |
<div>
|
| 161 |
<label class="flabel">Study type</label>
|
| 162 |
+
<select id="f-func">
|
| 163 |
<option value="all">All papers</option><option value="true">Functional only</option>
|
| 164 |
<option value="false">Non-functional only</option>
|
| 165 |
</select>
|
| 166 |
</div>
|
| 167 |
+
<div>
|
| 168 |
+
<label class="flabel">Review status</label>
|
| 169 |
+
<select id="f-review">
|
| 170 |
+
<option value="all">All review states</option>
|
| 171 |
+
<option value="unreviewed">Unreviewed</option>
|
| 172 |
+
<option value="needs_review">Needs review</option>
|
| 173 |
+
<option value="reviewed">Reviewed</option>
|
| 174 |
+
</select>
|
| 175 |
+
</div>
|
| 176 |
<div>
|
| 177 |
<label class="flabel">Min confidence: <span id="confv" style="color:var(--accent);font-weight:600;">0.00</span></label>
|
| 178 |
<div class="conf-row">
|
| 179 |
<input type="range" id="f-conf" min="0" max="1" step="0.05" value="0"
|
| 180 |
+
oninput="document.getElementById('confv').textContent=parseFloat(this.value).toFixed(2)">
|
| 181 |
</div>
|
| 182 |
</div>
|
| 183 |
<button class="btn btn-p" onclick="doSearch()">Search Database</button>
|
|
|
|
| 185 |
</div>
|
| 186 |
</div>
|
| 187 |
<div class="sbsec" style="flex:1;overflow-y:auto;">
|
| 188 |
+
<div class="sblbl">Genes in DB</div>
|
| 189 |
<div class="gpills" id="db-genes"></div>
|
| 190 |
</div>
|
| 191 |
</aside>
|
|
|
|
| 218 |
</div>
|
| 219 |
</div>
|
| 220 |
<div class="pane" id="pane-submit">
|
| 221 |
+
<div class="sub-card">
|
| 222 |
+
<h2>Request a new gene</h2>
|
| 223 |
+
<p>If a gene isn't in the database yet, submit it here. A lab member will run the pipeline and results will appear automatically.</p>
|
| 224 |
+
<div class="field">
|
| 225 |
+
<label>Gene symbol</label>
|
| 226 |
+
<input type="text" id="req-gene" placeholder="e.g. MSI1" maxlength="20"
|
| 227 |
+
oninput="this.value=this.value.toUpperCase()" onkeydown="if(event.key==='Enter')submitRequest()">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
</div>
|
| 229 |
+
<div class="field">
|
| 230 |
+
<label>Max papers to process</label>
|
| 231 |
+
<select id="req-max">
|
| 232 |
+
<option value="100">100 papers (faster)</option>
|
| 233 |
+
<option value="200">200 papers</option>
|
| 234 |
+
<option value="300" selected>300 papers (recommended)</option>
|
| 235 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
</div>
|
| 237 |
+
<button class="subbtn" id="req-btn" onclick="submitRequest()">Submit Request</button>
|
| 238 |
+
<div class="rbox" id="req-result"></div>
|
| 239 |
+
<div class="how">
|
| 240 |
+
<div class="how-lbl">How it works</div>
|
| 241 |
+
<div class="how-txt">
|
| 242 |
+
1. Submit a gene — it's added to the request queue<br>
|
| 243 |
+
2. A lab member opens the Colab notebook and runs the pipeline<br>
|
| 244 |
+
3. PubMed is searched, BioMistral-7B classifies each paper<br>
|
| 245 |
+
4. Results appear here automatically within an hour
|
| 246 |
+
</div>
|
| 247 |
</div>
|
| 248 |
</div>
|
| 249 |
</div>
|
|
|
|
| 261 |
</div>
|
| 262 |
<script>
|
| 263 |
// ── Base URL — works whether served direct or inside HF iframe ─────────────
|
| 264 |
+
const BASE = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
// ── Auth token ─────────────────────────────────────────────────────────────
|
| 267 |
const TOKEN = new URLSearchParams(window.location.search).get('token')
|
|
|
|
| 277 |
}
|
| 278 |
|
| 279 |
// ── State ──────────────────────────────────────────────────────────────────
|
| 280 |
+
const S = {page:1,perPage:25,genes:[],cancer:'all',func:'all',review:'all',conf:0,total:0,pages:1};
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
window.addEventListener('DOMContentLoaded', () => { loadStats(); setInterval(loadStats, 60000); });
|
| 283 |
|
|
|
|
| 297 |
document.getElementById('s-func').textContent = fmt(d.functional_papers);
|
| 298 |
document.getElementById('db-summary').textContent =
|
| 299 |
`${fmt(d.total_papers)} papers · ${fmt(d.total_genes)} genes · synced ${d.last_sync||'—'}`;
|
| 300 |
+
document.getElementById('db-genes').innerHTML = (d.all_genes||[]).map(g=>
|
| 301 |
+
`<span class="gpill" onclick="quickSearch('${g}')">${g}</span>`).join('');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
} catch(e) {
|
| 303 |
document.getElementById('db-summary').textContent = 'DB unavailable';
|
| 304 |
}
|
| 305 |
}
|
| 306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
function quickSearch(gene) {
|
| 308 |
document.getElementById('gene-input').value = gene;
|
| 309 |
switchTab('results', document.querySelector('.tab'));
|
| 310 |
doSearch();
|
| 311 |
}
|
| 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
async function doSearch(page) {
|
| 314 |
const genes = document.getElementById('gene-input').value
|
| 315 |
.split(/[\n,]+/).map(g=>g.trim().toUpperCase()).filter(Boolean);
|
| 316 |
if (!genes.length) { alert('Enter at least one gene symbol.'); return; }
|
| 317 |
S.genes=genes; S.cancer=document.getElementById('f-cancer').value;
|
| 318 |
S.func=document.getElementById('f-func').value;
|
| 319 |
+
S.review=document.getElementById('f-review').value;
|
| 320 |
S.conf=parseFloat(document.getElementById('f-conf').value);
|
| 321 |
S.page=page||1;
|
| 322 |
const btn = document.querySelector('.btn-p');
|
|
|
|
| 324 |
try {
|
| 325 |
const url = api('/api/query', {
|
| 326 |
genes: genes.join(','), cancer_type: S.cancer,
|
| 327 |
+
functional: S.func, review_status: S.review, min_conf: S.conf,
|
| 328 |
page: S.page, per_page: S.perPage
|
| 329 |
});
|
| 330 |
const d = await fetch(url).then(r=>r.json());
|
| 331 |
S.total=d.total; S.pages=d.pages;
|
| 332 |
document.getElementById('s-match').textContent = fmt(d.total);
|
| 333 |
+
renderCards(genes, d.summaries||{});
|
| 334 |
renderTable(d.rows||[], d.total);
|
| 335 |
renderPages(d.page, d.pages);
|
| 336 |
document.getElementById('results-empty').style.display = (d.rows&&d.rows.length)?'none':'block';
|
|
|
|
| 338 |
finally { btn.disabled=false; btn.textContent='Search Database'; }
|
| 339 |
}
|
| 340 |
|
| 341 |
+
function renderCards(genes, summaries) {
|
|
|
|
| 342 |
const el = document.getElementById('gcards');
|
|
|
|
|
|
|
| 343 |
el.innerHTML = genes.map(gene => {
|
| 344 |
const s = summaries[gene]||{};
|
| 345 |
if (!s.total) return `<div class="gcard" onclick="submitGene('${gene}')">
|
| 346 |
<div class="gcname">${gene}</div>
|
| 347 |
<div class="gcinfo" style="color:var(--amber);margin-top:6px;">Not in database</div>
|
| 348 |
<div class="gcinfo" style="font-size:13px;margin-top:3px;">Click to request</div></div>`;
|
| 349 |
+
const pct=Math.round(100*s.functional/s.total), m=s.methods||{};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
const tags=[
|
| 351 |
+
m.knockout?`<span class="tag t-ko">KO×${m.knockout}</span>`:'',
|
| 352 |
+
m.knockdown?`<span class="tag t-kd">KD×${m.knockdown}</span>`:'',
|
| 353 |
+
m.shrna?`<span class="tag t-shrna">shRNA×${m.shrna}</span>`:'',
|
| 354 |
+
m.sirna?`<span class="tag t-sirna">siRNA×${m.sirna}</span>`:'',
|
| 355 |
+
m.crispr?`<span class="tag t-crispr">CRISPR×${m.crispr}</span>`:'',
|
| 356 |
].join('');
|
| 357 |
+
const vt=s.functional?Math.round(100*s.in_vitro_only/s.functional):0;
|
| 358 |
+
const vv=s.functional?Math.round(100*s.in_vivo_only/s.functional):0;
|
| 359 |
+
const bt=s.functional?Math.round(100*s.both/s.functional):0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
return `<div class="gcard sel">
|
| 361 |
<div class="gcname">${gene}</div>
|
| 362 |
+
<div class="gcinfo"><strong>${s.functional}</strong> functional / ${s.total} papers (${pct}%)</div>
|
| 363 |
+
<div class="gcinfo">Pancreatic: <strong>${s.pancreatic}</strong> GI: <strong>${s.gi}</strong></div>
|
| 364 |
+
<div class="minibar">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
<div style="width:${vt}%;background:var(--purple);"></div>
|
| 366 |
<div style="width:${vv}%;background:#f97316;"></div>
|
| 367 |
<div style="width:${bt}%;background:var(--accent);"></div>
|
| 368 |
+
</div>
|
| 369 |
${tags?`<div class="tags">${tags}</div>`:''}
|
| 370 |
</div>`;
|
| 371 |
}).join('');
|
|
|
|
| 378 |
}
|
| 379 |
|
| 380 |
function renderTable(rows, total) {
|
| 381 |
+
const wrap = document.getElementById('tbl-wrap');
|
| 382 |
+
if (!rows.length) { wrap.style.display = 'none'; return; }
|
| 383 |
+
wrap.style.display = 'block';
|
| 384 |
+
document.getElementById('tbl-title').textContent = `${fmt(total)} paper${total !== 1 ? 's' : ''}`;
|
| 385 |
+
let html = `<table><thead><tr>
|
| 386 |
<th>Gene</th><th>Title</th><th>Year</th><th>Cancer</th>
|
| 387 |
+
<th>Functional</th><th>Where</th><th>Confidence</th><th>Review</th><th></th>
|
| 388 |
</tr></thead><tbody>`;
|
| 389 |
+
rows.forEach((row, i) => {
|
| 390 |
+
const uid = 'r' + i;
|
| 391 |
+
const conf = parseFloat(row.confidence) || 0;
|
| 392 |
+
const cc = conf >= .8 ? 'var(--green)' : conf >= .6 ? 'var(--amber)' : 'var(--red)';
|
| 393 |
+
const label = row.confidence_label || (conf >= .8 ? 'strong' : conf >= .6 ? 'moderate' : 'weak');
|
| 394 |
+
const priority = row.review_priority || 'low';
|
| 395 |
+
const status = row.review_status || 'unreviewed';
|
| 396 |
+
const fb = row.functional_study ? `<span class="badge by">Yes</span>` : `<span class="badge bn">No</span>`;
|
| 397 |
+
const wb = row.where_functional === 'both' ? `<span class="badge bb">Both</span>` :
|
| 398 |
+
row.where_functional === 'in_vitro' ? `<span class="badge bvt">In vitro</span>` :
|
| 399 |
+
row.where_functional === 'in_vivo' ? `<span class="badge bvv">In vivo</span>` :
|
| 400 |
+
`<span class="badge bn">Unknown</span>`;
|
| 401 |
+
const ct = row.cancer_type || 'unk';
|
| 402 |
+
const cb = `<span class="badge b${ct === 'pancreatic' ? 'panc' : ct === 'gi' ? 'gi' : ct === 'cancer' ? 'ca' : 'unk'}">${esc(ct)}</span>`;
|
| 403 |
+
const ttl = row.pubmed_link ? `<a href="${attr(row.pubmed_link)}" target="_blank" rel="noopener">${esc(row.title)}</a>` : esc(row.title);
|
| 404 |
+
const dis = row.llm_rules_disagree ? `<span class="bdis">disagree</span>` : '';
|
| 405 |
+
html += `<tr>
|
| 406 |
+
<td class="tdg">${esc(row.gene || '')}</td>
|
| 407 |
+
<td class="tdt">${ttl}<div class="tdm">${esc(row.journal || '')}${row.doi ? ' - ' + esc(row.doi) : ''}</div></td>
|
| 408 |
+
<td style="font-family:var(--mono);font-size:13px;color:var(--muted);white-space:nowrap;">${esc(row.year || '')}</td>
|
| 409 |
<td>${cb}</td><td>${fb}${dis}</td><td>${wb}</td>
|
| 410 |
+
<td><div class="cbar"><div class="cbg"><div class="cfg" style="width:${Math.round(conf * 100)}%;background:${cc};"></div></div>
|
| 411 |
+
<span class="cnum">${conf.toFixed(2)}</span></div><div class="tdm">${esc(label)}</div></td>
|
| 412 |
+
<td><span class="badge bprio-${attr(priority)}">${esc(status)}</span></td>
|
| 413 |
+
<td><button class="xbtn" onclick="toggleEv('${uid}',this)">More</button></td>
|
| 414 |
</tr>
|
| 415 |
+
<tr class="ev-row" id="${uid}"><td colspan="9" class="ev-cell">${buildEv(row, uid)}</td></tr>`;
|
| 416 |
});
|
| 417 |
+
document.getElementById('tbl-body').innerHTML = html + '</tbody></table>';
|
| 418 |
}
|
| 419 |
|
| 420 |
+
function buildEv(row, uid) {
|
| 421 |
+
const parts = [];
|
| 422 |
if (row.llm_reasoning) parts.push(`<div class="ev-lbl">LLM reasoning</div><div class="ev-note">${esc(row.llm_reasoning)}</div>`);
|
| 423 |
+
[['evidence_perturbation','Perturbation'], ['evidence_in_vitro','In vitro'],
|
| 424 |
+
['evidence_in_vivo','In vivo'], ['evidence_crispr_screen','CRISPR screen']].forEach(([f, l]) => {
|
| 425 |
+
if (row[f]) {
|
| 426 |
+
parts.push(`<div class="ev-lbl" style="margin-top:${parts.length ? '12px' : '0'};">${l}</div>` +
|
| 427 |
+
row[f].split('|').filter(Boolean).map(x => `<div class="ev-txt">- ${esc(x)}</div>`).join(''));
|
| 428 |
+
}
|
| 429 |
});
|
| 430 |
+
const signals = (row.review_signals || []).map(x => `<span class="badge bprio-medium">${esc(x.replace(/_/g, ' '))}</span>`).join(' ');
|
| 431 |
+
const meta = [
|
| 432 |
+
row.classified_by_llm !== undefined ? `LLM: ${row.classified_by_llm}` : null,
|
| 433 |
+
row.rules_functional !== undefined ? `Rules: ${row.rules_functional}` : null,
|
| 434 |
+
row.total_evidence_sents ? `Evidence sentences: ${row.total_evidence_sents}` : null,
|
| 435 |
+
row.pmcid ? `PMCID: ${row.pmcid}` : null,
|
| 436 |
+
].filter(Boolean).join(' - ');
|
| 437 |
+
if (signals) parts.push(`<div class="ev-lbl" style="margin-top:12px;">Review signals</div><div>${signals}</div>`);
|
| 438 |
if (meta) parts.push(`<div class="ev-lbl" style="margin-top:12px;">Diagnostics</div><div class="ev-txt">${esc(meta)}</div>`);
|
| 439 |
+
parts.push(reviewBox(row, uid));
|
| 440 |
+
return parts.join('') || `<div class="ev-txt" style="color:var(--faint);">No evidence extracted.</div>${reviewBox(row, uid)}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
}
|
| 442 |
|
| 443 |
+
function reviewBox(row, uid) {
|
| 444 |
+
return `<div class="review-box">
|
| 445 |
+
<div class="ev-lbl">Human review</div>
|
| 446 |
+
<div class="review-grid">
|
| 447 |
+
${sel(`rev-status-${uid}`, row.review_status || 'unreviewed', [
|
| 448 |
+
['unreviewed','Unreviewed'], ['needs_review','Needs review'], ['reviewed','Reviewed']
|
| 449 |
+
])}
|
| 450 |
+
${sel(`rev-label-${uid}`, row.review_label || '', [
|
| 451 |
+
['','No label'], ['functional','Functional'], ['not_functional','Not functional'], ['unclear','Unclear']
|
| 452 |
+
])}
|
| 453 |
+
<input id="rev-notes-${uid}" type="text" value="${attr(row.review_notes || '')}" placeholder="Short reviewer note">
|
| 454 |
+
<button class="review-save" onclick="saveReview('${uid}', '${attr(row.gene || '')}', '${attr(row.pmid || '')}', this)">Save</button>
|
| 455 |
+
</div>
|
| 456 |
+
<div id="rev-msg-${uid}" class="review-msg">Priority: ${esc(row.review_priority || 'low')} - Confidence: ${esc(row.confidence_label || '')}</div>
|
| 457 |
+
</div>`;
|
| 458 |
}
|
| 459 |
|
| 460 |
+
function sel(id, value, opts) {
|
| 461 |
+
return `<select id="${id}">${opts.map(([v, t]) => `<option value="${attr(v)}" ${v === value ? 'selected' : ''}>${esc(t)}</option>`).join('')}</select>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 462 |
}
|
| 463 |
|
| 464 |
+
async function saveReview(uid, gene, pmid, btn) {
|
| 465 |
+
const msg = document.getElementById(`rev-msg-${uid}`);
|
| 466 |
+
const old = btn.textContent;
|
| 467 |
+
btn.disabled = true;
|
| 468 |
+
btn.textContent = 'Saving';
|
| 469 |
+
try {
|
| 470 |
+
const d = await fetch(api('/api/review'), {
|
| 471 |
+
method: 'POST',
|
| 472 |
+
headers: {'Content-Type': 'application/json'},
|
| 473 |
+
body: JSON.stringify({
|
| 474 |
+
gene,
|
| 475 |
+
pmid,
|
| 476 |
+
review_status: document.getElementById(`rev-status-${uid}`).value,
|
| 477 |
+
review_label: document.getElementById(`rev-label-${uid}`).value,
|
| 478 |
+
review_notes: document.getElementById(`rev-notes-${uid}`).value,
|
| 479 |
+
reviewed_by: 'website'
|
| 480 |
+
})
|
| 481 |
+
}).then(r => r.json());
|
| 482 |
+
if (d.error) throw new Error(d.error);
|
| 483 |
+
msg.style.color = d.uploaded ? 'var(--green)' : 'var(--amber)';
|
| 484 |
+
msg.textContent = d.uploaded ? 'Saved and uploaded to Drive.' : 'Saved locally. Drive upload did not complete; replace/upload DB before Space restart.';
|
| 485 |
+
loadStats();
|
| 486 |
+
} catch (e) {
|
| 487 |
+
msg.style.color = 'var(--red)';
|
| 488 |
+
msg.textContent = 'Save failed: ' + e.message;
|
| 489 |
+
} finally {
|
| 490 |
+
btn.disabled = false;
|
| 491 |
+
btn.textContent = old;
|
| 492 |
+
}
|
| 493 |
}
|
| 494 |
|
| 495 |
+
function toggleEv(uid, btn) {
|
| 496 |
+
const open = document.getElementById(uid).classList.toggle('open');
|
| 497 |
+
btn.textContent = open ? 'Less' : 'More';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
}
|
| 499 |
|
| 500 |
+
function renderPages(page, pages) {
|
| 501 |
+
const el = document.getElementById('pages');
|
| 502 |
+
if (pages <= 1) { el.innerHTML = ''; return; }
|
| 503 |
+
let h = `<button class="pgbtn" onclick="doSearch(${page - 1})" ${page === 1 ? 'disabled' : ''}>Prev</button>`;
|
| 504 |
+
const s = Math.max(1, page - 2), e = Math.min(pages, page + 2);
|
| 505 |
+
if (s > 1) h += `<button class="pgbtn" onclick="doSearch(1)">1</button>${s > 2 ? '<span class="pginfo">...</span>' : ''}`;
|
| 506 |
+
for (let p = s; p <= e; p++) h += `<button class="pgbtn ${p === page ? 'on' : ''}" onclick="doSearch(${p})">${p}</button>`;
|
| 507 |
+
if (e < pages) h += `${e < pages - 1 ? '<span class="pginfo">...</span>' : ''}<button class="pgbtn" onclick="doSearch(${pages})">${pages}</button>`;
|
| 508 |
+
h += `<button class="pgbtn" onclick="doSearch(${page + 1})" ${page === pages ? 'disabled' : ''}>Next</button>`;
|
| 509 |
+
h += `<span class="pginfo">Page ${page} of ${pages}</span>`;
|
| 510 |
+
el.innerHTML = h;
|
| 511 |
}
|
| 512 |
|
| 513 |
+
function doExport() {
|
| 514 |
+
const genes = document.getElementById('gene-input').value
|
| 515 |
+
.split(/[\n,]+/).map(g => g.trim().toUpperCase()).filter(Boolean);
|
| 516 |
+
if (!genes.length) { alert('Enter at least one gene first.'); return; }
|
| 517 |
+
window.location.href = api('/api/export', {
|
| 518 |
+
genes: genes.join(','),
|
| 519 |
+
cancer_type: document.getElementById('f-cancer').value,
|
| 520 |
+
functional: document.getElementById('f-func').value,
|
| 521 |
+
review_status: document.getElementById('f-review').value,
|
| 522 |
+
min_conf: document.getElementById('f-conf').value
|
| 523 |
+
});
|
| 524 |
}
|
| 525 |
|
| 526 |
+
async function submitRequest() {
|
| 527 |
+
const gene = document.getElementById('req-gene').value.trim().toUpperCase();
|
| 528 |
+
if (!gene) { alert('Enter a gene symbol.'); return; }
|
| 529 |
+
const btn = document.getElementById('req-btn');
|
| 530 |
+
btn.disabled = true; btn.innerHTML = '<span class="spin"></span> Submitting...';
|
| 531 |
+
const box = document.getElementById('req-result');
|
| 532 |
+
try {
|
| 533 |
+
const d = await fetch(api('/api/request'), {
|
| 534 |
+
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 535 |
+
body: JSON.stringify({gene, max_papers: parseInt(document.getElementById('req-max').value)})
|
| 536 |
+
}).then(r => r.json());
|
| 537 |
+
if (d.error) { box.className = 'rbox err'; box.style.display = 'block'; box.textContent = d.error; return; }
|
| 538 |
+
const cls = d.status === 'already_processed' ? 'info' : d.status === 'queued' ? 'ok' : 'warn';
|
| 539 |
+
box.className = `rbox ${cls}`; box.style.display = 'block'; box.textContent = d.message;
|
| 540 |
+
if (d.status === 'queued') loadStats();
|
| 541 |
+
} catch (e) { box.className = 'rbox err'; box.style.display = 'block'; box.textContent = 'Network error: ' + e.message; }
|
| 542 |
+
finally { btn.disabled = false; btn.textContent = 'Submit Request'; }
|
| 543 |
}
|
| 544 |
|
| 545 |
+
async function loadQueue() {
|
| 546 |
+
try {
|
| 547 |
+
const d = await fetch(api('/api/queue')).then(r => r.json());
|
| 548 |
+
const tbody = document.getElementById('queue-body');
|
| 549 |
+
if (!d.queue || !d.queue.length) {
|
| 550 |
+
tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:30px;color:var(--faint);">No requests yet.</td></tr>'; return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
}
|
| 552 |
+
tbody.innerHTML = d.queue.map(q => `<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
<td style="font-weight:600;color:var(--text);font-family:var(--mono);">${esc(q.gene)}</td>
|
| 554 |
+
<td><span class="qs-${attr(q.status)}">${esc(q.status)}</span></td>
|
| 555 |
+
<td>${esc((q.requested_at || '').slice(0, 16))}</td>
|
| 556 |
+
<td>${esc((q.started_at || '-').slice(0, 16))}</td>
|
| 557 |
+
<td>${esc((q.finished_at || '-').slice(0, 16))}</td>
|
| 558 |
+
<td style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${esc(q.error || '')}</td>
|
| 559 |
</tr>`).join('');
|
| 560 |
+
document.getElementById('tab-q').textContent = d.pending_count > 0 ? `Queue (${d.pending_count})` : 'Queue';
|
| 561 |
+
} catch (e) {
|
| 562 |
+
document.getElementById('queue-body').innerHTML =
|
| 563 |
+
`<tr><td colspan="6" style="text-align:center;padding:20px;color:var(--red);">Error: ${esc(e.message)}</td></tr>`;
|
| 564 |
+
}
|
| 565 |
}
|
| 566 |
|
| 567 |
+
function showEmpty(msg) {
|
| 568 |
+
document.getElementById('tbl-wrap').style.display = 'none';
|
| 569 |
+
document.getElementById('gcards').style.display = 'none';
|
| 570 |
+
const el = document.getElementById('results-empty');
|
| 571 |
+
el.style.display = 'block'; el.innerHTML = `<div class="empty-icon">DNA</div>${esc(msg)}`;
|
| 572 |
}
|
| 573 |
|
| 574 |
+
function fmt(n) { return (n || 0).toLocaleString(); }
|
| 575 |
+
function esc(s) { return String(s || '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); }
|
| 576 |
+
function attr(s) { return esc(s).replace(/'/g, '''); }</script>
|
| 577 |
</body>
|
| 578 |
+
</html>
|