Skip to content

Commit

Permalink
feat(website): add CCHF dashboard
Browse files Browse the repository at this point in the history
resolves #528
  • Loading branch information
fengelniederhammer committed Feb 11, 2025
1 parent 4f022b4 commit ed9f206
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 1 deletion.
23 changes: 23 additions & 0 deletions backend/src/main/resources/application-dashboards-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,29 @@ dashboards:
- url: "https://pathoplexus.org/ebola-zaire"
label: "Browse data"
menuIcon: "database"
cchf:
lapis:
url: "https://lapis.pathoplexus.org/cchf"
mainDateField: "sampleCollectionDateRangeLower"
locationFields:
- "geoLocCountry"
- "geoLocAdmin1"
hostField: "hostNameScientific"
authorAffiliationsField: "authorAffiliations"
authorsField: "authors"
additionalFilters:
versionStatus: "LATEST_VERSION"
isRevocation: "false"
accessionDownloadFields:
- "insdcAccessionFull"
- "accessionVersion"
- "dataUseTerms"
- "dataUseTermsUrl"
- "dataUseTermsRestrictedUntil"
externalNavigationLinks:
- url: "https://pathoplexus.org/cchf"
label: "Browse data"
menuIcon: "database"
auth:
github:
clientId: "Iv23liLcTmoYOEje50sW"
23 changes: 23 additions & 0 deletions backend/src/main/resources/application-dashboards-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,29 @@ dashboards:
- url: "https://pathoplexus.org/ebola-zaire"
label: "Browse data"
menuIcon: "database"
cchf:
lapis:
url: "https://lapis.pathoplexus.org/cchf"
mainDateField: "sampleCollectionDateRangeLower"
locationFields:
- "geoLocCountry"
- "geoLocAdmin1"
hostField: "hostNameScientific"
authorAffiliationsField: "authorAffiliations"
authorsField: "authors"
additionalFilters:
versionStatus: "LATEST_VERSION"
isRevocation: "false"
accessionDownloadFields:
- "insdcAccessionFull"
- "accessionVersion"
- "dataUseTerms"
- "dataUseTermsUrl"
- "dataUseTermsRestrictedUntil"
externalNavigationLinks:
- url: "https://pathoplexus.org/cchf"
label: "Browse data"
menuIcon: "database"
auth:
github:
clientId: "Iv23li4tJm7xQ3VkM3OC"
6 changes: 6 additions & 0 deletions website/src/pages/cchf/compare-side-by-side.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
import GenericCompareSideBySidePage from '../../components/views/compareSideBySide/GenericCompareSideBySidePage.astro';
import { Organisms } from '../../types/Organism';
---

<GenericCompareSideBySidePage organism={Organisms.cchf} />
6 changes: 6 additions & 0 deletions website/src/pages/cchf/compare-to-baseline.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
import GenericCompareToBaselinePage from '../../components/views/compareToBaseline/GenericCompareToBaselinePage.astro';
import { Organisms } from '../../types/Organism';
---

<GenericCompareToBaselinePage organism={Organisms.cchf} />
6 changes: 6 additions & 0 deletions website/src/pages/cchf/compare-variants.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
import GenericCompareVariantsPage from '../../components/views/compareVariants/GenericCompareVariantsPage.astro';
import { Organisms } from '../../types/Organism';
---

<GenericCompareVariantsPage organism={Organisms.cchf} />
11 changes: 11 additions & 0 deletions website/src/pages/cchf/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
import { Organisms } from '../../types/Organism';
import { ServerSide } from '../../views/serverSideRouting';
import { singleVariantViewKey } from '../../views/viewKeys';
return Astro.redirect(
ServerSide.routing
.getOrganismView(`${Organisms.cchf}.${singleVariantViewKey}`)
.pageStateHandler.getDefaultPageUrl(),
);
---
6 changes: 6 additions & 0 deletions website/src/pages/cchf/sequencing-efforts.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
import GenericSequencingEffortsPage from '../../components/views/sequencingEfforts/GenericSequencingEffortsPage.astro';
import { Organisms } from '../../types/Organism';
---

<GenericSequencingEffortsPage organism={Organisms.cchf} />
6 changes: 6 additions & 0 deletions website/src/pages/cchf/single-variant.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
import GenericAnalyzeSingleVariantPage from '../../components/views/analyzeSingleVariant/GenericAnalyzeSingleVariantPage.astro';
import { Organisms } from '../../types/Organism';
---

