--- $(date) Implemented server-side storage for variants table annotations. ## Overview: Added server-side persistence for the "Relevance to HPOs", "Confidence", and "Summary" columns in the variants table. Previously, these were only stored in browser localStorage, which is not persistent, shareable, or version-controllable. ## Changes: ### 1. Server Endpoints (varbook/write/html_server.py): #### Added routes: - `POST /api/save-table-data` - Save table annotations to TSV file - `GET /api/load-table-data` - Load table annotations from TSV file #### Helper methods: - `_get_annotations_file(dataset)` - Get path to annotations file with sanitized filename - `_save_table_annotations(dataset, annotations)` - Save to TSV with backup - `_load_table_annotations(dataset)` - Load from TSV #### Storage format: - Files saved to: `{html_dir}/annotations/{dataset_name}.annotations.tsv` - TSV format with columns: variant_id, relevance, confidence, summary - Creates `.tsv.backup` before each save ### 2. Client-Side JavaScript (varbook/write/html.py): #### Added functions: - `syncTableDataToServer()` - Debounced sync to server (2s delay) - `loadTableDataFromServer()` - Load annotations from server on page load #### Modified functions: - `saveDropdownValue()` - Now calls `syncTableDataToServer()` after localStorage update - `saveSummaryValue()` - Now calls `syncTableDataToServer()` after localStorage update #### Behavior: - **Live mode**: Data synced to server AND localStorage - **Static mode**: Data only saved to localStorage (backwards compatible) - On page load: Fetches from server, updates localStorage, then loads to UI - Debouncing prevents excessive server requests during editing ### 3. Template Updates (varbook/write/html.py): #### Modified `get_javascript()`: - Added `dataset_name` parameter - Template now includes base dataset name for API calls #### Modified `generate_html()`: - Extracts base dataset name using `SubdatasetSpec` - Passes dataset name to JavaScript generation ## Benefits: 1. **Persistent**: Survives browser cache clearing 2. **Shareable**: TSV files can be shared with team 3. **Version controllable**: Files can be tracked in git 4. **Exportable**: TSV format is easy to analyze 5. **Backwards compatible**: Falls back to localStorage if server unavailable ## File Locations: - Annotations: `snakemake/annotations/Broad_neurological_disorders.annotations.tsv` - Backups: `snakemake/annotations/Broad_neurological_disorders.annotations.tsv.backup`