react-msaview-cli 7.0.0 → 8.1.0

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 (3) hide show
  1. package/README.md +98 -108
  2. package/dist/index.js +50233 -47131
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -3,28 +3,29 @@
3
3
  Annotate a multiple sequence alignment and render it to a publication figure,
4
4
  from the command line, with no browser in the loop.
5
5
 
6
- Two things live here, and they compose:
6
+ The CLI has two groups of commands, and the second draws what the first writes:
7
7
 
8
- - **Annotate** build a domain or exon GFF for an alignment, from InterPro's
8
+ - **Annotate**: build a domain or exon GFF for an alignment, from InterPro's
9
9
  precomputed matches (`interpro`), a live InterProScan run (`interproscan`), or
10
10
  a RefSeq transcript's exon model (`genestructure`).
11
- - **Render** draw the alignment, its tree, and those annotations to a
12
- standalone SVG (`export-svg`). This is the same renderer the web viewer uses,
13
- driven headlessly, so the figure matches what the app shows.
11
+ - **Render**: draw the alignment, its tree, and those annotations to a
12
+ standalone SVG (`export-svg`). The command runs the web viewer's renderer
13
+ headlessly, so the figure matches what the app shows.
14
14
 
15
15
  ## Prerequisites
16
16
 
17
17
  - NodeJS v22+
18
18
 
