feat(website): resistance mutation sets as collections#1181
Conversation
Creates three COVID collections (3CLpro, RdRp, Spike mAb) from the resistance mutation sets defined in resistanceMutations.ts, each with one filterObject variant per individual mutation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…cript When SESSION_TOKEN is set, the script hits the website proxy at /api/collections (which injects the user ID from the session) and passes the auth cookie. Automatically uses the __Secure- cookie prefix for HTTPS targets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of hard-coding mutation lists in the codebase, fetch them at runtime from the backend collections API (one collection per set: 3CLpro, RdRp, Spike). The seed script now uses mature protein names (offset-adjusted) as variant names, so the name calculation is no longer needed in client code. Offset and matureName are removed from the frontend entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
useResistanceMutationSets now returns ResistanceData directly (mutationAnnotations + displayMutationsBySet), removing the intermediate ResistanceMutationSet type and resistanceMutations.ts entirely. The selector/filter chain now takes plain string[] for set names. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The example data seeder on feat/example-data-seeder handles this now. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…errides Add wastewaterOrganismStagingConfigs with staging resistance collection IDs (1/2/3 for 3CLpro/RdRp/Spike). Wasap.astro now selects prod vs staging config and passes it directly to WasapPage, removing the env dependency from React. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tance collections Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
IDs confirmed at https://genspectrum.org/api/collections Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…2, 3) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moves resistance collection fetching from a React Query hook to the Astro SSR layer, so data is available before the page reaches the browser. WasapPage now receives resistanceData as a prop instead of fetching it client-side. Removes useResistanceMutationSets hook; logic lives in resistanceData.ts as a plain async function. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5ca6a5d to
2b50741
Compare
|
Hey Fabian, the resistance stuff is fetched in the astro frontmatter, I think that's better because it's a simple Docker internal call. But I had it before with a React hook, the change is all in this commit: 2b50741 - Both approaches have pros and cons I'd say, we can also revert this commit if the hook approach is better. |
There was a problem hiding this comment.
Pull request overview
Moves W-ASAP resistance mutation sets from hard-coded TypeScript arrays to backend collections, fetching them server-side in Wasap.astro and passing the resolved config + resistance data into the React page to avoid client-side loading.
Changes:
- Replace
resistanceMutationSetswithresistanceMutationCollections(collection IDs + metadata) across config/types/tests. - Add server-side resistance collection fetching/building (
resistanceData.ts) and plumb it throughWasap.astro→WasapPage. - Remove the old hard-coded resistance mutations module and update the resistance filter UI to use set names derived from fetched data.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/views/pageStateHandlers/WasapPageStateHandler.spec.ts | Updates test config to use resistanceMutationCollections. |
| website/src/types/wastewaterConfig.ts | Switches COVID resistance config to collection-based IDs; adds staging config override export. |
| website/src/types/wastewaterConfig.spec.ts | Adjusts config validation test to new property name. |
| website/src/components/views/wasap/wasapPageConfig.ts | Updates WasapPageConfig to use ResistanceMutationCollectionConfig. |
| website/src/components/views/wasap/useWasapPageData.ts | Threads displayMutationsBySet into the query path for resistance mode. |
| website/src/components/views/wasap/resistanceMutations.ts | Deletes hard-coded resistance mutation sets + conversion helper. |
| website/src/components/views/wasap/resistanceData.ts | Adds SSR fetch + transformation from collections to mutation annotations + display mutations. |
| website/src/components/views/wasap/WasapPage.tsx | Accepts SSR-provided config + resistanceData, wiring them into gs-app + filters. |
| website/src/components/views/wasap/Wasap.astro | Resolves prod vs staging config and fetches resistance collections server-side. |
| website/src/components/pageStateSelectors/wasap/filters/ResistanceMutationsFilter.tsx | Switches selector inputs from full sets to set-name list. |
| website/src/components/pageStateSelectors/wasap/filters/ResistanceMutationsFilter.browser.spec.tsx | Updates browser test to pass set names instead of mutation sets. |
| website/src/components/pageStateSelectors/wasap/WasapPageStateSelector.tsx | Wires resistanceSetNames through to the resistance filter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| <WasapPageStateSelector | ||
| config={config} | ||
| pageStateHandler={pageStateHandler} | ||
| initialBaseFilterState={base} | ||
| initialAnalysisFilterState={analysis} | ||
| setPageState={setPageState} | ||
| resistanceSetNames={Object.keys(displayMutationsBySet)} | ||
| /> |
| } catch (error) { | ||
| getInstanceLogger('WasapPage').error( | ||
| `Failed to fetch resistance data for WASAP page (organism: ${wastewaterOrganism}): ${error}`, | ||
| ); |
| function withResistanceCollectionOverrides(config: WasapPageConfig): WasapPageConfig { | ||
| if (!config.resistanceAnalysisModeEnabled) return config; | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| const stagingIds: Record<string, number> = { '3CLpro': 1, 'RdRp': 2, 'Spike': 3 }; | ||
| return { | ||
| ...config, | ||
| resistanceMutationCollections: config.resistanceMutationCollections.map((set) => ({ | ||
| ...set, | ||
| collectionId: stagingIds[set.name] ?? set.collectionId, | ||
| })), | ||
| }; |
| type: 'mutations', | ||
| displayMutations: | ||
| config.resistanceMutationSets.find((set) => set.name === analysis.resistanceSet)?.mutations ?? [], | ||
| displayMutations: displayMutationsBySet[analysis.resistanceSet ?? ''] ?? [], |
There was a problem hiding this comment.
Can analysis.resistanceSet ever be undefined?
There was a problem hiding this comment.
Let's maybe add a simple unit test to test the mapping here?
| type Props = { | ||
| wastewaterOrganism: WastewaterOrganismName; | ||
| }; | ||
|
|
||
| const { wastewaterOrganism } = Astro.props; | ||
| const { name } = wastewaterOrganismConfigs[wastewaterOrganism]; | ||
| const config = (isStaging() ? wastewaterOrganismStagingConfigs : wastewaterOrganismConfigs)[wastewaterOrganism]; | ||
| const backendService = new BackendService(getBackendHost()); | ||
| let resistanceData: ResistanceData = { mutationAnnotations: [], displayMutationsBySet: {} }; | ||
|
|
||
| try { | ||
| resistanceData = await fetchResistanceData(config, backendService); | ||
| } catch (error) { |
There was a problem hiding this comment.
AI: If fetchResistanceData fails, the page renders with empty resistance data — the resistance mode dropdown will show zero options, but the user can still select the "resistance" tab and see an empty dropdown. Should we show some kind of user-facing warning in this case, or hide the resistance mode tab entirely when the data is unavailable?
Summary
Wasap.astro(SSR) and passed as a prop toWasapPage, so no client-side fetch or loading state is needed for resistance dataWasap.astro, picking prod vs staging collection IDs — staging overrides live inwastewaterOrganismStagingConfigsresistanceData.tscontains the plain async fetch logic;useResistanceMutationSetshook deletedScreenshot
n/a
PR Checklist
All necessary documentation has been adapted.The implemented feature is covered by an appropriate test.