Suggest assemblies with many indexed segments across all six divisions
Browse files- app.py +12 -1
- data/suggested_accessions.json +11 -0
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
"""A small Hugging Face Space for exploring genome annotations by accession."""
|
| 2 |
from pathlib import Path
|
| 3 |
from contextlib import closing
|
|
|
|
| 4 |
import os
|
| 5 |
import re
|
| 6 |
import tempfile
|
|
@@ -145,11 +146,21 @@ def build_app(catalog=None):
|
|
| 145 |
accession = gr.Textbox(label="Accession ID", placeholder="Assembly (GCA_…) or contig accession", scale=5)
|
| 146 |
search_button = gr.Button("Find annotations", variant="primary", scale=1, elem_classes="action-button")
|
| 147 |
examples = [first["assembly_accession"], first["record_name"]]
|
|
|
|
| 148 |
if remote_mode:
|
| 149 |
examples += catalog.manifest.get("example_record_names", [])[:6]
|
| 150 |
if not full_snapshot:
|
| 151 |
examples += ["JBPJTW010000350.1"]
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
status = gr.Markdown("Enter an accession or select an example. IDs are case-insensitive; version suffixes are optional.", elem_classes="quiet-note")
|
| 154 |
results = gr.Dataframe(value=catalog.table([]), interactive=False, label="Matching segments", elem_id="annotation-results")
|
| 155 |
segment = gr.Dropdown(choices=[], label="Segment to explore", interactive=True)
|
|
|
|
| 1 |
"""A small Hugging Face Space for exploring genome annotations by accession."""
|
| 2 |
from pathlib import Path
|
| 3 |
from contextlib import closing
|
| 4 |
+
import json
|
| 5 |
import os
|
| 6 |
import re
|
| 7 |
import tempfile
|
|
|
|
| 146 |
accession = gr.Textbox(label="Accession ID", placeholder="Assembly (GCA_…) or contig accession", scale=5)
|
| 147 |
search_button = gr.Button("Find annotations", variant="primary", scale=1, elem_classes="action-button")
|
| 148 |
examples = [first["assembly_accession"], first["record_name"]]
|
| 149 |
+
example_labels = None
|
| 150 |
if remote_mode:
|
| 151 |
examples += catalog.manifest.get("example_record_names", [])[:6]
|
| 152 |
if not full_snapshot:
|
| 153 |
examples += ["JBPJTW010000350.1"]
|
| 154 |
+
suggestions_path = Path(__file__).parent / "data/suggested_accessions.json"
|
| 155 |
+
if full_snapshot and suggestions_path.exists():
|
| 156 |
+
suggestions = json.loads(suggestions_path.read_text())
|
| 157 |
+
if suggestions["inventory_sha256"] == catalog.manifest.get("inventory_sha256"):
|
| 158 |
+
examples = [entry["accession"] for entry in suggestions["examples"]]
|
| 159 |
+
example_labels = [f"{entry['organism']} · {entry['segments']:,} segments" for entry in suggestions["examples"]]
|
| 160 |
+
gr.Examples(examples=[[e] for e in dict.fromkeys(examples)], inputs=accession,
|
| 161 |
+
example_labels=example_labels,
|
| 162 |
+
label="Explore an assembly with many segments" if example_labels else "Try an accession",
|
| 163 |
+
elem_id="annotation-examples")
|
| 164 |
status = gr.Markdown("Enter an accession or select an example. IDs are case-insensitive; version suffixes are optional.", elem_classes="quiet-note")
|
| 165 |
results = gr.Dataframe(value=catalog.table([]), interactive=False, label="Matching segments", elem_id="annotation-results")
|
| 166 |
segment = gr.Dropdown(choices=[], label="Segment to explore", interactive=True)
|
data/suggested_accessions.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"inventory_sha256": "6977ea207d67fc662a39df05352a99b4b6c489195c1b5880b266dfc2f2da2dd7",
|
| 3 |
+
"examples": [
|
| 4 |
+
{"accession": "GCA_015093335.1", "organism": "Homo sapiens", "segments": 2719},
|
| 5 |
+
{"accession": "GCA_014706055.1", "organism": "Lycocorax pyrrhopterus obiensis", "segments": 2582},
|
| 6 |
+
{"accession": "GCA_023898315.2", "organism": "Schistocerca nitens", "segments": 585},
|
| 7 |
+
{"accession": "GCA_055472915.1", "organism": "Phakopsora pachyrhizi", "segments": 350},
|
| 8 |
+
{"accession": "GCA_024718635.1", "organism": "Zea mays", "segments": 198},
|
| 9 |
+
{"accession": "GCA_039621445.1", "organism": "Euglena gracilis", "segments": 47}
|
| 10 |
+
]
|
| 11 |
+
}
|