<GenericAnalyzeSingleVariantPage organism={Organisms.cchf} />
10 changes: 10 additions & 0 deletions website/src/types/Organism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const Organisms = {
rsvB: 'rsvB' as const,
mpox: 'mpox' as const,
ebolaZaire: 'ebolaZaire' as const,
cchf: 'cchf' as const,
};

export const organismConfig = {
Expand Down Expand Up @@ -84,6 +85,15 @@ export const organismConfig = {
menuListEntryDecoration: 'hover:decoration-wine',
borderEntryDecoration: 'hover:border-wine',
},
[Organisms.cchf]: {
organism: Organisms.cchf,
pathFragment: 'cchf',
label: 'Crimean-Congo Hemorrhagic Fever Virus',
backgroundColor: 'bg-oliveMuted',
backgroundColorFocus: 'group-hover:bg-olive',
menuListEntryDecoration: 'hover:decoration-olive',
borderEntryDecoration: 'hover:border-olive',
},
};
export const allOrganisms = Object.keys(organismConfig) as Organism[];
export type Organism = keyof typeof organismConfig;
Expand Down
135 changes: 135 additions & 0 deletions website/src/views/cchf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { type DateRangeOption, dateRangeOptionPresets } from '@genspectrum/dashboard-components/util';

import { type CompareSideBySideData, type DatasetAndVariantData, type Id } from './View.ts';
import { type OrganismsConfig } from '../config.ts';
import {
BaseView,
GenericCompareToBaselineView,
GenericCompareVariantsView,
GenericSequencingEffortsView,
GenericSingleVariantView,
} from './BaseView.ts';
import { getPathoplexusAdditionalSequencingEffortsFields, type ExtendedConstants } from './OrganismConstants.ts';
import { compareSideBySideViewConstants } from './ViewConstants.ts';
import type { LineageFilterConfig } from '../components/pageStateSelectors/LineageFilterInput.tsx';
import { organismConfig, Organisms } from '../types/Organism.ts';
import { type DataOrigin, dataOrigins } from '../types/dataOrigins.ts';
import { GenericCompareSideBySideStateHandler } from './pageStateHandlers/CompareSideBySidePageStateHandler.ts';

class CchfConstants implements ExtendedConstants {
public readonly organism = Organisms.cchf;
public readonly earliestDate = '1956-01-01';
public readonly defaultDateRange = dateRangeOptionPresets.lastYear;
public readonly dateRangeOptions: DateRangeOption[] = [
dateRangeOptionPresets.lastMonth,
dateRangeOptionPresets.last2Months,
dateRangeOptionPresets.last3Months,
dateRangeOptionPresets.last6Months,
dateRangeOptionPresets.lastYear,
{ label: 'Since 2020', dateFrom: '2020-01-01' },
{ label: '2010-2019', dateFrom: '2010-01-01', dateTo: '2019-12-31' },
{ label: '2000-2009', dateFrom: '2000-01-01', dateTo: '2009-12-31' },
{ label: 'Since 2000', dateFrom: '2000-01-01' },
{ label: 'Before 2000', dateFrom: this.earliestDate, dateTo: '1999-12-31' },
{ label: 'All times', dateFrom: this.earliestDate },
];
public readonly mainDateField: string;
public readonly locationFields: string[];
public readonly lineageFilters: LineageFilterConfig[] = [];
public readonly useAdvancedQuery = false;
public readonly hostField: string;
public readonly authorsField: string | undefined;
public readonly authorAffiliationsField: string | undefined;
public readonly accessionDownloadFields;

public get additionalSequencingEffortsFields() {
return getPathoplexusAdditionalSequencingEffortsFields(this);
}

public readonly additionalFilters: Record<string, string> | undefined;
public readonly dataOrigins: DataOrigin[] = [dataOrigins.pathoplexus];

constructor(organismsConfig: OrganismsConfig) {
this.mainDateField = organismsConfig.cchf.lapis.mainDateField;
this.locationFields = organismsConfig.cchf.lapis.locationFields;
this.hostField = organismsConfig.cchf.lapis.hostField;
this.authorsField = organismsConfig.cchf.lapis.authorsField;
this.authorAffiliationsField = organismsConfig.cchf.lapis.authorAffiliationsField;
this.additionalFilters = organismsConfig.cchf.lapis.additionalFilters;
this.accessionDownloadFields = organismsConfig.cchf.lapis.accessionDownloadFields;
}
}

export class CchfAnalyzeSingleVariantView extends GenericSingleVariantView<CchfConstants> {
constructor(organismsConfig: OrganismsConfig) {
super(new CchfConstants(organismsConfig));
}
}

