@lipme/vue-blast-viewer 1.0.3 → 1.0.5

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 (39) hide show
  1. package/dist/App.vue.d.ts +3 -0
  2. package/dist/components/BlastAlignmentDetails.vue.d.ts +10 -0
  3. package/dist/components/BlastGraphicViewer.vue.d.ts +12 -0
  4. package/dist/components/BlastHeader.vue.d.ts +11 -0
  5. package/dist/components/BlastHitTable.vue.d.ts +13 -0
  6. package/dist/components/BlastViewer.vue.d.ts +10 -0
  7. package/dist/main.d.ts +1 -0
  8. package/dist/mockData.d.ts +3 -0
  9. package/dist/types.d.ts +53 -0
  10. package/dist/vue-blast-viewer.css +2 -0
  11. package/dist/vue-blast-viewer.js +670 -0
  12. package/dist/vue-blast-viewer.umd.cjs +2 -0
  13. package/package.json +18 -15
  14. package/.vscode/extensions.json +0 -3
  15. package/index.html +0 -13
  16. package/lipme-vue-blast-viewer-1.0.0.tgz +0 -0
  17. package/lipme-vue-blast-viewer-1.0.1.tgz +0 -0
  18. package/lipme-vue-blast-viewer-1.0.2.tgz +0 -0
  19. package/lipme-vue-blast-viewer-1.0.3.tgz +0 -0
  20. package/public/favicon.svg +0 -1
  21. package/public/icons.svg +0 -24
  22. package/src/App.vue +0 -548
  23. package/src/assets/hero.png +0 -0
  24. package/src/assets/vite.svg +0 -1
  25. package/src/assets/vue.svg +0 -1
  26. package/src/components/BlastAlignmentDetails.vue +0 -581
  27. package/src/components/BlastGraphicViewer.vue +0 -477
  28. package/src/components/BlastHeader.vue +0 -259
  29. package/src/components/BlastHitTable.vue +0 -669
  30. package/src/components/BlastViewer.vue +0 -232
  31. package/src/main.ts +0 -5
  32. package/src/mockData.ts +0 -457
  33. package/src/style.css +0 -258
  34. package/src/types.ts +0 -59
  35. package/tsconfig.app.json +0 -14
  36. package/tsconfig.json +0 -28
  37. package/vite.config.ts +0 -24
  38. package/vue-blast-viewer-1.0.0.tgz +0 -0
  39. /package/{src/index.ts → dist/index.d.ts} +0 -0
@@ -1,581 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref, watch, onMounted, nextTick } from 'vue';
3
- import type { BlastSearch, BlastHsp } from '../types';
4
-
5
- const props = defineProps<{
6
- searchData: BlastSearch;
7
- isProtein: boolean;
8
- selectedHitNum: number | null;
9
- subjectLink?: string;
10
- }>();
11
-
12
- // Expanded hits state (track by hit number)
13
- const expandedHits = ref<Record<number, boolean>>({});
14
-
15
- // Keep track of DOM elements for scrolling
16
- const hitRefs = ref<Record<number, HTMLElement | null>>({});
17
-
18
- // Track the highlighted hit that was recently clicked
19
- const activeHighlightedHit = ref<number | null>(null);
20
-
21
- // Initialize: Expand the first hit by default
22
- onMounted(() => {
23
- if (props.searchData.hits.length > 0) {
24
- expandedHits.value[props.searchData.hits[0].num] = true;
25
- }
26
- });
27
-
28
- // Scroll to a selected hit when it changes
29
- watch(() => props.selectedHitNum, async (newVal) => {
30
- if (newVal !== null) {
31
- // 1. Expand the hit
32
- expandedHits.value[newVal] = true;
33
-
34
- // 2. Clear highlighting on others, set on this one
35
- activeHighlightedHit.value = newVal;
36
-
37
- // 3. Scroll to the element after DOM updates
38
- await nextTick();
39
- const el = hitRefs.value[newVal];
40
- if (el) {
41
- el.scrollIntoView({ behavior: 'smooth', block: 'center' });
42
-
43
- // Remove highlighting after a short delay
44
- setTimeout(() => {
45
- if (activeHighlightedHit.value === newVal) {
46
- activeHighlightedHit.value = null;
47
- }
48
- }, 2500);
49
- }
50
- }
51
- });
52
-
53
- // Set reference function for v-for
54
- const setHitRef = (num: number, el: any) => {
55
- if (el) {
56
- hitRefs.value[num] = el as HTMLElement;
57
- }
58
- };
59
-
60
- // Toggle expanded state
61
- const toggleHit = (num: number) => {
62
- expandedHits.value[num] = !expandedHits.value[num];
63
- };
64
-
65
- // Alignment Block Generator (splits into 60-char blocks with correct coords)
66
- interface AlignmentChar {
67
- q: string;
68
- h: string;
69
- m: string;
70
- type: 'match' | 'positive' | 'mismatch' | 'gap';
71
- }
72
-
73
- interface AlignmentBlock {
74
- queryStart: number;
75
- queryEnd: number;
76
- sbjctStart: number;
77
- sbjctEnd: number;
78
- columns: AlignmentChar[];
79
- }
80
-
81
- const getAlignmentBlocks = (hsp: BlastHsp): AlignmentBlock[] => {
82
- const blockSize = 60;
83
- const qSeq = hsp.qseq;
84
- const hSeq = hsp.hseq;
85
- const midline = hsp.midline;
86
- const totalLen = qSeq.length;
87
-
88
- const blocks: AlignmentBlock[] = [];
89
-
90
- let qCoord = hsp.query_from;
91
- let sCoord = hsp.hit_from;
92
-
93
- const isReverse = hsp.hit_strand === 'minus' || hsp.hit_to < hsp.hit_from;
94
-
95
- for (let b = 0; b < totalLen; b += blockSize) {
96
- const endIdx = Math.min(b + blockSize, totalLen);
97
- const columns: AlignmentChar[] = [];
98
-
99
- const queryStart = qCoord;
100
- const sbjctStart = sCoord;
101
-
102
- let queryCharsInBlock = 0;
103
- let sbjctCharsInBlock = 0;
104
-
105
- for (let i = b; i < endIdx; i++) {
106
- const qChar = qSeq[i];
107
- const hChar = hSeq[i];
108
- let mChar = midline[i] || ' ';
109
-
110
- let type: 'match' | 'positive' | 'mismatch' | 'gap' = 'mismatch';
111
- if (qChar === '-' || hChar === '-') {
112
- type = 'gap';
113
- } else if (mChar === '|') {
114
- type = 'match';
115
- } else if (mChar === '+') {
116
- type = 'positive';
117
- } else if (qChar === hChar) {
118
- mChar = '|';
119
- type = 'match';
120
- }
121
-
122
- columns.push({ q: qChar, h: hChar, m: mChar, type });
123
-
124
- // Increment query coord if not gap
125
- if (qChar !== '-') {
126
- qCoord++;
127
- queryCharsInBlock++;
128
- }
129
-
130
- // Increment/decrement subject coord if not gap
131
- if (hChar !== '-') {
132
- if (isReverse) {
133
- sCoord--;
134
- } else {
135
- sCoord++;
136
- }
137
- sbjctCharsInBlock++;
138
- }
139
- }
140
-
141
- const queryEnd = queryStart + (queryCharsInBlock > 0 ? queryCharsInBlock - 1 : 0);
142
- const sbjctEnd = isReverse
143
- ? sbjctStart - (sbjctCharsInBlock > 0 ? sbjctCharsInBlock - 1 : 0)
144
- : sbjctStart + (sbjctCharsInBlock > 0 ? sbjctCharsInBlock - 1 : 0);
145
-
146
- blocks.push({
147
- queryStart,
148
- queryEnd,
149
- sbjctStart,
150
- sbjctEnd,
151
- columns
152
- });
153
- }
154
-
155
- return blocks;
156
- };
157
-
158
- const formatEvalue = (val: number) => {
159
- if (val === 0) return '0.0';
160
- if (val < 0.001) return val.toExponential(2);
161
- return val.toFixed(4);
162
- };
163
-
164
- const getSubjectLink = (accession: string) => {
165
- if (props.subjectLink) {
166
- return props.subjectLink.replace('{accession}', accession);
167
- }
168
- const db = props.isProtein ? 'protein' : 'nucleotide';
169
- return `https://www.ncbi.nlm.nih.gov/${db}/${accession}`;
170
- };
171
- </script>
172
-
173
- <template>
174
- <div class="blast-alignments fade-in">
175
- <div class="alignments-title">
176
- <h2>Detailed Pairwise Alignments</h2>
177
- <p>Click headers to collapse/expand. Matching bases/residues are color-highlighted.</p>
178
- </div>
179
-
180
- <!-- Alignments List -->
181
- <div class="hit-alignments-list">
182
- <div
183
- v-for="(hit, idx) in searchData.hits"
184
- :key="hit.num"
185
- :ref="(el: any) => setHitRef(hit.num, el)"
186
- class="hit-alignment-card glass-panel"
187
- :class="{
188
- 'expanded': expandedHits[hit.num],
189
- 'highlighted-flash': activeHighlightedHit === hit.num
190
- }"
191
- >
192
- <!-- Header Toggle Bar -->
193
- <div class="alignment-card-header" @click="toggleHit(hit.num)">
194
- <div class="header-desc">
195
- <span class="chevron-icon" :class="{ 'open': expandedHits[hit.num] }">▶</span>
196
- <div class="hit-title-box">
197
- <span class="hit-index-badge">Hit {{ idx + 1 }}</span>
198
- <span class="hit-main-title">{{ hit.description[0].title }}</span>
199
- </div>
200
- </div>
201
- <div class="header-meta">
202
- <a :href="getSubjectLink(hit.description[0].accession)" target="_blank" class="accession-badge sequence-font" @click.stop>{{ hit.description[0].accession }}</a>
203
- <span class="length-badge">Length: {{ hit.len }}</span>
204
- </div>
205
- </div>
206
-
207
- <!-- Expanded Alignment Content -->
208
- <div v-if="expandedHits[hit.num]" class="alignment-card-content">
209
- <div v-for="hsp in hit.hsps" :key="hsp.num" class="hsp-alignment-box">
210
-
211
- <!-- HSP Stats Banner -->
212
- <div class="hsp-stats-banner">
213
- <div class="hsp-banner-title">HSP {{ hsp.num }}</div>
214
- <div class="hsp-stats-grid">
215
- <div class="hsp-stat-item">
216
- <span class="lbl">Score:</span>
217
- <span class="val sequence-font">{{ hsp.bit_score.toFixed(1) }} bits ({{ hsp.score }})</span>
218
- </div>
219
- <div class="hsp-stat-item">
220
- <span class="lbl">Expect:</span>
221
- <span class="val sequence-font">{{ formatEvalue(hsp.evalue) }}</span>
222
- </div>
223
- <div class="hsp-stat-item">
224
- <span class="lbl">Identities:</span>
225
- <span class="val sequence-font">
226
- {{ hsp.identity }}/{{ hsp.align_len }} ({{ Math.round((hsp.identity / hsp.align_len) * 100) }}%)
227
- </span>
228
- </div>
229
- <div class="hsp-stat-item" v-if="hsp.gaps > 0">
230
- <span class="lbl">Gaps:</span>
231
- <span class="val sequence-font">{{ hsp.gaps }}/{{ hsp.align_len }} ({{ Math.round((hsp.gaps / hsp.align_len) * 100) }}%)</span>
232
- </div>
233
- <div class="hsp-stat-item" v-if="hsp.query_strand || hsp.hit_strand">
234
- <span class="lbl">Strand:</span>
235
- <span class="val sequence-font">{{ hsp.query_strand }} / {{ hsp.hit_strand }}</span>
236
- </div>
237
- </div>
238
- </div>
239
-
240
- <!-- Sequence Alignment Render -->
241
- <div class="sequence-alignment-area">
242
- <div
243
- v-for="(block, bIdx) in getAlignmentBlocks(hsp)"
244
- :key="bIdx"
245
- class="alignment-block"
246
- >
247
- <!-- Query line -->
248
- <div class="alignment-line query-line">
249
- <span class="line-label">Query</span>
250
- <span class="line-coord start-coord sequence-font">{{ block.queryStart }}</span>
251
- <span class="line-chars sequence-font">
252
- <span
253
- v-for="(col, cIdx) in block.columns"
254
- :key="cIdx"
255
- class="char-cell"
256
- :class="col.type"
257
- >{{ col.q }}</span>
258
- </span>
259
- <span class="line-coord end-coord sequence-font">{{ block.queryEnd }}</span>
260
- </div>
261
-
262
- <!-- Midline (connective annotations) -->
263
- <div class="alignment-line midline">
264
- <span class="line-label"></span>
265
- <span class="line-coord start-coord"></span>
266
- <span class="line-chars sequence-font">
267
- <span
268
- v-for="(col, cIdx) in block.columns"
269
- :key="cIdx"
270
- class="char-cell"
271
- :class="col.type"
272
- >
273
- <!-- Display a vertical line for exact match, '+' for protein positives, or space -->
274
- {{ col.m === '|' ? '│' : (col.m === '+' ? '┿' : ' ') }}
275
- </span>
276
- </span>
277
- <span class="line-coord end-coord"></span>
278
- </div>
279
-
280
- <!-- Subject line -->
281
- <div class="alignment-line sbjct-line">
282
- <span class="line-label">Sbjct</span>
283
- <span class="line-coord start-coord sequence-font">{{ block.sbjctStart }}</span>
284
- <span class="line-chars sequence-font">
285
- <span
286
- v-for="(col, cIdx) in block.columns"
287
- :key="cIdx"
288
- class="char-cell"
289
- :class="col.type"
290
- >{{ col.h }}</span>
291
- </span>
292
- <span class="line-coord end-coord sequence-font">{{ block.sbjctEnd }}</span>
293
- </div>
294
- </div>
295
- </div>
296
-
297
- </div>
298
- </div>
299
- </div>
300
- </div>
301
- </div>
302
- </template>
303
-
304
- <style scoped>
305
- .blast-alignments {
306
- display: flex;
307
- flex-direction: column;
308
- gap: 1.25rem;
309
- }
310
-
311
- .alignments-title h2 {
312
- font-size: 1.15rem;
313
- font-weight: 600;
314
- margin-bottom: 0.25rem;
315
- }
316
-
317
- .alignments-title p {
318
- font-size: 0.85rem;
319
- color: var(--text-secondary);
320
- }
321
-
322
- .hit-alignments-list {
323
- display: flex;
324
- flex-direction: column;
325
- gap: 1rem;
326
- }
327
-
328
- .hit-alignment-card {
329
- border-radius: var(--radius-md);
330
- overflow: hidden;
331
- transition: all var(--transition-normal);
332
- }
333
-
334
- .hit-alignment-card.highlighted-flash {
335
- box-shadow: 0 0 25px var(--color-primary-glow), inset 0 0 15px rgba(59, 130, 246, 0.2);
336
- border-color: var(--color-primary);
337
- animation: pulse-glow 2.5s infinite;
338
- }
339
-
340
- .alignment-card-header {
341
- display: flex;
342
- justify-content: space-between;
343
- align-items: center;
344
- padding: 1rem 1.25rem;
345
- cursor: pointer;
346
- background: var(--bg-overlay-1);
347
- user-select: none;
348
- }
349
-
350
- .alignment-card-header:hover {
351
- background: var(--bg-overlay-hover);
352
- }
353
-
354
- .header-desc {
355
- display: flex;
356
- align-items: center;
357
- gap: 0.75rem;
358
- min-width: 0; /* allows text truncation */
359
- }
360
-
361
- .chevron-icon {
362
- font-size: 0.65rem;
363
- color: var(--text-secondary);
364
- transition: transform var(--transition-fast);
365
- display: inline-block;
366
- }
367
-
368
- .chevron-icon.open {
369
- transform: rotate(90deg);
370
- color: var(--color-primary);
371
- }
372
-
373
- .hit-title-box {
374
- display: flex;
375
- align-items: center;
376
- gap: 0.75rem;
377
- min-width: 0;
378
- }
379
-
380
- .hit-index-badge {
381
- background: var(--bg-overlay-1);
382
- color: var(--text-secondary);
383
- font-size: 0.75rem;
384
- font-weight: 600;
385
- padding: 0.15rem 0.5rem;
386
- border-radius: 4px;
387
- flex-shrink: 0;
388
- }
389
-
390
- .hit-main-title {
391
- font-weight: 600;
392
- color: var(--text-primary);
393
- overflow: hidden;
394
- text-overflow: ellipsis;
395
- white-space: nowrap;
396
- }
397
-
398
- .header-meta {
399
- display: flex;
400
- align-items: center;
401
- gap: 0.75rem;
402
- flex-shrink: 0;
403
- }
404
-
405
- .accession-badge {
406
- background: var(--color-primary-glow);
407
- color: var(--color-primary);
408
- font-size: 0.75rem;
409
- font-weight: 600;
410
- padding: 0.15rem 0.5rem;
411
- border-radius: 4px;
412
- }
413
-
414
- .length-badge {
415
- font-size: 0.75rem;
416
- color: var(--text-muted);
417
- }
418
-
419
- .alignment-card-content {
420
- border-top: 1px solid var(--border-color);
421
- padding: 1.5rem;
422
- background: var(--bg-depth-light);
423
- display: flex;
424
- flex-direction: column;
425
- gap: 2rem;
426
- }
427
-
428
- .hsp-alignment-box {
429
- display: flex;
430
- flex-direction: column;
431
- gap: 1.25rem;
432
- }
433
-
434
- .hsp-alignment-box:not(:last-child) {
435
- border-bottom: 1px dashed var(--border-color);
436
- padding-bottom: 2rem;
437
- }
438
-
439
- .hsp-stats-banner {
440
- background: var(--bg-depth);
441
- border: 1px solid var(--border-color);
442
- border-radius: var(--radius-sm);
443
- padding: 0.75rem 1rem;
444
- display: flex;
445
- flex-direction: column;
446
- gap: 0.35rem;
447
- }
448
-
449
- .hsp-banner-title {
450
- font-weight: 700;
451
- font-size: 0.85rem;
452
- color: var(--color-primary);
453
- }
454
-
455
- .hsp-stats-grid {
456
- display: flex;
457
- flex-wrap: wrap;
458
- gap: 1.5rem;
459
- }
460
-
461
- .hsp-stat-item {
462
- font-size: 0.8rem;
463
- display: flex;
464
- gap: 0.35rem;
465
- }
466
-
467
- .hsp-stat-item .lbl {
468
- color: var(--text-secondary);
469
- }
470
-
471
- .hsp-stat-item .val {
472
- font-weight: 600;
473
- color: var(--text-primary);
474
- }
475
-
476
- .sequence-alignment-area {
477
- display: flex;
478
- flex-direction: column;
479
- gap: 1.25rem;
480
- padding: 1rem;
481
- background: var(--bg-depth);
482
- border-radius: var(--radius-sm);
483
- overflow-x: auto;
484
- border: 1px solid var(--bg-overlay-hover);
485
- }
486
-
487
- .alignment-block {
488
- display: flex;
489
- flex-direction: column;
490
- gap: 0.15rem;
491
- min-width: fit-content;
492
- }
493
-
494
- .alignment-line {
495
- display: flex;
496
- align-items: center;
497
- }
498
-
499
- .line-label {
500
- width: 50px;
501
- font-size: 0.75rem;
502
- font-weight: 600;
503
- color: var(--text-secondary);
504
- user-select: none;
505
- }
506
-
507
- .line-coord {
508
- width: 50px;
509
- font-size: 0.8rem;
510
- color: var(--text-muted);
511
- user-select: none;
512
- }
513
-
514
- .start-coord {
515
- text-align: right;
516
- padding-right: 12px;
517
- }
518
-
519
- .end-coord {
520
- text-align: left;
521
- padding-left: 12px;
522
- }
523
-
524
- .line-chars {
525
- display: flex;
526
- font-size: 0.95rem;
527
- font-weight: 500;
528
- }
529
-
530
- .char-cell {
531
- width: 11px;
532
- height: 20px;
533
- display: inline-flex;
534
- align-items: center;
535
- justify-content: center;
536
- text-align: center;
537
- transition: background-color var(--transition-fast);
538
- }
539
-
540
- /* Character level highlighting */
541
- .query-line .char-cell.match,
542
- .sbjct-line .char-cell.match {
543
- color: var(--text-primary);
544
- background-color: rgba(16, 185, 129, 0.06);
545
- }
546
-
547
- .query-line .char-cell.positive,
548
- .sbjct-line .char-cell.positive {
549
- color: var(--text-primary);
550
- background-color: rgba(139, 92, 246, 0.06);
551
- }
552
-
553
- .query-line .char-cell.mismatch,
554
- .sbjct-line .char-cell.mismatch {
555
- color: #fb923c; /* soft orange */
556
- background-color: rgba(251, 146, 60, 0.05);
557
- }
558
-
559
- .query-line .char-cell.gap,
560
- .sbjct-line .char-cell.gap {
561
- color: var(--color-danger);
562
- background-color: rgba(239, 68, 68, 0.12);
563
- font-weight: 700;
564
- }
565
-
566
- .midline .char-cell {
567
- color: var(--text-muted);
568
- opacity: 0.4;
569
- font-size: 0.7rem;
570
- }
571
-
572
- .midline .char-cell.match {
573
- color: var(--color-success);
574
- opacity: 0.85;
575
- }
576
-
577
- .midline .char-cell.positive {
578
- color: var(--color-secondary);
579
- opacity: 0.85;
580
- }
581
- </style>