Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
089fea2
1
Parent(s):
a56975c
fix: species names
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ if HF_TOKEN is None:
|
|
| 39 |
)
|
| 40 |
|
| 41 |
PLOT_TARGET_POINTS = int(os.environ.get("PLOT_TARGET_POINTS", "1500"))
|
| 42 |
-
SEARCH_MAX_RESULTS = int(os.environ.get("SEARCH_MAX_RESULTS", "
|
| 43 |
|
| 44 |
# -----------------------------
|
| 45 |
# Load pipeline (reloadable)
|
|
@@ -249,8 +249,8 @@ def _load_track_metadata() -> dict[str, str]:
|
|
| 249 |
|
| 250 |
# Build display name from available fields
|
| 251 |
parts = []
|
| 252 |
-
if biosample_type and biosample_type != "tissue":
|
| 253 |
-
|
| 254 |
if tissue:
|
| 255 |
parts.append(tissue)
|
| 256 |
if assay:
|
|
@@ -267,7 +267,7 @@ def _load_track_metadata() -> dict[str, str]:
|
|
| 267 |
parts.append(experiment_target)
|
| 268 |
|
| 269 |
if parts:
|
| 270 |
-
display_name = "
|
| 271 |
else:
|
| 272 |
display_name = track_id # Fallback to ID if no metadata
|
| 273 |
|
|
@@ -793,10 +793,10 @@ DEFAULT_COORDS = {
|
|
| 793 |
_default_coords = DEFAULT_COORDS.get(DEFAULT_SPECIES, DEFAULT_COORDS["human"])
|
| 794 |
|
| 795 |
|
| 796 |
-
# Format species names for display (replace underscores with spaces, capitalize)
|
| 797 |
def _format_species_name(species: str) -> str:
|
| 798 |
"""Format species name for display."""
|
| 799 |
-
return species.replace("_", " ").
|
| 800 |
|
| 801 |
|
| 802 |
# Get all available species and format them
|
|
@@ -907,11 +907,14 @@ with gr.Blocks(title="NTv3 Tracks Demo") as demo:
|
|
| 907 |
|
| 908 |
gr.Markdown("# Input DNA sequence")
|
| 909 |
|
| 910 |
-
# Get all available species from the pipeline
|
| 911 |
all_species = sorted(ASSEMBLY_TO_SPECIES.values())
|
|
|
|
|
|
|
|
|
|
| 912 |
|
| 913 |
species = gr.Dropdown(
|
| 914 |
-
choices=
|
| 915 |
value=DEFAULT_SPECIES,
|
| 916 |
label="Species",
|
| 917 |
)
|
|
@@ -1034,18 +1037,9 @@ with gr.Blocks(title="NTv3 Tracks Demo") as demo:
|
|
| 1034 |
visible=False,
|
| 1035 |
)
|
| 1036 |
|
| 1037 |
-
bigwig_selected = gr.CheckboxGroup(
|
| 1038 |
-
choices=_init_bigwig_selected,
|
| 1039 |
-
value=_init_bigwig_selected,
|
| 1040 |
-
label="Selected functional tracks (used for prediction)",
|
| 1041 |
-
visible=bool(
|
| 1042 |
-
_init_bigwig_selected
|
| 1043 |
-
), # Show if there are default tracks, otherwise hidden
|
| 1044 |
-
)
|
| 1045 |
-
|
| 1046 |
bigwig_query = gr.Textbox(
|
| 1047 |
label="Search functional tracks (auto-search while typing)",
|
| 1048 |
-
placeholder="Type to search… (e.g. heart
|
| 1049 |
)
|
| 1050 |
|
| 1051 |
bigwig_results = gr.CheckboxGroup(
|
|
@@ -1053,6 +1047,15 @@ with gr.Blocks(title="NTv3 Tracks Demo") as demo:
|
|
| 1053 |
label="Results (click to add to Selected)",
|
| 1054 |
)
|
| 1055 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1056 |
with gr.Row(visible=True) as bigwig_buttons_row:
|
| 1057 |
bigwig_clear_btn = gr.Button("Clear search results")
|
| 1058 |
bigwig_remove_btn = gr.Button("Remove all selected")
|
|
|
|
| 39 |
)
|
| 40 |
|
| 41 |
PLOT_TARGET_POINTS = int(os.environ.get("PLOT_TARGET_POINTS", "1500"))
|
| 42 |
+
SEARCH_MAX_RESULTS = int(os.environ.get("SEARCH_MAX_RESULTS", "20"))
|
| 43 |
|
| 44 |
# -----------------------------
|
| 45 |
# Load pipeline (reloadable)
|
|
|
|
| 249 |
|
| 250 |
# Build display name from available fields
|
| 251 |
parts = []
|
| 252 |
+
# if biosample_type and biosample_type != "tissue":
|
| 253 |
+
# parts.append(biosample_type)
|
| 254 |
if tissue:
|
| 255 |
parts.append(tissue)
|
| 256 |
if assay:
|
|
|
|
| 267 |
parts.append(experiment_target)
|
| 268 |
|
| 269 |
if parts:
|
| 270 |
+
display_name = " ".join(parts)
|
| 271 |
else:
|
| 272 |
display_name = track_id # Fallback to ID if no metadata
|
| 273 |
|
|
|
|
| 793 |
_default_coords = DEFAULT_COORDS.get(DEFAULT_SPECIES, DEFAULT_COORDS["human"])
|
| 794 |
|
| 795 |
|
| 796 |
+
# Format species names for display (replace underscores with spaces, capitalize first letter)
|
| 797 |
def _format_species_name(species: str) -> str:
|
| 798 |
"""Format species name for display."""
|
| 799 |
+
return species.replace("_", " ").capitalize()
|
| 800 |
|
| 801 |
|
| 802 |
# Get all available species and format them
|
|
|
|
| 907 |
|
| 908 |
gr.Markdown("# Input DNA sequence")
|
| 909 |
|
| 910 |
+
# Get all available species from the pipeline and format for display
|
| 911 |
all_species = sorted(ASSEMBLY_TO_SPECIES.values())
|
| 912 |
+
# Format choices as (display_name, value) tuples so dropdown shows formatted names
|
| 913 |
+
# but returns actual species values
|
| 914 |
+
species_choices = [(_format_species_name(s), s) for s in all_species]
|
| 915 |
|
| 916 |
species = gr.Dropdown(
|
| 917 |
+
choices=species_choices,
|
| 918 |
value=DEFAULT_SPECIES,
|
| 919 |
label="Species",
|
| 920 |
)
|
|
|
|
| 1037 |
visible=False,
|
| 1038 |
)
|
| 1039 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1040 |
bigwig_query = gr.Textbox(
|
| 1041 |
label="Search functional tracks (auto-search while typing)",
|
| 1042 |
+
placeholder="Type to search… (e.g. heart DNAse-seq)",
|
| 1043 |
)
|
| 1044 |
|
| 1045 |
bigwig_results = gr.CheckboxGroup(
|
|
|
|
| 1047 |
label="Results (click to add to Selected)",
|
| 1048 |
)
|
| 1049 |
|
| 1050 |
+
bigwig_selected = gr.CheckboxGroup(
|
| 1051 |
+
choices=_init_bigwig_selected,
|
| 1052 |
+
value=_init_bigwig_selected,
|
| 1053 |
+
label="Selected functional tracks (used for prediction)",
|
| 1054 |
+
visible=bool(
|
| 1055 |
+
_init_bigwig_selected
|
| 1056 |
+
), # Show if there are default tracks, otherwise hidden
|
| 1057 |
+
)
|
| 1058 |
+
|
| 1059 |
with gr.Row(visible=True) as bigwig_buttons_row:
|
| 1060 |
bigwig_clear_btn = gr.Button("Clear search results")
|
| 1061 |
bigwig_remove_btn = gr.Button("Remove all selected")
|