export type V2Fasta = 'FASTA_UNSPECIFIED' | 'FASTA_GENE' | 'FASTA_RNA' | 'FASTA_PROTEIN' | 'FASTA_GENE_FLANK' | 'FASTA_CDS' | 'FASTA_5P_UTR' | 'FASTA_3P_UTR'; export type V2GeneDatasetRequestGeneDatasetReportType = 'DATASET_REPORT' | 'PRODUCT_REPORT'; export type GetApiGeneIdGeneIdsDownloadArgs = {gene_ids: Array, include_annotation_type?: Array | undefined, accession_filter?: Array | undefined, aux_report?: Array | undefined, tabular_reports?: Array | undefined, filename?: string | undefined}; export type GetApiGeneIdGeneIdsDownloadOptions = {baseUrl?: string | undefined, ApiKeyAuthHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get a gene data package by GeneID * * GET /gene/id/{gene_ids}/download */ export const getApiGeneIdGeneIdsDownload = async (args: GetApiGeneIdGeneIdsDownloadArgs, options?: GetApiGeneIdGeneIdsDownloadOptions) => { const {baseUrl = "https://api.ncbi.nlm.nih.gov/datasets/v2", fetch: fetchFn = fetch, ApiKeyAuthHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") for (const item of args.include_annotation_type ?? []) query.append("include_annotation_type", String(item)) for (const item of args.accession_filter ?? []) query.append("accession_filter", String(item)) for (const item of args.aux_report ?? []) query.append("aux_report", String(item)) for (const item of args.tabular_reports ?? []) query.append("tabular_reports", String(item)) if (args.filename != null) query.append("filename", String(args.filename)) if (ApiKeyAuthHeader !== undefined) headers.set("api-key", ApiKeyAuthHeader) const url = `${baseUrl.replace(/\/+$/, '')}/gene/id/${encodeURIComponent(String(args.gene_ids))}/download${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };