Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fetch sidecar Auspice JSON if .root_sequence is not on the tree #1460

Merged
merged 7 commits into from
May 30, 2024
13 changes: 12 additions & 1 deletion packages/nextclade-web/src/io/fetchSingleDatasetAuspice.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { isEmpty } from 'lodash'
import { attrStrMaybe, AuspiceTree, Dataset } from 'src/types'
import { removeTrailingSlash } from 'src/io/url'
import { axiosFetch } from 'src/io/axiosFetch'
import { axiosFetch, axiosFetchOrUndefined } from 'src/io/axiosFetch'

export async function fetchSingleDatasetAuspice(datasetJsonUrl_: string) {
const datasetJsonUrl = removeTrailingSlash(datasetJsonUrl_)

const auspiceJson = await axiosFetch<AuspiceTree>(datasetJsonUrl, {
headers: { Accept: 'application/json, text/plain, */*' },
ivan-aksamentov marked this conversation as resolved.
Show resolved Hide resolved
})

if (isEmpty(auspiceJson.root_sequence)) {
const sidecar = await axiosFetchOrUndefined<Record<string, string>>(datasetJsonUrl, {
headers: { Accept: 'application/vnd.nextstrain.dataset.root-sequence+json' },
ivan-aksamentov marked this conversation as resolved.
Show resolved Hide resolved
})
if (!isEmpty(sidecar)) {
auspiceJson.root_sequence = sidecar
}
}
ivan-aksamentov marked this conversation as resolved.
Show resolved Hide resolved

const pathogen = auspiceJson.meta.extensions?.nextclade?.pathogen

const name =
Expand Down
Loading