jbrowse-plugin-msaview 2.7.3 → 2.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/LaunchMsaView/components/LaunchMsaViewDialog.js +7 -1
  2. package/dist/LaunchMsaView/components/OrthologQuery/OrthologPanel.d.ts +8 -0
  3. package/dist/LaunchMsaView/components/OrthologQuery/OrthologPanel.js +86 -0
  4. package/dist/LaunchMsaView/components/OrthologQuery/orthologLaunchView.d.ts +9 -0
  5. package/dist/LaunchMsaView/components/OrthologQuery/orthologLaunchView.js +13 -0
  6. package/dist/MsaViewPanel/afterCreateAutoruns.d.ts +8 -0
  7. package/dist/MsaViewPanel/afterCreateAutoruns.js +28 -0
  8. package/dist/MsaViewPanel/doLaunchOrthologs.d.ts +23 -0
  9. package/dist/MsaViewPanel/doLaunchOrthologs.js +97 -0
  10. package/dist/MsaViewPanel/model.d.ts +21 -5
  11. package/dist/MsaViewPanel/model.js +12 -1
  12. package/dist/jbrowse-plugin-msaview.umd.production.min.js +31 -27
  13. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
  14. package/dist/utils/ncbiOrthologs.d.ts +105 -0
  15. package/dist/utils/ncbiOrthologs.js +211 -0
  16. package/dist/utils/ncbiOrthologs.test.d.ts +1 -0
  17. package/dist/utils/ncbiOrthologs.test.js +41 -0
  18. package/dist/version.d.ts +1 -1
  19. package/dist/version.js +1 -1
  20. package/package.json +3 -3
  21. package/src/LaunchMsaView/components/LaunchMsaViewDialog.tsx +13 -2
  22. package/src/LaunchMsaView/components/OrthologQuery/OrthologPanel.tsx +172 -0
  23. package/src/LaunchMsaView/components/OrthologQuery/orthologLaunchView.ts +28 -0
  24. package/src/MsaViewPanel/afterCreateAutoruns.ts +27 -0
  25. package/src/MsaViewPanel/doLaunchOrthologs.ts +123 -0
  26. package/src/MsaViewPanel/model.ts +24 -0
  27. package/src/utils/ncbiOrthologs.test.ts +56 -0
  28. package/src/utils/ncbiOrthologs.ts +320 -0
  29. package/src/version.ts +1 -1