export class CchfCompareSideBySideView extends BaseView<
CompareSideBySideData,
CchfConstants,
GenericCompareSideBySideStateHandler
> {
constructor(organismsConfig: OrganismsConfig) {
const constants = new CchfConstants(organismsConfig);
const defaultPageState = {
filters: new Map<Id, DatasetAndVariantData>([
[
0,
{
datasetFilter: {
location: {},
dateRange: constants.defaultDateRange,
},
variantFilter: {
lineages: {},
mutations: {},
},
},
],
[
1,
{
datasetFilter: {
location: {},
dateRange: constants.defaultDateRange,
},
variantFilter: {
lineages: {},
mutations: {},
},
},
],
]),
};

super(
constants,
new GenericCompareSideBySideStateHandler(
constants,
defaultPageState,
organismConfig[constants.organism].pathFragment,
),
compareSideBySideViewConstants,
);
}
}

export class CchfSequencingEffortsView extends GenericSequencingEffortsView<CchfConstants> {
constructor(organismsConfig: OrganismsConfig) {
super(new CchfConstants(organismsConfig));
}
}

export class CchfCompareVariantsView extends GenericCompareVariantsView<CchfConstants> {
constructor(organismsConfig: OrganismsConfig) {
super(new CchfConstants(organismsConfig));
}
}

export class CchfCompareToBaselineView extends GenericCompareToBaselineView<CchfConstants> {
constructor(organismsConfig: OrganismsConfig) {
super(new CchfConstants(organismsConfig));
}
}
16 changes: 16 additions & 0 deletions website/src/views/routing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import type { OrganismConstants } from './OrganismConstants.ts';
import type { View } from './View.ts';
import {
CchfAnalyzeSingleVariantView,
CchfCompareSideBySideView,
CchfCompareToBaselineView,
CchfCompareVariantsView,
CchfSequencingEffortsView,
} from './cchf.ts';
import {
CovidAnalyzeSingleVariantView,
CovidCompareSideBySideView,
Expand Down Expand Up @@ -136,6 +143,13 @@ export class Routing {
[compareVariantsViewKey]: new EbolaZaireCompareVariantsView(organismsConfig),
[compareToBaselineViewKey]: new EbolaZaireCompareToBaselineView(organismsConfig),
},
[Organisms.cchf]: {
[singleVariantViewKey]: new CchfAnalyzeSingleVariantView(organismsConfig),
[compareSideBySideViewKey]: new CchfCompareSideBySideView(organismsConfig),
[sequencingEffortsViewKey]: new CchfSequencingEffortsView(organismsConfig),
[compareVariantsViewKey]: new CchfCompareVariantsView(organismsConfig),
[compareToBaselineViewKey]: new CchfCompareToBaselineView(organismsConfig),
},
} as const;

this.externalPages = this.initializeExternalPages(organismsConfig);
Expand All @@ -159,6 +173,8 @@ export class Routing {
return Object.values(this.views[Organisms.mpox]);
case Organisms.ebolaZaire:
return Object.values(this.views[Organisms.ebolaZaire]);
case Organisms.cchf:
return Object.values(this.views[Organisms.cchf]);
}
}

Expand Down
1 change: 1 addition & 0 deletions website/tests/compareVariants.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const organismOptions = {
[Organisms.rsvB]: { lineage: 'B.D.E.1', lineageFieldPlaceholder: 'Lineage' },
[Organisms.mpox]: { lineage: 'F.1', lineageFieldPlaceholder: 'Lineage' },
[Organisms.ebolaZaire]: { mutation: 'T18365C' },
[Organisms.cchf]: { mutation: 'M:G3565A' },
};

test.describe('The Compare Variants page', () => {
Expand Down
3 changes: 2 additions & 1 deletion website/tests/sequencingEfforts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const organismOptions = {
[Organisms.rsvB]: { location: 'USA' },
[Organisms.mpox]: { location: 'USA' },
[Organisms.ebolaZaire]: { location: 'USA' },
[Organisms.cchf]: { location: 'Turkey' },
};

test.describe('The Sequencing Efforts Page', () => {
Expand All @@ -24,8 +25,8 @@ test.describe('The Sequencing Efforts Page', () => {

await sequencingEffortsPage.goto(organism);
await sequencingEffortsPage.expectToSeeNoComponentErrors();
await sequencingEffortsPage.selectLocation(options.location);
await sequencingEffortsPage.selectDateRange('All times');
await sequencingEffortsPage.selectLocation(options.location);
await sequencingEffortsPage.submitFilters();

await expect(sequencingEffortsPage.diagramTitle('Number Sequences')).toBeVisible();
Expand Down

0 comments on commit ed9f206

Please sign in to comment.