19
- Nothing else for `export-svg` and `interpro`. `interproscan` needs a backend to
20
- scan with the EBI web API (the default, no install), or Docker, Singularity,
21
- or a local InterProScan (see [interproscan](#interproscan)).
19
+ `export-svg` and `interpro` need nothing else. `interproscan` needs a backend to
20
+ scan with: the EBI web API (the default, no install), Docker, Singularity, or a
21
+ local InterProScan (see [interproscan](#interproscan)).
22
22
 
23
23
  `export-svg` draws the alignment background as one embedded image when
24
- [@napi-rs/canvas](https://www.npmjs.com/package/@napi-rs/canvas) is present. It
25
- is an optional dependency with prebuilt binaries, so a normal install brings it
26
- in; on a platform it does not cover, the export still works and draws a
27
- rectangle per cell instead, which is much larger and slower for big alignments.
24
+ [@napi-rs/canvas](https://www.npmjs.com/package/@napi-rs/canvas) is present. The
25
+ package is an optional dependency with prebuilt binaries, so a normal install
26
+ brings it in. On a platform with no prebuilt binary, the export draws a
27
+ rectangle per cell, which makes a much larger file and runs slower on big
28
+ alignments.
28
29
 
29
30
  ## Setup
30
31
 
@@ -55,9 +56,10 @@ react-msaview-cli export-svg --msa kinases.aln --tree kinases.nwk \
55
56
 
56
57
  ![Src-family kinases: tree, SH3/SH2/kinase domain architecture, and the color key](../../docs/media/cli-domains.png)
57
58
 
58
- The domain architecture reads straight down the alignment SH3, then SH2, then
59
- the catalytic domain because every row is drawn in the alignment's own column
60
- space. The key on the right is generated from the domains actually present.
59
+ The domain architecture reads straight down the alignment: SH3, then SH2, then
60
+ the catalytic domain. The renderer draws every row in the alignment's column
61
+ space, so each domain lands in the same columns in every row. The key on the
62
+ right lists the domains present in the GFF.
61
63
 
62
64
  Every figure on this page is `export-svg` output, drawn from the Src-kinase and
63
65
  GPCR examples in
@@ -91,8 +93,8 @@ react-msaview-cli export-svg --msa <file> [options]
91
93
  `--tracks` names the tracks to draw above the alignment, by id, or `all` for
92
94
  every one this alignment has: `conservation`, `property-conservation` (protein
93
95
  only), `sequence-logo`, `position-ruler`, `base-pairs` (a Stockholm `SS_cons`
94
- line), and any track ids the file itself carries. A name matching no track is
95
- reported rather than silently dropped.
96
+ line), and any track ids the file itself carries. The CLI reports a name that
97
+ matches no track.
96
98
 
97
99
  ```bash
98
100
  react-msaview-cli export-svg --msa kinases.aln --tracks conservation,position-ruler \
@@ -102,10 +104,9 @@ react-msaview-cli export-svg --msa kinases.aln --tracks conservation,position-ru
102
104
  ### Sizing the figure
103
105
 
104
106
  `export-svg` draws the **entire** alignment unless `--viewport` asks for the
105
- `--width` x `--height` window at the top left instead, so the output is normally
106
- as wide as the alignment is long `--width` and `--height` size the viewport
107
- the model lays out in, not the figure. What scales the figure is `--col-width`
108
- and `--row-height`:
107
+ `--width` x `--height` window at the top left, so the output is normally as wide
108
+ as the alignment is long. `--width` and `--height` size the viewport the model
109
+ lays out in, not the figure. `--col-width` and `--row-height` scale the figure:
109
110
 
110
111
  ```bash
111
112
  ## a 90-column alignment at the default 12px columns: letters are legible
@@ -122,12 +123,11 @@ react-msaview-cli export-svg --msa kinases.aln --tree kinases.nwk \
122
123
 
123
124
  ![The same kinase family drawn as a colored overview beside its tree](../../docs/media/cli-quickstart.png)
124
125
 
125
- Residue letters draw only where there is room for them columns at least 5px
126
- wide and wider than half the row height, rows at least 8px tall which is the
127
- same rule the app applies as you zoom out. Below that you get the colored
128
- overview above, and for a whole-alignment figure that is usually what you want:
129
- the conserved blocks and the gaps are the signal at that scale, and the letters
130
- would be unreadable ink.
126
+ Residue letters draw only in columns at least 5px wide and wider than half the
127
+ row height, and in rows at least 8px tall. The app applies the same rule as you
128
+ zoom out. Below that size the figure is the colored overview above, which
129
+ usually suits a whole-alignment figure: at that scale the conserved blocks and
130
+ gaps are visible, and letters would be too small to read.
131
131
 
132
132
  ### Color schemes
133
133
 
@@ -142,47 +142,43 @@ react-msaview-cli export-svg --msa gpcrs.fa \
142
142
  `cinema`, and the `jalview_*` family (`jalview_zappo`, `jalview_taylor`,
143
143
  `jalview_hydrophobicity`, `jalview_buried`, `jalview_prophelix`,
144
144
  `jalview_propstrand`, `jalview_propturn`) color each residue by identity. The
145
- two `_dynamic` schemes `clustalx_protein_dynamic` and
146
- `percent_identity_dynamic` color by what the column actually contains, so
147
- conservation shows up as color rather than as something you have to read off.
148
- `nucleotide`, `clustalx_dna`, `jbrowse_dna` and `rainbow_dna` are for DNA;
149
- `none` turns background color off.
145
+ two `_dynamic` schemes, `clustalx_protein_dynamic` and
146
+ `percent_identity_dynamic`, color each residue by the composition of its column,
147
+ so conserved columns stand out by color. `nucleotide`, `clustalx_dna`,
148
+ `jbrowse_dna` and `rainbow_dna` are for DNA; `none` turns background color off.
150
149
 
151
150
  ### Output
152
151
 
153
- The SVG scales without limit and grows with the alignment. The background is one
154
- embedded image where @napi-rs/canvas is installed, and a rectangle per cell
155
- where it is not the letters, the tree and the annotations are vector either
156
- way. A 10-row by 856-column figure is about 700KB. Converting to PNG or PDF for
157
- a journal:
152
+ The SVG grows with the alignment: a 10-row by 856-column figure is about 700KB.
153
+ The background is one embedded image where @napi-rs/canvas is installed, and a
154
+ rectangle per cell where it is not. The letters, the tree and the annotations
155
+ are vector either way. To convert to PNG or PDF for a journal:
158
156
 
159
157
  ```bash
160
158
  rsvg-convert -w 2000 alignment.svg -o alignment.png
161
159
  inkscape alignment.svg --export-filename=alignment.pdf
162
160
  ```
163
161
 
164
- Exports are reproducible — the same input gives the same bytes, so a figure can
165
- be regenerated in CI and diffed.
162
+ The same input gives the same bytes, so CI can regenerate a figure and diff it.
166
163
 
167
164
  ## Annotating
168
165
 
169
166
  ### interpro
170
167
 
171
168
  Build a domain GFF from InterPro's **precomputed** matches for UniProtKB
172
- accessions, instead of submitting sequences to a live InterProScan job. Every
173
- UniProtKB sequence already has InterPro matches computed and served by the EBI
174
- InterPro API, so for inputs that are real UniProt accessions this is instant,
175
- deterministic, and version-pinnable no email or rate-limited job submission.
176
- Prefer this over `interproscan` whenever your rows are UniProt accessions.
169
+ accessions. The EBI InterPro API already serves matches for every UniProtKB
170
+ sequence, so the lookup returns in seconds, gives the same result for a given
171
+ InterPro release, and needs no email or rate-limited job. Use this instead of
172
+ `interproscan` whenever your rows are UniProt accessions.
177
173
 
178
174
  ```bash
179
175
  react-msaview-cli interpro <accessions.tsv> [options]
180
176
  ```
181
177
 
182
178
  The input is one accession per line, optionally followed by a tab- or
183
- space-separated row label; lines starting with `#` are ignored. The output goes
184
- through the same writer the `interproscan` command's does, plus a `#` header
185
- line naming the InterPro release the coordinates came from.
179
+ space-separated row label. The command skips lines starting with `#`. It writes
180
+ through the same GFF writer as `interproscan`, and adds a `#` header line naming
181
+ the InterPro release the coordinates came from.
186
182
 
187
183
  | Option | Description | Default |
188
184
  | --------------------- | ----------------------------------------------- | ------------- |
@@ -192,11 +188,10 @@ line naming the InterPro release the coordinates came from.
192
188
  | `--format <name>` | Force the `--msa` format instead of sniffing it | |
193
189
  | `--no-cache` | Re-fetch, ignoring the disk cache | off |
194
190
 
195
- Matches are computed on UniProt's canonical sequence, so a row that is an
196
- isoform or a fragment puts them on the wrong residues. Pass `--msa` and each
197
- row's ungapped length is checked against the protein's, with a warning naming
198
- any that disagree. An accession that resolves to no matches is called out too,
199
- rather than leaving its row silently undecorated.
191
+ InterPro computes matches on UniProt's canonical sequence, so on a row that is
192
+ an isoform or a fragment the matches land on the wrong residues. With `--msa`,
193
+ the CLI compares each row's ungapped length against the protein's and warns
194
+ about any that differ. It also warns about any accession with no matches.
200
195
 
201
196
  ```bash
202
197
  react-msaview-cli interpro accessions.tsv -o domains.gff
@@ -205,25 +200,23 @@ react-msaview-cli interpro accessions.tsv -o domains.gff --database cdd
205
200
 
206
201
  #### Caching
207
202
 
208
- The InterPro API serves one protein per request there is no batch endpoint
209
- so the request count is fixed at one per distinct accession. To keep that from
210
- being paid twice, every response is cached on disk under
211
- `$XDG_CACHE_HOME/react-msaview-cli/interpro` (override with
212
- `REACT_MSAVIEW_CACHE`), keyed by InterPro release so a new release misses
213
- cleanly rather than serving coordinates computed against the old one. Proteins
214
- with no matches are cached too, so they are not re-fetched every run.
203
+ The InterPro API serves one protein per request and has no batch endpoint, so a
204
+ run makes one request per distinct accession. The CLI caches every response on
205
+ disk under `$XDG_CACHE_HOME/react-msaview-cli/interpro` (override with
206
+ `REACT_MSAVIEW_CACHE`), keyed by InterPro release, so a new release fetches
207
+ fresh coordinates. The cache also records proteins with no matches, so a re-run
208
+ does not fetch them again.
215
209
 
216
- A re-run of the same dataset therefore makes one request the release lookup
217
- and answers the rest from disk. That also makes a failed run resumable: retries
218
- are automatic with backoff, and if the API is still unreachable the accessions
219
- already fetched stay cached, so re-running picks up where it stopped instead of
220
- asking EBI for all of them again.
210
+ A re-run of the same dataset makes one request, the release lookup, and reads
211
+ the rest from disk. A failed run can therefore resume. The CLI retries with
212
+ backoff, and if the API stays unreachable, the accessions it already fetched
213
+ stay cached, so the next run fetches only the rest.
221
214
 
222
215
  ### interproscan
223
216
 
224
217
  Run InterProScan on all sequences in an MSA file and output results as GFF3. Use
225
- this when the rows are not UniProt accessions a de novo assembly, predicted
226
- proteins, anything InterPro has not already scanned.
218
+ this when the rows are not UniProt accessions: a de novo assembly, predicted
219
+ proteins, or anything else InterPro has not scanned.
227
220
 
228
221
  ```bash
229
222
  react-msaview-cli interproscan <input-msa> [options]
@@ -244,17 +237,17 @@ react-msaview-cli interproscan <input-msa> [options]
244
237
  | `--email <email>` | Email for EBI API (used only for EBI API runs) | `user@example.com` |
245
238
 
246
239
  By default (no backend flag) the CLI submits sequences to the EBI InterProScan
247
- REST API one at a time. `--local`, `--docker`, and `--singularity` instead run
240
+ REST API one at a time. `--local`, `--docker`, and `--singularity` run
248
241
  InterProScan on the whole alignment locally, which is much faster for large
249
242
  datasets.
250
243
 
251
244
  #### Choosing a backend
252
245
 
253
246
  ```bash
254
- ## EBI web API no install, but one sequential submission per sequence
247
+ ## EBI web API: no install, one sequential submission per sequence
255
248
  react-msaview-cli interproscan alignment.fasta -o domains.gff --email you@example.com
256
249
 
257
- ## Docker no InterProScan install, whole alignment in one run
250
+ ## Docker: no InterProScan install, whole alignment in one run
258
251
  react-msaview-cli interproscan alignment.fasta -o domains.gff --docker
259
252
 
260
253
  ## a local install
@@ -273,22 +266,20 @@ The published image carries InterProScan but **not** its member database data,
273
266
  which is a separate multi-gigabyte download. Fetch and unpack the matching
274
267
  release's `data/` directory (see the
275
268
  [InterProScan docs](https://interproscan-docs.readthedocs.io/)) and point
276
- `--interproscan-data` at it; it is mounted at `/opt/interproscan/data`, where
277
- both container backends look for it.
269
+ `--interproscan-data` at it. Both container backends mount it at
270
+ `/opt/interproscan/data` and look for it there.
278
271
 
279
- The EBI API has usage limits: sequences go one at a time, sequentially, to avoid
280
- overwhelming the server. Past about 100 sequences, use a local or container
281
- backend.
272
+ The EBI API has usage limits, so the CLI submits sequences one at a time. Past
273
+ about 100 sequences, use a local or container backend.
282
274
 
283
275
  #### InterProScan programs
284
276
 
285
- `--programs` takes the EBI API's names `PfamA` and `CDD` (the default),
286
- `SMART`, `SuperFamily`, `Gene3d`, `PANTHER`, `TIGRFAM`, `HAMAP`,
277
+ `--programs` takes the EBI API's names whichever backend runs: `PfamA` and `CDD`
278
+ (the default), `SMART`, `SuperFamily`, `Gene3d`, `PANTHER`, `TIGRFAM`, `HAMAP`,
287
279
  `PrositeProfiles`, `PrositePatterns`, `PRINTS`, `PIRSF`, `MobiDBLite`, `Coils`,
288
- `SFLD` — whichever backend runs. InterProScan 5 spells several of them
289
- differently (`Pfam`, not `PfamA`; `NCBIfam`, which absorbed TIGRFAM; `Hamap`;
290
- `SUPERFAMILY`; `Gene3D`), and the local, Docker and Singularity backends get the
291
- translated names.
280
+ `SFLD`. InterProScan 5 spells several of them differently (`Pfam`, not `PfamA`;
281
+ `NCBIfam`, which absorbed TIGRFAM; `Hamap`; `SUPERFAMILY`; `Gene3D`), and the
282
+ CLI passes the translated names to the local, Docker and Singularity backends.
292
283
 
293
284
  ```bash
294
285
  react-msaview-cli interproscan alignment.fasta -o domains.gff \
@@ -298,20 +289,21 @@ react-msaview-cli interproscan alignment.fasta -o domains.gff \
298
289
  ### genestructure
299
290
 
300
291
  Build a **gene-structure GFF** for a coding-sequence alignment from a RefSeq
301
- transcript, overlaid the same way InterProScan domains are. The exon model is
302
- fetched from the NCBI Datasets v2 API; each species' Nth exon is named `exon-N`,
303
- so a given exon is the same color in every row and the exon architecture reads
304
- straight down the alignment.
292
+ transcript, overlaid the same way InterProScan domains are. The command fetches
293
+ the exon model from the NCBI Datasets v2 API and names each species' Nth exon
294
+ `exon-N`, so a given exon is the same color in every row and the exon
295
+ architecture reads straight down the alignment.
305
296
 
306
297
  ```bash
307
298
  react-msaview-cli genestructure <input-msa> --gene <symbol> --ref <rowname> [options]
308
299
  ```
309
300
 
310
- The exon boundaries of the chosen transcript are mapped onto the reference row's
311
- columns, then projected into every other row's own ungapped coordinates — so an
312
- exon that picks up a frameshifting indel in one lineage gets shorter on exactly
313
- that row while staying column-aligned with the rest. The reference row must be
314
- the transcript's coding sequence (the CLI warns if its length doesn't match).
301
+ The command maps the chosen transcript's exon boundaries onto the reference
302
+ row's columns, then projects them into every other row's ungapped coordinates.
303
+ An exon that picks up a frameshifting indel in one lineage therefore gets
304
+ shorter on that row and stays in the same columns as the rest. The reference row
305
+ must be the transcript's coding sequence; the CLI warns if its length doesn't
306
+ match.
315
307
 
316
308
  | Option | Description | Default |
317
309
  | --------------------- | --------------------------------------------- | ------------------- |
@@ -332,20 +324,19 @@ react-msaview-cli genestructure aln.fa --transcript NM_000505.4 --ref human
332
324
 
333
325
  ## Input formats
334
326
 
335
- The CLI sniffs the format from the file's content, not from its name, and
336
- `--format` (`fasta`, `a3m`, `stockholm`, `clustal`, `emf`) settles it when the
337
- guess is wrong — FASTA and A3M share a leading `>`, so telling them apart is a
338
- heuristic:
327
+ The CLI sniffs the format from the file's content, not from its name. `--format`
328
+ (`fasta`, `a3m`, `stockholm`, `clustal`, `emf`) overrides a wrong guess. FASTA
329
+ and A3M share a leading `>`, so the CLI tells them apart heuristically.
339
330
 
340
331
  - **FASTA** (`.fasta`, `.fa`, `.faa`)
341
332
  - **Clustal** (`.clustal`, `.aln`)
342
333
  - **Stockholm** (`.sto`, `.stockholm`)
343
- - **A3M** (`.a3m`) AlphaFold/ColabFold
344
- - **EMF** (`.emf`) Ensembl Multi Format
334
+ - **A3M** (`.a3m`), from AlphaFold/ColabFold
335
+ - **EMF** (`.emf`), Ensembl Multi Format
345
336
 
346
337
  ## Annotation output format
347
338
 
348
- The annotation commands write standard GFF3, one line per feature
339
+ The annotation commands write standard GFF3, one line per feature:
349
340
  `protein_match` for a domain from `interpro`/`interproscan`, `exon` for a
350
341
  segment from `genestructure`. `start`/`end` are 1-based positions in the
351
342
  **ungapped** sequence, and the attributes carry the accession, name, and
@@ -374,12 +365,12 @@ Done!
374
365
 
375
366
  ## Using the GFF elsewhere
376
367
 
377
- The same file the CLI writes loads into every other front end.
368
+ The web viewer, the React component and the R package all load the file the CLI
369
+ writes.
378
370
 
379
371
  In the web viewer, select it in the import form's **Annotation GFF file or URL**
380
- field. (The **Annotations > Open InterProScan results...** menu item takes
381
- InterProScan JSON rather than GFF, so use the import form for the file generated
382
- above.)
372
+ field, or open it over a loaded alignment with **Annotations > Open annotation
373
+ file...**, which also accepts the JSON an InterProScan run returns.
383
374
 
384
375
  In the React component, pass it inline as the `gff` prop:
385
376
 
@@ -395,11 +386,10 @@ msaview(msa = "alignment.fasta", gff = "domains.gff")
395
386
 
396
387
  ## Troubleshooting
397
388
 
398
- **EBI API timeout.** A single sequence has been measured at fifteen minutes in
399
- the queue; the CLI waits an hour per job and keeps the results of the sequences
400
- that did finish. Use `--local`, `--docker`, or `--singularity` to run
401
- InterProScan yourself. For large datasets those are much faster than the API
402
- regardless.
389
+ **EBI API timeout.** We measured one sequence waiting fifteen minutes in the
390
+ queue. The CLI waits an hour per job and keeps the results of the sequences that
391
+ finished. Use `--local`, `--docker`, or `--singularity` to run InterProScan
392
+ yourself; on large datasets they are much faster than the API.
403
393
 
404
394
  **Local InterProScan not found.**
405
395
 
@@ -415,9 +405,9 @@ nucleotide; try other `--programs`; verify the input parses as one of the
415
405
  formats above.
416
406
 
417
407
  **The exported figure is enormous.** `export-svg` draws the whole alignment at
418
- `--col-width` per column. Drop `--col-width` until it fits below 5px (or below
419
- half the row height) the residue letters stop drawing, which is most of the file
420
- size.
408
+ `--col-width` per column. Lower `--col-width` until it fits. Below 5px, or below
409
+ half the row height, the residue letters stop drawing, and they account for most
410
+ of the file size.
421
411
 
422
412
  ## Uses
423
413