@@ -0,0 +1,123 @@
1
+ import { cleanProteinSequence } from '../LaunchMsaView/util'
2
+ import { launchMSA } from '../utils/msa'
3
+ import {
4
+ fetchOrthologRows,
5
+ fetchProteinForGene,
6
+ resolveGeneId,
7
+ } from '../utils/ncbiOrthologs'
8
+
9
+ import type { JBrowsePluginMsaViewModel } from './model'
10
+ import type { OrthologRow } from '../utils/ncbiOrthologs'
11
+
12
+ /**
13
+ * The no-search-job alternative to doLaunchBlast.
14
+ *
15
+ * BLAST spends 10+ minutes answering "what looks like this sequence" and
16
+ * returns a redundant, accession-labelled hit list. This asks NCBI the question
17
+ * the alignment actually wants — "what is this gene's ortholog in each species"
18
+ * — which NCBI has already computed, so the whole NCBI half returns in about a
19
+ * second and only the EBI alignment (~10s) costs real time.
20
+ *
21
+ * The query row is the user's OWN selected transcript, not NCBI's
22
+ * representative protein for the query species, because `connectedFeature`
23
+ * maps genome coordinates through that row — swapping in a different isoform
24
+ * would silently break the genome<->MSA linkage. The query species is therefore
25
+ * excluded from the ortholog set rather than appearing twice.
26
+ */
27
+ export async function doLaunchOrthologs({
28
+ self,
29
+ }: {
30
+ self: JBrowsePluginMsaViewModel
31
+ }) {
32
+ const { taxId, taxa, geneCandidates, msaAlgorithm, proteinSequence } =
33
+ self.orthologParams!
34
+ const cleanedSeq = cleanProteinSequence(proteinSequence)
35
+
36
+ const onProgress = (arg: string) => {
37
+ self.setProgress(arg)
38
+ }
39
+
40
+ onProgress('Resolving gene at NCBI...')
41
+ const resolved = await resolveGeneId(geneCandidates, taxId)
42
+ if (!resolved) {
43
+ throw new Error(
44
+ `Could not resolve any of ${geneCandidates.join(', ')} to an NCBI gene in taxon ${taxId}. Try the NCBI BLAST tab, which needs no gene identifier.`,
45
+ )
46
+ }
47
+
48
+ // the query species is represented by the user's own transcript below
49
+ const wanted = new Set(taxa.filter(t => t !== taxId))
50
+ const rows = await fetchOrthologRows({
51
+ geneId: resolved.geneId,
52
+ taxa: wanted,
53
+ onProgress,
54
+ })
55
+
56
+ const treeMetadata: Record<string, Record<string, string>> = {
57
+ QUERY: await buildQueryMetadata(self, resolved.geneId, cleanedSeq),
58
+ }
59
+ for (const row of rows) {
60
+ treeMetadata[row.label] = buildRowMetadata(row)
61
+ }
62
+
63
+ const result = await launchMSA({
64
+ algorithm: msaAlgorithm,
65
+ sequence: [
66
+ `>QUERY\n${cleanedSeq}`,
67
+ ...rows.map(r => `>${r.label}\n${r.sequence}`),
68
+ ].join('\n'),
69
+ onProgress,
70
+ })
71
+
72
+ return {
73
+ ...result,
74
+ treeMetadata: JSON.stringify(treeMetadata),
75
+ }
76
+ }
77
+
78
+ /**
79
+ * The query row is the user's own translated transcript, so it carries an
80
+ * Accession — which is what drives the automatic CDD overlay
81
+ * (afterCreateAutoruns.autoLoadProteinDomains -> loadProteinDomains) — ONLY
82
+ * when its sequence is byte-identical to the RefSeq protein that accession
83
+ * names. Attaching it unconditionally would put every domain box at an offset
84
+ * whenever the user picked a non-representative isoform, which is a silently
85
+ * wrong figure rather than a missing one.
86
+ */
87
+ async function buildQueryMetadata(
88
+ self: JBrowsePluginMsaViewModel,
89
+ geneId: string,
90
+ proteinSequence: string,
91
+ ): Promise<Record<string, string>> {
92
+ const transcript = self.orthologParams?.selectedTranscript
93
+ const metadata: Record<string, string> = { 'Gene ID': geneId }
94
+ const name = transcript?.get('name') ?? transcript?.get('id')
95
+ if (name) {
96
+ metadata.Transcript = name
97
+ }
98
+ try {
99
+ const representative = await fetchProteinForGene(geneId)
100
+ if (representative?.sequence === proteinSequence) {
101
+ metadata.Accession = representative.accession
102
+ }
103
+ } catch (e) {
104
+ // a failed lookup only costs the query row its domain overlay, so it must
105
+ // not take down an alignment that is otherwise complete
106
+ console.warn('[msaview-orthologs] query protein lookup failed:', e)
107
+ }
108
+ return metadata
109
+ }
110
+
111
+ function buildRowMetadata(row: OrthologRow): Record<string, string> {
112
+ const metadata: Record<string, string> = {
113
+ 'Scientific name': row.scientificName,
114
+ // Accession drives the automatic CDD domain overlay
115
+ // (afterCreateAutoruns.autoLoadProteinDomains -> loadProteinDomains)
116
+ Accession: row.protein,
117
+ 'Gene ID': row.geneId,
118
+ }
119
+ if (row.commonName) {
120
+ metadata['Common name'] = row.commonName
121
+ }
122
+ return metadata
123
+ }
@@ -12,6 +12,7 @@ export type { MSAFormat } from 'msa-parsers'
12
12
  import {
13
13
  autoLoadProteinDomains,
14
14
  launchBlastIfNeeded,
15
+ launchOrthologsIfNeeded,
15
16
  loadStoredData,
16
17
  observeProteinHighlights,
17
18
  processInit,
@@ -54,6 +55,18 @@ export interface BlastParams {
54
55
  rid?: string
55
56
  }
56
57
 
58
+ export interface OrthologParams {
59
+ /** NCBI taxon id of the assembly the query gene came from */
60
+ taxId: number
61
+ /** taxon ids to include as rows (the query taxon is represented by QUERY) */
62
+ taxa: number[]
63
+ /** candidate gene identifiers off the feature, tried in order */
64
+ geneCandidates: string[]
65
+ msaAlgorithm: MsaAlgorithm
66
+ selectedTranscript?: Feature
67
+ proteinSequence: string
68
+ }
69
+
57
70
  /**
58
71
  * #stateModel MsaViewPlugin
59
72
  * extends
@@ -77,6 +90,10 @@ export default function stateModelFactory() {
77
90
  * #property
78
91
  */
79
92
  blastParams: types.frozen<BlastParams | undefined>(),
93
+ /**
94
+ * #property
95
+ */
96
+ orthologParams: types.frozen<OrthologParams | undefined>(),
80
97
  /**
81
98
  * #property
82
99
  */
@@ -256,6 +273,12 @@ export default function stateModelFactory() {
256
273
  setBlastParams(args?: BlastParams) {
257
274
  self.blastParams = args
258
275
  },
276
+ /**
277
+ * #action
278
+ */
279
+ setOrthologParams(args?: OrthologParams) {
280
+ self.orthologParams = args
281
+ },
259
282
  /**
260
283
  * #action
261
284
  */
@@ -366,6 +389,7 @@ export default function stateModelFactory() {
366
389
  loadStoredData,
367
390
  storeDataToIndexedDB,
368
391
  launchBlastIfNeeded,
392
+ launchOrthologsIfNeeded,
369
393
  processInit,
370
394
  autoLoadProteinDomains,
371
395
  ]) {
@@ -0,0 +1,56 @@
1
+ import { describe, expect, test } from 'vitest'
2
+
3
+ import { dedupeLabels, parseFasta } from './ncbiOrthologs'
4
+
5
+ describe('dedupeLabels', () => {
6
+ test('sanitizes to single tokens', () => {
7
+ // labels are used identically as FASTA headers, Newick leaf names and GFF
8
+ // seq_ids, so anything that would need quoting in one of those is stripped
9
+ expect(dedupeLabels(['house mouse', 'Norway rat'])).toEqual([
10
+ 'house_mouse',
11
+ 'Norway_rat',
12
+ ])
13
+ expect(dedupeLabels(['Frog (X. tropicalis)'])).toEqual([
14
+ 'Frog_X_tropicalis',
15
+ ])
16
+ })
17
+
18
+ test('suffixes collisions rather than overwriting a row', () => {
19
+ expect(dedupeLabels(['a b', 'a-b', 'a_b'])).toEqual([
20
+ 'a_b',
21
+ 'a_b_2',
22
+ 'a_b_3',
23
+ ])
24
+ })
25
+
26
+ test('falls back for a name with no usable characters', () => {
27
+ expect(dedupeLabels(['...', '...'])).toEqual(['row', 'row_2'])
28
+ })
29
+ })
30
+
31
+ describe('parseFasta', () => {
32
+ test('keys by the first header token and joins wrapped lines', () => {
33
+ const map = parseFasta(
34
+ ['>NP_000537.3 cellular tumor antigen p53', 'MEEP', 'QSDP', ''].join(
35
+ '\n',
36
+ ),
37
+ )
38
+ expect(map.get('NP_000537.3')).toBe('MEEPQSDP')
39
+ })
40
+
41
+ test('reads every record of a multi-FASTA', () => {
42
+ const map = parseFasta(
43
+ ['>A one', 'MMM', '>B two', 'KKK', '>C three', 'LLL'].join('\n'),
44
+ )
45
+ expect([...map.keys()]).toEqual(['A', 'B', 'C'])
46
+ expect(map.get('C')).toBe('LLL')
47
+ })
48
+
49
+ test('returns nothing for a response that carried no records', () => {
50
+ // efetch answers an unknown accession with an error body, not a 4xx, so a
51
+ // caller that assumed "text back = sequences" would build empty rows
52
+ expect(parseFasta('Error: CEFetchPApplication::proxy_stream()').size).toBe(
53
+ 0,
54
+ )
55
+ })
56
+ })
@@ -0,0 +1,320 @@
1
+ // Homolog discovery WITHOUT a search job.
2
+ //
3
+ // The BLAST path answers "what looks like this sequence", which is not the
4
+ // question an MSA row set wants — it wants "what is homologous to this gene,
5
+ // one per species, labelled by species". BLAST then costs 10+ minutes to
6
+ // return a redundant, accession-labelled hit list that has to be deduplicated
7
+ // before it reads. NCBI has already computed the answer: the Datasets
8
+ // orthologs endpoint returns one ortholog gene per species, instantly.
9
+ //
10
+ // gene symbol -> gene id -> orthologs -> a representative protein each ->
11
+ // sequences, all from NCBI, in a handful of requests. The caller aligns them
12
+ // (EBI Clustal Omega, ~10s) and overlays CDD domains, which are already baked
13
+ // into the GenPept records (see ncbiDomains.ts).
14
+ //
15
+ // Mirrors jb2hubs' website/src/components/proteinMsa.ts assembler, trimmed to
16
+ // what the launch dialog needs and using this plugin's fetch/eutils helpers.
17
+
18
+ import { NCBI_EMAIL, NCBI_TOOL } from './eutils'
19
+ import { jsonfetch, textfetch } from './fetch'
20
+
21
+ // v2, not v2alpha: the alpha path still answers /orthologs but 404s
22
+ // /product_report, so an assembler pointed at it silently resolves zero
23
+ // representative proteins and reports "no orthologs" for every gene.
24
+ const DATASETS = 'https://api.ncbi.nlm.nih.gov/datasets/v2'
25
+ const EUTILS = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils'
26
+
27
+ // The species panel offered in the launch dialog, ordered from the reference
28
+ // outward so a run that finds only close relatives still reads as a ladder.
29
+ // Orthologs absent for a given gene are skipped rather than erroring.
30
+ export const COMMON_SPECIES = [
31
+ { label: 'Human', taxId: 9606 },
32
+ { label: 'Mouse', taxId: 10090 },
33
+ { label: 'Rat', taxId: 10116 },
34
+ { label: 'Cow', taxId: 9913 },
35
+ { label: 'Pig', taxId: 9823 },
36
+ { label: 'Dog', taxId: 9615 },
37
+ { label: 'Chicken', taxId: 9031 },
38
+ { label: 'Frog', taxId: 8364 },
39
+ { label: 'Zebrafish', taxId: 7955 },
40
+ { label: 'Fruitfly', taxId: 7227 },
41
+ { label: 'C. elegans', taxId: 6239 },
42
+ { label: 'Yeast', taxId: 4932 },
43
+ { label: 'Arabidopsis', taxId: 3702 },
44
+ ] as const
45
+
46
+ export const COMMON_TAX_RANK = new Map(
47
+ COMMON_SPECIES.map((s, i) => [s.taxId as number, i]),
48
+ )
49
+
50
+ export interface OrthologRow {
51
+ taxId: number
52
+ /** single-token id used identically in the FASTA, the tree and the domain GFF */
53
+ label: string
54
+ scientificName: string
55
+ commonName?: string
56
+ geneId: string
57
+ /** accession.version */
58
+ protein: string
59
+ sequence: string
60
+ }
61
+
62
+ function ncbiUrl(url: string) {
63
+ const sep = url.includes('?') ? '&' : '?'
64
+ return `${url}${sep}tool=${NCBI_TOOL}&email=${encodeURIComponent(NCBI_EMAIL)}`
65
+ }
66
+
67
+ /**
68
+ * A free-text gene reference -> NCBI gene id. A bare number is taken as the id
69
+ * itself; anything else is searched as a gene name within the query taxon.
70
+ * Several candidate identifiers are tried in order, because a JBrowse feature
71
+ * carries whatever its GFF/BigBed had — `id()`, `name`, `gene_name` — and only
72
+ * some of those are real symbols.
73
+ */
74
+ export async function resolveGeneId(
75
+ candidates: string[],
76
+ taxId: number,
77
+ ): Promise<{ geneId: string; matched: string } | undefined> {
78
+ for (const raw of candidates) {
79
+ const query = raw.trim()
80
+ if (!query) {
81
+ continue
82
+ }
83
+ if (/^\d+$/.test(query)) {
84
+ return { geneId: query, matched: query }
85
+ }
86
+ // strip a version suffix (NM_000546.6) and any GFF ID prefix (gene:TP53)
87
+ const cleaned = query.replace(/^\w+:/, '').replace(/\.\d+$/, '')
88
+ const term = `${cleaned}[Gene Name] AND ${taxId}[taxid]`
89
+ const json = await jsonfetch<{
90
+ esearchresult?: { idlist?: string[] }
91
+ }>(
92
+ ncbiUrl(
93
+ `${EUTILS}/esearch.fcgi?db=gene&term=${encodeURIComponent(term)}&retmode=json&retmax=1`,
94
+ ),
95
+ )
96
+ const geneId = json.esearchresult?.idlist?.[0]
97
+ if (geneId) {
98
+ return { geneId, matched: cleaned }
99
+ }
100
+ }
101
+ return undefined
102
+ }
103
+
104
+ interface OrthologReport {
105
+ reports?: {
106
+ gene?: {
107
+ gene_id?: string
108
+ tax_id?: string | number
109
+ taxname?: string
110
+ common_name?: string
111
+ }
112
+ }[]
113
+ }
114
+
115
+ /** One ortholog gene per species, restricted to the requested taxa. */
116
+ export async function fetchOrthologGenes(geneId: string, taxa: Set<number>) {
117
+ const json = await jsonfetch<OrthologReport>(
118
+ ncbiUrl(
119
+ `${DATASETS}/gene/id/${geneId}/orthologs?returned_content=COMPLETE`,
120
+ ),
121
+ )
122
+ const byTaxon = new Map<
123
+ number,
124
+ {
125
+ taxId: number
126
+ geneId: string
127
+ scientificName: string
128
+ commonName?: string
129
+ }
130
+ >()
131
+ for (const { gene } of json.reports ?? []) {
132
+ const taxId = Number(gene?.tax_id)
133
+ if (gene?.gene_id && taxa.has(taxId) && !byTaxon.has(taxId)) {
134
+ byTaxon.set(taxId, {
135
+ taxId,
136
+ geneId: gene.gene_id,
137
+ scientificName: gene.taxname ?? String(taxId),
138
+ commonName: gene.common_name,
139
+ })
140
+ }
141
+ }
142
+ return [...byTaxon.values()].sort(
143
+ (a, b) =>
144
+ (COMMON_TAX_RANK.get(a.taxId) ?? Infinity) -
145
+ (COMMON_TAX_RANK.get(b.taxId) ?? Infinity),
146
+ )
147
+ }
148
+
149
+ interface ProductReport {
150
+ reports?: {
151
+ product?: {
152
+ gene_id?: string
153
+ transcripts?: {
154
+ select_category?: string
155
+ protein?: { accession_version?: string; length?: number }
156
+ }[]
157
+ }
158
+ }[]
159
+ }
160
+
161
+ /**
162
+ * geneId -> representative protein accession: MANE Select where flagged, else
163
+ * the longest isoform. A stable, comparable choice across species — picking
164
+ * "the first" would silently vary with NCBI's ordering.
165
+ */
166
+ export async function fetchRepresentativeProteins(geneIds: string[]) {
167
+ const byGene = new Map<string, string>()
168
+ if (geneIds.length > 0) {
169
+ const json = await jsonfetch<ProductReport>(
170
+ ncbiUrl(`${DATASETS}/gene/id/${geneIds.join(',')}/product_report`),
171
+ )
172
+ for (const { product } of json.reports ?? []) {
173
+ const candidates = (product?.transcripts ?? [])
174
+ .map(t => ({
175
+ acc: t.protein?.accession_version,
176
+ len: t.protein?.length ?? 0,
177
+ mane: /select/i.test(t.select_category ?? ''),
178
+ }))
179
+ .filter(
180
+ (c): c is { acc: string; len: number; mane: boolean } => !!c.acc,
181
+ )
182
+ const best =
183
+ candidates.find(c => c.mane) ??
184
+ [...candidates].sort((a, b) => b.len - a.len).at(0)
185
+ if (product?.gene_id && best) {
186
+ byGene.set(product.gene_id, best.acc)
187
+ }
188
+ }
189
+ }
190
+ return byGene
191
+ }
192
+
193
+ /** accession (first header token) -> ungapped sequence, from a multi-FASTA. */
194
+ export function parseFasta(text: string) {
195
+ const map = new Map<string, string>()
196
+ let acc: string | undefined
197
+ let buf: string[] = []
198
+ for (const line of text.split('\n')) {
199
+ if (line.startsWith('>')) {
200
+ if (acc) {
201
+ map.set(acc, buf.join(''))
202
+ }
203
+ acc = line.slice(1).split(/\s+/)[0]
204
+ buf = []
205
+ } else {
206
+ buf.push(line.trim())
207
+ }
208
+ }
209
+ if (acc) {
210
+ map.set(acc, buf.join(''))
211
+ }
212
+ return map
213
+ }
214
+
215
+ function sanitize(name: string) {
216
+ return name.replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '')
217
+ }
218
+
219
+ /**
220
+ * Sanitized, unique single-token labels used identically in the FASTA headers,
221
+ * the tree leaf names and the domain GFF seq_ids — that identity is how the
222
+ * viewer pairs a tree leaf to its alignment row to its domain track. Collisions
223
+ * get a numeric suffix rather than silently overwriting a row.
224
+ */
225
+ export function dedupeLabels(names: string[]) {
226
+ const seen = new Map<string, number>()
227
+ return names.map(name => {
228
+ const base = sanitize(name) || 'row'
229
+ const n = seen.get(base) ?? 0
230
+ seen.set(base, n + 1)
231
+ return n === 0 ? base : `${base}_${n + 1}`
232
+ })
233
+ }
234
+
235
+ /**
236
+ * The representative protein for a single gene, with its sequence. Used to
237
+ * decide whether the user's own translated transcript is byte-identical to the
238
+ * RefSeq protein — if it is, that accession's precomputed CDD domains apply to
239
+ * the query row exactly, and if it isn't, they would land at an offset.
240
+ */
241
+ export async function fetchProteinForGene(geneId: string) {
242
+ const acc = (await fetchRepresentativeProteins([geneId])).get(geneId)
243
+ if (!acc) {
244
+ return undefined
245
+ }
246
+ const seq = parseFasta(
247
+ await textfetch(
248
+ ncbiUrl(
249
+ `${EUTILS}/efetch.fcgi?db=protein&id=${acc}&rettype=fasta&retmode=text`,
250
+ ),
251
+ ),
252
+ ).get(acc)
253
+ return seq ? { accession: acc, sequence: seq } : undefined
254
+ }
255
+
256
+ /**
257
+ * The whole NCBI half of the pipeline: gene -> ortholog rows carrying labels,
258
+ * accessions and sequences. Everything here is a precomputed lookup, so this
259
+ * returns in seconds rather than the 10+ minutes a BLAST submission costs.
260
+ */
261
+ export async function fetchOrthologRows({
262
+ geneId,
263
+ taxa,
264
+ onProgress,
265
+ }: {
266
+ geneId: string
267
+ taxa: Set<number>
268
+ onProgress: (arg: string) => void
269
+ }): Promise<OrthologRow[]> {
270
+ onProgress('Finding orthologs across species...')
271
+ const genes = await fetchOrthologGenes(geneId, taxa)
272
+ if (genes.length < 2) {
273
+ throw new Error(
274
+ `Only ${genes.length} ortholog(s) found among the selected species — not enough to align`,
275
+ )
276
+ }
277
+
278
+ onProgress('Selecting a representative protein per species...')
279
+ const proteinByGene = await fetchRepresentativeProteins(
280
+ genes.map(g => g.geneId),
281
+ )
282
+ const withProtein = genes.filter(g => proteinByGene.has(g.geneId))
283
+ if (withProtein.length < 2) {
284
+ throw new Error(
285
+ 'Could not resolve representative proteins for the orthologs',
286
+ )
287
+ }
288
+
289
+ onProgress(`Fetching ${withProtein.length} protein sequences...`)
290
+ const accessions = withProtein.map(g => proteinByGene.get(g.geneId)!)
291
+ const seqByAcc = parseFasta(
292
+ await textfetch(
293
+ ncbiUrl(
294
+ `${EUTILS}/efetch.fcgi?db=protein&id=${accessions.join(',')}&rettype=fasta&retmode=text`,
295
+ ),
296
+ ),
297
+ )
298
+
299
+ const labels = dedupeLabels(
300
+ withProtein.map(g => g.commonName ?? g.scientificName),
301
+ )
302
+ const rows = withProtein
303
+ .map((g, i) => {
304
+ const protein = proteinByGene.get(g.geneId)!
305
+ return {
306
+ taxId: g.taxId,
307
+ label: labels[i]!,
308
+ scientificName: g.scientificName,
309
+ commonName: g.commonName,
310
+ geneId: g.geneId,
311
+ protein,
312
+ sequence: seqByAcc.get(protein) ?? '',
313
+ }
314
+ })
315
+ .filter(r => r.sequence)
316
+ if (rows.length < 2) {
317
+ throw new Error('Could not fetch protein sequences for the orthologs')
318
+ }
319
+ return rows
320
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.7.3'
1
+ export const version = '2.7.4'