Skip to content

Commit

Permalink
feat(website): Explicitly set dataFormat=fasta for sequence downloa…
Browse files Browse the repository at this point in the history
…ds (#3767)

* foo

* Fix tests
  • Loading branch information
fhennig authored Feb 26, 2025
1 parent 38458a8 commit fae6d9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('DownloadDialog', () => {
[path, query] = getDownloadHref()?.split('?') ?? [];
expect(path).toBe(`${defaultLapisUrl}/sample/unalignedNucleotideSequences`);
expect(query).toMatch(
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&dataUseTerms=OPEN&compression=gzip&accession=accession1&accession=accession2&field1=value1/,
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&dataUseTerms=OPEN&dataFormat=fasta&compression=gzip&accession=accession1&accession=accession2&field1=value1/,
);

await userEvent.click(screen.getByLabelText(/include restricted data/));
Expand All @@ -98,7 +98,7 @@ describe('DownloadDialog', () => {
[path, query] = getDownloadHref()?.split('?') ?? [];
expect(path).toBe(`${defaultLapisUrl}/sample/unalignedNucleotideSequences`);
expect(query).toMatch(
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&compression=zstd&accession=accession1&accession=accession2&field1=value1/,
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&dataFormat=fasta&compression=zstd&accession=accession1&accession=accession2&field1=value1/,
);
});

Expand All @@ -119,7 +119,7 @@ describe('DownloadDialog', () => {
[path, query] = getDownloadHref()?.split('?') ?? [];
expect(path).toBe(`${defaultLapisUrl}/sample/unalignedNucleotideSequences`);
expect(query).toMatch(
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&dataUseTerms=OPEN&compression=gzip&accessionVersion=SEQID1&accessionVersion=SEQID2/,
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&dataUseTerms=OPEN&dataFormat=fasta&compression=gzip&accessionVersion=SEQID1&accessionVersion=SEQID2/,
);

await userEvent.click(screen.getByLabelText(/include restricted data/));
Expand All @@ -128,7 +128,7 @@ describe('DownloadDialog', () => {
[path, query] = getDownloadHref()?.split('?') ?? [];
expect(path).toBe(`${defaultLapisUrl}/sample/unalignedNucleotideSequences`);
expect(query).toMatch(
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&compression=zstd&accessionVersion=SEQID1&accessionVersion=SEQID2/,
/downloadAsFile=true&downloadFileBasename=ebola_nuc_\d{4}-\d{2}-\d{2}T\d{4}&dataFormat=fasta&compression=zstd&accessionVersion=SEQID1&accessionVersion=SEQID2/,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import kebabCase from 'just-kebab-case';

import { getEndpoint, dataTypeForFilename, type DownloadDataType } from './DownloadDataType.ts';
import type { SequenceFilter } from './SequenceFilters.tsx';
import { IS_REVOCATION_FIELD, metadataDefaultDownloadDataFormat, VERSION_STATUS_FIELD } from '../../../settings.ts';
import {
IS_REVOCATION_FIELD,
metadataDefaultDownloadDataFormat,
sequenceDefaultDownloadDataFormat,
VERSION_STATUS_FIELD,
} from '../../../settings.ts';
import { versionStatuses } from '../../../types/lapis.ts';

export type Compression = 'zstd' | 'gzip' | undefined;
Expand Down Expand Up @@ -52,6 +57,8 @@ export class DownloadUrlGenerator {

if (option.dataType.type === 'metadata') {
params.set('dataFormat', metadataDefaultDownloadDataFormat);
} else {
params.set('dataFormat', sequenceDefaultDownloadDataFormat);
}
if (option.compression !== undefined) {
params.set('compression', option.compression);
Expand Down
1 change: 1 addition & 0 deletions website/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export const VERSION_COMMENT_FIELD = 'versionComment';
export const SUBMISSION_ID_FIELD = 'submissionId';

export const metadataDefaultDownloadDataFormat = 'tsv';
export const sequenceDefaultDownloadDataFormat = 'fasta';

export const DEFAULT_LOCALE = 'en-US';

0 comments on commit fae6d9a

Please sign in to comment.