@lipme/vue-blast-viewer 1.0.17 → 1.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.
package/README.md CHANGED
@@ -10,7 +10,9 @@ An interactive, responsive, and visually rich Vue 3 component for displaying bio
10
10
  - **Searchable & Sortable Table**: Displays descriptions, Max Score, Total Score, Query Coverage (overlapping intervals merged), E-values, and Identity percentages. Supports exporting the current filtered results directly to a TSV file.
11
11
  - **Pairwise Alignment Visualizer**: Formats alignment text in blocks of 60 characters with colored annotations highlighting exact matches, gaps, and mismatches, with exact forward and reverse coordinate tracking.
12
12
  - **Custom Accession Linkers**: Dynamically redirects accession IDs to custom endpoints using string templates (`{accession}`).
13
- - **Modern Responsive Design**: A glassmorphic dark-theme tailored for scientific applications, supporting drag-and-drop file uploading and raw JSON pasting.
13
+ - **Material Design look**: Styled like Vuetify 3 (and the viewnomics app), with light and dark themes. Inside a Vuetify app, brand colours follow the host theme automatically.
14
+ - **Safe by default**: link templates are URL-encoded and restricted to http(s)/relative URLs, report text is never rendered as HTML, and TSV exports are protected against spreadsheet formula injection.
15
+ - **Fast on large reports**: tabs are mounted on first visit, alignments are rendered as merged text runs (very long HSPs show their first 50 blocks, with a button for the rest), and tooltips never re-render the graphic.
14
16
 
15
17
  ---
16
18
 
@@ -120,6 +122,11 @@ const subjectLinkTemplate = computed(() => {
120
122
  | `blastData` | `BlastRoot \| null` | Yes | `null` | The parsed JSON output payload matching standard NCBI BLAST JSON structures. |
121
123
  | `queryLink` | `string` | No | `null` | String template to resolve the link for the Query ID in the metadata header (use `{accession}`). |
122
124
  | `subjectLink` | `string` | No | `null` | String template to resolve the links for Subject/target accessions in the hit list and alignments. |
125
+ | `theme` | `'light' \| 'dark'` | No | `'light'` | Colour theme of the component. |
126
+ | `db` | `string` | No | report's `search_target.db` | Database label shown in the header. |
127
+ | `isGenomic` | `boolean` | No | `false` | Subjects are genomic sequences: HSP subject coordinates become links, `{accession}` being replaced by `accession:from..to`. |
128
+
129
+ Link templates: every `{accession}` is replaced by the URL-encoded accession (`:` is kept). A template whose result is not an `http(s)://`, `/`, `./`, `#` or `?` URL is ignored and the accession is shown as plain text.
123
130
 
124
131
  ---
125
132
 
@@ -179,23 +186,25 @@ export interface BlastRoot {
179
186
 
180
187
  ## 🎨 Theme Customization
181
188
 
182
- The aesthetics are configured via CSS variables. You can easily adjust the visual signature of the components by overriding these variables in your root stylesheet:
189
+ Styles are scoped to the component (`.blast-viewer`) and never touch the host page's `:root`. Colours are CSS custom properties prefixed `--bv-`; override them on `.blast-viewer` (or on `.blast-viewer.bv-theme--dark` for the dark theme):
183
190
 
184
191
  ```css
185
- :root {
186
- /* Core Spacings */
187
- --font-sans: 'Plus Jakarta Sans', sans-serif;
188
- --font-mono: 'Fira Code', monospace;
189
-
190
- /* Theme Base Color Modifiers */
191
- --bg-primary: #0a0e17;
192
- --bg-card: rgba(20, 27, 45, 0.65);
193
-
194
- /* BLAST Score Color Coding overrides */
195
- --blast-score-low: #4b5563; /* < 40 score */
196
- --blast-score-mid-low: #3b82f6; /* 40 - 50 score */
197
- --blast-score-mid: #10b981; /* 50 - 80 score */
198
- --blast-score-mid-high: #ec4899; /* 80 - 200 score */
199
- --blast-score-high: #ef4444; /* >= 200 score */
192
+ .blast-viewer {
193
+ --bv-font: Roboto, sans-serif;
194
+ --bv-font-mono: 'Roboto Mono', monospace;
195
+ --bv-primary: #1867c0; /* defaults to the host Vuetify theme's primary colour when available */
196
+
197
+ /* BLAST score colour key */
198
+ --bv-score-1: #424242; /* < 40 */
199
+ --bv-score-2: #1e88e5; /* 40–50 */
200
+ --bv-score-3: #43a047; /* 50–80 */
201
+ --bv-score-4: #d81b60; /* 80–200 */
202
+ --bv-score-5: #e53935; /* ≥ 200 */
200
203
  }
201
204
  ```
205
+
206
+ ### Upgrading from 1.0.x
207
+
208
+ - The default theme is now `light` (pass `theme="dark"` for the previous look).
209
+ - CSS variables were renamed with the `--bv-` prefix and scoped to the component (`--blast-score-low` → `--bv-score-1`, …, `--color-primary` → `--bv-primary`).
210
+ - `vue` is now a peer dependency.
@@ -1,7 +1,12 @@
1
1
  import type { BlastSearch } from '../types';
2
2
  type __VLS_Props = {
3
3
  searchData: BlastSearch;
4
- selectedHitNum: number | null;
4
+ program: string;
5
+ /** Hit to reveal; `seq` changes on every request, even for the same hit. */
6
+ selection: {
7
+ num: number;
8
+ seq: number;
9
+ } | null;
5
10
  subjectLink?: string;
6
11
  isGenomic?: boolean;
7
12
  };
@@ -1,6 +1,7 @@
1
1
  import type { BlastSearch } from '../types';
2
2
  type __VLS_Props = {
3
3
  searchData: BlastSearch;
4
+ theme: 'light' | 'dark';
4
5
  };
5
6
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
7
  "select-hit": (hitNum: number) => any;
@@ -0,0 +1,8 @@
1
+ import type { BlastHsp } from '../types';
2
+ type __VLS_Props = {
3
+ hsp: BlastHsp;
4
+ program: string;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -1,12 +1,19 @@
1
1
  import type { BlastRoot } from '../types';
2
2
  type __VLS_Props = {
3
3
  blastData: BlastRoot | null;
4
+ /** Link template for the query, `{accession}` is replaced by the query id. */
4
5
  queryLink?: string;
6
+ /** Link template for subjects, `{accession}` is replaced by the hit accession. */
5
7
  subjectLink?: string;
6
8
  theme?: 'light' | 'dark';
9
+ /** Database label, overrides the report's `search_target.db`. */
7
10
  db?: string;
11
+ /** Subjects are genomic sequences: HSP coordinates become region links. */
8
12
  isGenomic?: boolean;
9
13
  };
10
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
15
+ theme: "light" | "dark";
16
+ isGenomic: boolean;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
18
  declare const _default: typeof __VLS_export;
12
19
  export default _default;
@@ -0,0 +1,23 @@
1
+ declare const PATHS: {
2
+ readonly 'chevron-right': "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z";
3
+ readonly 'chevron-left': "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z";
4
+ readonly 'chevron-down': "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z";
5
+ readonly close: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";
6
+ readonly magnify: "M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z";
7
+ readonly download: "M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z";
8
+ readonly 'arrow-up': "M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z";
9
+ readonly 'arrow-down': "M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z";
10
+ readonly 'alert-circle-outline': "M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z";
11
+ readonly 'open-in-new': "M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z";
12
+ readonly eye: "M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z";
13
+ };
14
+ export type IconName = keyof typeof PATHS;
15
+ type __VLS_Props = {
16
+ name: IconName;
17
+ size?: number | string;
18
+ };
19
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
20
+ size: number | string;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { type TooltipState } from '../utils';
2
+ type __VLS_Props = {
3
+ state: TooltipState;
4
+ theme: 'light' | 'dark';
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
package/dist/types.d.ts CHANGED
@@ -8,8 +8,13 @@ export interface BlastHsp {
8
8
  query_to: number;
9
9
  hit_from: number;
10
10
  hit_to: number;
11
+ positive?: number;
11
12
  query_strand?: string;
12
13
  hit_strand?: string;
14
+ /** Reading frame of the query (translated searches: blastx, tblastx). */
15
+ query_frame?: number;
16
+ /** Reading frame of the subject (translated searches: tblastn, tblastx). */
17
+ hit_frame?: number;
13
18
  align_len: number;
14
19
  gaps: number;
15
20
  qseq: string;
@@ -0,0 +1,72 @@
1
+ import type { BlastHit, BlastHsp, BlastSearch } from './types';
2
+ /**
3
+ * Fill a `{accession}` link template and return a safe URL, or `undefined`
4
+ * when there is no template or the result is not an http(s)/relative URL.
5
+ *
6
+ * The accession comes from the BLAST report (possibly user-supplied sequences),
7
+ * so it is URI-encoded (keeping `:` for `acc:from..to` style region links) and
8
+ * the final URL is checked so a crafted value can never yield `javascript:` etc.
9
+ */
10
+ export declare function buildLink(template: string | undefined, accession: string): string | undefined;
11
+ export declare function formatEvalue(val: number): string;
12
+ export declare function percent(part: number, total: number): number;
13
+ /**
14
+ * Make a value safe for a TSV cell: no tab / newline (would break the row),
15
+ * and no leading formula character (CSV/TSV injection when opened in a spreadsheet).
16
+ */
17
+ export declare function tsvCell(value: string | number): string;
18
+ export declare function safeFileName(name: string): string;
19
+ /**
20
+ * Return a defensively normalized copy of a BLAST search: every field the
21
+ * components read exists with the right type, so a malformed or partial
22
+ * report renders (with blanks) instead of throwing during render.
23
+ */
24
+ export declare function normalizeSearch(search: BlastSearch): BlastSearch;
25
+ export type ColumnType = 'match' | 'positive' | 'mismatch' | 'gap';
26
+ /** Consecutive alignment columns sharing the same type, rendered as one text node. */
27
+ export interface Run {
28
+ type: ColumnType;
29
+ text: string;
30
+ }
31
+ export interface AlignmentBlock {
32
+ queryStart: number;
33
+ queryEnd: number;
34
+ sbjctStart: number;
35
+ sbjctEnd: number;
36
+ query: Run[];
37
+ midline: Run[];
38
+ sbjct: Run[];
39
+ }
40
+ /** Nucleotides consumed per alignment letter on each side, by BLAST program. */
41
+ export declare function coordinateSteps(program: string): {
42
+ q: number;
43
+ s: number;
44
+ };
45
+ /**
46
+ * Split an HSP into fixed-width blocks with correct start/end coordinates on
47
+ * both sequences (reverse strands and translated searches included). Columns
48
+ * are merged into typed runs to keep the DOM small.
49
+ */
50
+ export declare function buildAlignmentBlocks(hsp: BlastHsp, program?: string, blockSize?: number): AlignmentBlock[];
51
+ /** Query span of an HSP as an ordered [start, end] interval. */
52
+ export declare const querySpan: (h: BlastHsp) => [number, number];
53
+ /** Percentage of the query covered by the union of the hit's HSPs. */
54
+ export declare function hitCoverage(hit: BlastHit, queryLen: number): number;
55
+ export interface TooltipState {
56
+ visible: boolean;
57
+ /** Pointer position in viewport coordinates. */
58
+ x: number;
59
+ y: number;
60
+ data: {
61
+ title: string;
62
+ accession: string;
63
+ bitScore: number;
64
+ evalue: number;
65
+ identity: number;
66
+ coverage: number;
67
+ qFrom: number;
68
+ qTo: number;
69
+ hFrom: number;
70
+ hTo: number;
71
+ } | null;
72
+ }