Description
Description
NC-Scorer currently processes variants individually through the UI. Users needing to analyze or score multiple variants (e.g., from a VCF file filter or a candidate list) must manually enter each one, which is time-consuming and inefficient.
Desired Behavior (Revised Plan)
Implement a simple batch processing mode that leverages variant-linker
v2.0.0's batch capabilities. This initial implementation will focus on allowing users to paste a list of variants, processing them in a single batch API call, and providing the results directly as a downloadable file (JSON, CSV, TSV, or VCF), without displaying results in a table initially.
Requirements
- New Route/View:
- Create a dedicated route (e.g.,
/batch
) and corresponding view component (src/views/BatchView.vue
).
- Create a dedicated route (e.g.,
- Input Method:
- Provide a
<v-textarea>
component for users to paste a list of variants (one per line). - Supported input formats per line: VCF-style (
CHR-POS-REF-ALT
) or HGVS notation. - Implement client-side validation to limit input to a maximum number of lines (e.g., 200).
- Provide a
- Output Format Selection:
- Provide a UI element (e.g.,
<v-select>
or<v-radio-group>
) for the user to choose the desired output format: JSON, CSV, TSV, VCF.
- Provide a UI element (e.g.,
- Processing Logic:
- Parse the pasted variants from the textarea, trim whitespace, and filter empty lines.
- Validate the number of variants against the maximum limit (e.g., 200).
- Update the
queryVariant
wrapper insrc/api/variantApi.js
(or createqueryVariantBatch
) to accept an array of variant strings. - The API wrapper must pass the variant array and the user-selected
output
format parameter to the underlyingvariant-linker
analyzeVariant
function. - Handle potential errors during API calls gracefully, displaying an error message to the user.
- Show a loading indicator while processing.
- Output Handling:
- When the
variant-linker
API call succeeds:Expect the response to be a single string for CSV, TSV, or VCF formats, or a JSON object/array for JSON format. - Trigger an automatic file download of the received result string (or stringified JSON).
- Generate an appropriate filename (e.g.,
nc_scorer_batch_results_[timestamp].[format]
). - Set the correct MIME type for the download based on the selected format.
- When the
- No initial requirement to display results in a UI table.
Implementation Plan (High-Level)
- Create Batch View (
src/views/BatchView.vue
):- Set up the basic structure with
ContentContainer
. - Add UI elements:
v-textarea
(for input),v-select
(for output format),v-btn
(to submit),v-alert
(for errors/status). - Implement client-side validation (max lines).
- Set up the basic structure with
- Update API Wrapper (
src/api/variantApi.js
):- Modify
queryVariant
(or createqueryVariantBatch
) to acceptvariants: string[]
and pass theoutput
option. - Ensure it correctly calls
variantLinker.analyzeVariant
with the array and returns the expected result (string or object based on output format).
- Modify
- Implement View Logic (
src/views/BatchView.vue
):- Write the
processAndDownload
function:- Parse/validate input text area.
- Call the updated API wrapper function with the variant array and selected format.
- Handle the promise: trigger download on success, show error on failure.
- Manage loading state.
- Write the
- Add Routing (
src/router/index.js
):- Define the
/batch
route pointing to theBatchView
component (lazy-loaded).
- Define the
- Add Navigation (
src/config/menuConfig.json
):- (Optional) Add a "Batch Analysis" item to the main navigation menu.
Motivation
To provide an initial, efficient way for users to process multiple variants using the underlying capabilities of variant-linker
v2.0.0, focusing on data output rather than immediate display. This addresses the core need for batch processing described in #30 while simplifying the initial implementation. Future iterations can build upon this to add UI display features.