react-msaview-cli 8.2.0 → 8.3.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 +86 -12
  2. package/dist/index.js +37685 -36409
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -7,7 +7,8 @@ The CLI has two groups of commands, and the second draws what the first writes:
7
7
 
8
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
- a RefSeq transcript's exon model (`genestructure`).
10
+ a RefSeq transcript's exon model (`genestructure`), and relate rows to 3D
11
+ structures (`residue-mappings`).
11
12
  - **Render**: draw the alignment, its tree, and those annotations to a
12
13
  standalone SVG (`export-svg`). The command runs the web viewer's renderer
13
14
  headlessly, so the figure matches what the app shows.
@@ -16,9 +17,10 @@ The CLI has two groups of commands, and the second draws what the first writes:
16
17
 
17
18
  - NodeJS v22+
18
19
 
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)).
20
+ `export-svg`, `interpro` and `residue-mappings` need nothing else.
21
+ `interproscan` needs a backend to scan with: the EBI web API (the default, no
22
+ install), Docker, Singularity, or a local InterProScan (see
23
+ [interproscan](#interproscan)).
22
24
 
23
25
  `export-svg` draws the alignment background as one embedded image when
24
26
  [@napi-rs/canvas](https://www.npmjs.com/package/@napi-rs/canvas) is present. The
@@ -73,9 +75,10 @@ react-msaview-cli export-svg --msa <file> [options]
73
75
 
74
76
  | Option | Description | Default |
75
77
  | ------------------------ | ---------------------------------------------- | --------------- |
78
+ | `--spec <file.json>` | View spec or snapshot (see below) | |
76
79
  | `--msa <file>` | MSA file (FASTA, Stockholm, Clustal, A3M, EMF) | _required_ |
77
80
  | `--tree <file>` | Newick tree file | |
78
- | `--gff <file>` | Domain or exon GFF (from the commands below) | |
81
+ | `--gff <file>` | Domain or exon GFF, or InterProScan JSON | |
79
82
  | `-o, --output <file>` | Output SVG file path | `alignment.svg` |
80
83
  | `--color-scheme <name>` | Color scheme | `maeditor` |
81
84
  | `--col-width <px>` | Width of one alignment column | `12` |
@@ -101,6 +104,20 @@ react-msaview-cli export-svg --msa kinases.aln --tracks conservation,position-ru
101
104
  -o kinases.svg
102
105
  ```
103
106
 
107
+ ### Layers
108
+
109
+ `--spec` takes an `MsaView` snapshot or its shorthand as a JSON file, so any
110
+ layer in [docs/layers.md](../../docs/layers.md) draws in the figure: column
111
+ tracks, highlights, clades, row panels, encodings. A spec that sets `msa`,
112
+ `tree`, or a filehandle's `uri` to a relative path reads it beside the spec
113
+ file, and an `http(s)` one fetches it. `--msa` is then optional, and every flag
114
+ given on the command line overrides the spec. The figure draws the tracks the
115
+ app would show for the spec, unless `--tracks` names them.
116
+
117
+ ```bash
118
+ react-msaview-cli export-svg --spec p53-view.json -o p53.svg
119
+ ```
120
+
104
121
  ### Sizing the figure
105
122
 
106
123
  `export-svg` draws the **entire** alignment unless `--viewport` asks for the
@@ -176,9 +193,12 @@ react-msaview-cli interpro <accessions.tsv> [options]
176
193
  ```
177
194
 
178
195
  The input is one accession per line, optionally followed by a tab- or
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.
196
+ space-separated row label. The command skips lines starting with `#`. It reads
197
+ an isoform (`P04637-2`) or versioned (`P04637.4`) accession as the canonical one
198
+ and warns, and stops before any request on an entry name (`P53_HUMAN`), a RefSeq
199
+ id or anything else InterPro does not key by; run `interproscan` on those. It
200
+ writes through the same GFF writer as `interproscan`, and adds a `#` header line
201
+ naming the InterPro release the coordinates came from.
182
202
 
183
203
  | Option | Description | Default |
184
204
  | --------------------- | ----------------------------------------------- | ------------- |
@@ -188,10 +208,13 @@ the InterPro release the coordinates came from.
188
208
  | `--format <name>` | Force the `--msa` format instead of sniffing it | |
189
209
  | `--no-cache` | Re-fetch, ignoring the disk cache | off |
190
210
 
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.
211
+ InterPro computes matches on UniProt's canonical sequence. A label ending in
212
+ `/start-end`, as Pfam and Stockholm name a fragment row (`P12931/84-145`), moves
213
+ each match into the fragment's own positions and clips it to the fragment. On an
214
+ isoform row the matches land on the wrong residues. With `--msa`, the CLI
215
+ compares each row's ungapped length against the protein's, or against the
216
+ range's for a fragment, and warns about any that differ. It also warns about any
217
+ accession with no matches.
195
218
 
196
219
  ```bash
197
220
  react-msaview-cli interpro accessions.tsv -o domains.gff
@@ -212,6 +235,9 @@ the rest from disk. A failed run can therefore resume. The CLI retries with
212
235
  backoff, and if the API stays unreachable, the accessions it already fetched
213
236
  stay cached, so the next run fetches only the rest.
214
237
 
238
+ When the release lookup fails, the CLI warns and reads the newest release in the
239
+ cache, so a fully cached run needs no network.
240
+
215
241
  ### interproscan
216
242
 
217
243
  Run InterProScan on all sequences in an MSA file and output results as GFF3. Use
@@ -322,6 +348,54 @@ react-msaview-cli genestructure f12-cds.stock --gene F12 --ref human -o exons.gf
322
348
  react-msaview-cli genestructure aln.fa --transcript NM_000505.4 --ref human
323
349
  ```
324
350
 
351
+ ### residue-mappings
352
+
353
+ Build the
354
+ [`residueMappings` layer](https://github.com/GMOD/JBrowseMSA/blob/main/docs/layers.md#residuemappings),
355
+ which tells the viewer which residue of a PDB chain or an AlphaFold model each
356
+ residue of a row is. The output is `{"residueMappings": [...]}`, ready for the
357
+ `residueMappings` prop, a `?data=` link, or the R and Python widgets.
358
+
359
+ ```bash
360
+ react-msaview-cli residue-mappings --msa <file> --row <name> --accession <acc> \
361
+ (--pdb <id> --chain <id> | --alphafold) [-o mappings.json]
362
+ react-msaview-cli residue-mappings --msa <file> --rows <tsv> [-o mappings.json]
363
+ ```
364
+
365
+ | Option | Description | Default |
366
+ | ------------------------- | ------------------------------------------------------- | ------- |
367
+ | `--msa <file>` | Alignment holding the rows | |
368
+ | `--format <name>` | Force the MSA format instead of sniffing it | |
369
+ | `--rows <tsv>` | `row`, `accession`, `structure` per line, tab-separated | |
370
+ | `--row <name>` | One row, instead of `--rows` | |
371
+ | `--accession <acc>` | The row's UniProtKB accession | |
372
+ | `--pdb <id> --chain <id>` | The PDB entry and its author chain | |
373
+ | `--alphafold` | The AlphaFold DB model of the accession instead | |
374
+ | `-o, --output <file>` | Output JSON file | stdout |
375
+
376
+ In `--rows`, the structure column is `6VXX:A` or `alphafold`, and a
377
+ `row accession structure` header line is optional. A row may appear on several
378
+ lines to map it onto several structures.
379
+
380
+ For each row, the CLI first fetches the accession's sequence from UniProt and
381
+ checks the row's ungapped residues against it. A row named `/start-end` has to
382
+ match that slice of the protein, and every position in its mapping is a residue
383
+ of the row. A mismatch stops the run with the row, the accession and the first
384
+ residue where they differ.
385
+
386
+ For a PDB chain, the segments come from the PDBe SIFTS mapping of the entry, and
387
+ `unobserved` lists every position of the chain's entity outside PDBe's observed
388
+ ranges. `asymId` is the `struct_asym_id` SIFTS gives for the author chain. For
389
+ an AlphaFold model, the model numbers the protein from 1, so the mapping is one
390
+ segment and has no `unobserved`.
391
+
392
+ ```console
393
+ $ react-msaview-cli residue-mappings --msa spike.afa --row SARS-CoV-2 \
394
+ --accession P0DTC2 --pdb 6VXX --chain A -o mappings.json
395
+ SARS-CoV-2: P0DTC2 onto 6VXX chain A, row 14-1211 at 33-1230
396
+ wrote mappings.json
397
+ ```
398
+
325
399
  ## Input formats
326
400
 
327
401
  The CLI sniffs the format from the file's content, not from its name. `--format`