@platforma-sdk/ui-vue 1.30.25 → 1.30.37
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/CHANGELOG.md +17 -0
- package/dist/assets/chemical-properties.worker-thYtrBDn.js.map +1 -0
- package/dist/lib.js +11619 -10406
- package/dist/lib.js.map +1 -1
- package/dist/lib.umd.cjs +36 -29
- package/dist/lib.umd.cjs.map +1 -1
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts +2 -1
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/PlAgDataTableV2.vue.d.ts +12 -12
- package/dist/src/components/PlAgDataTable/PlAgDataTableV2.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/sources/common.d.ts +6 -16
- package/dist/src/components/PlAgDataTable/sources/common.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/sources/table-source-v2.d.ts +13 -4
- package/dist/src/components/PlAgDataTable/sources/table-source-v2.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/sources/table-source.d.ts +12 -3
- package/dist/src/components/PlAgDataTable/sources/table-source.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/types.d.ts +25 -5
- package/dist/src/components/PlAgDataTable/types.d.ts.map +1 -1
- package/dist/src/components/PlMultiSequenceAlignment/MultiSequenceAlignmentView.vue.d.ts +8 -0
- package/dist/src/components/PlMultiSequenceAlignment/MultiSequenceAlignmentView.vue.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/PlMultiSequenceAlignment.vue.d.ts +40 -0
- package/dist/src/components/PlMultiSequenceAlignment/PlMultiSequenceAlignment.vue.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/data.d.ts +86 -0
- package/dist/src/components/PlMultiSequenceAlignment/data.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/chemical-properties.d.ts +19 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/chemical-properties.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/chemical-properties.worker.d.ts +9 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/chemical-properties.worker.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/index.d.ts +7 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/index.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/types.d.ts +6 -0
- package/dist/src/components/PlMultiSequenceAlignment/highlight/types.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/index.d.ts +2 -0
- package/dist/src/components/PlMultiSequenceAlignment/index.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/multi-sequence-alignment.d.ts +7 -0
- package/dist/src/components/PlMultiSequenceAlignment/multi-sequence-alignment.d.ts.map +1 -0
- package/dist/src/components/PlMultiSequenceAlignment/types.d.ts +6 -0
- package/dist/src/components/PlMultiSequenceAlignment/types.d.ts.map +1 -0
- package/dist/src/lib.d.ts +1 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +13 -11
- package/src/components/PlAgDataTable/PlAgDataTable.vue +8 -7
- package/src/components/PlAgDataTable/PlAgDataTableV2.vue +157 -86
- package/src/components/PlAgDataTable/sources/common.ts +7 -101
- package/src/components/PlAgDataTable/sources/table-source-v2.ts +106 -11
- package/src/components/PlAgDataTable/sources/table-source.ts +95 -2
- package/src/components/PlAgDataTable/types.ts +29 -5
- package/src/components/PlMultiSequenceAlignment/MultiSequenceAlignmentView.vue +135 -0
- package/src/components/PlMultiSequenceAlignment/PlMultiSequenceAlignment.vue +173 -0
- package/src/components/PlMultiSequenceAlignment/data.ts +404 -0
- package/src/components/PlMultiSequenceAlignment/highlight/chemical-properties.ts +72 -0
- package/src/components/PlMultiSequenceAlignment/highlight/chemical-properties.worker.ts +191 -0
- package/src/components/PlMultiSequenceAlignment/highlight/index.ts +25 -0
- package/src/components/PlMultiSequenceAlignment/highlight/types.ts +5 -0
- package/src/components/PlMultiSequenceAlignment/index.ts +1 -0
- package/src/components/PlMultiSequenceAlignment/multi-sequence-alignment.ts +134 -0
- package/src/components/PlMultiSequenceAlignment/types.ts +5 -0
- package/src/lib.ts +2 -0
- package/src/vite-env.d.ts +13 -0
- package/tsconfig.lib.json +3 -1
- package/vite.config.ts +5 -2
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import Aioli from '@biowasm/aioli';
|
|
2
|
+
import {
|
|
3
|
+
type MaybeRefOrGetter,
|
|
4
|
+
onWatcherCleanup,
|
|
5
|
+
reactive,
|
|
6
|
+
toValue,
|
|
7
|
+
watchEffect,
|
|
8
|
+
} from 'vue';
|
|
9
|
+
import type { SequenceRow } from './types';
|
|
10
|
+
|
|
11
|
+
export function useAlignedRows(sequenceRows: MaybeRefOrGetter<SequenceRow[]>) {
|
|
12
|
+
const alignment = reactive({
|
|
13
|
+
value: new Map<string, string>(),
|
|
14
|
+
loading: false,
|
|
15
|
+
});
|
|
16
|
+
watchEffect(async () => {
|
|
17
|
+
const inputRows = toValue(sequenceRows);
|
|
18
|
+
let aborted = false;
|
|
19
|
+
onWatcherCleanup(() => {
|
|
20
|
+
aborted = true;
|
|
21
|
+
});
|
|
22
|
+
try {
|
|
23
|
+
alignment.loading = true;
|
|
24
|
+
const value = await multiSequenceAlignment(inputRows);
|
|
25
|
+
if (aborted) return;
|
|
26
|
+
alignment.value = value;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
alignment.value.clear();
|
|
30
|
+
} finally {
|
|
31
|
+
alignment.loading = false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return alignment;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const cache = new Map<string, Map<string, string>>();
|
|
38
|
+
|
|
39
|
+
async function multiSequenceAlignment(
|
|
40
|
+
sequenceRows: SequenceRow[],
|
|
41
|
+
): Promise<Map<string, string>> {
|
|
42
|
+
const inputHash = await hash(sequenceRows);
|
|
43
|
+
let result = cache.get(inputHash);
|
|
44
|
+
if (result) {
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
const CLI = await new Aioli(['kalign/3.3.1']);
|
|
48
|
+
const file = new File(
|
|
49
|
+
sequenceRows.map((row) => `>${row.header}\n${row.sequence}\n`),
|
|
50
|
+
'input',
|
|
51
|
+
);
|
|
52
|
+
await CLI.mount(file);
|
|
53
|
+
await CLI.exec('kalign -f fasta -i input -o output');
|
|
54
|
+
const output = await CLI.cat('output');
|
|
55
|
+
result = parseKalignOutput(output);
|
|
56
|
+
cache.set(inputHash, result);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function parseKalignOutput(output: string): Map<string, string> {
|
|
61
|
+
const result = new Map<string, string>();
|
|
62
|
+
let lastHeader = '';
|
|
63
|
+
for (let line of output.split('\n')) {
|
|
64
|
+
line = line.trim();
|
|
65
|
+
if (!line) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (line.startsWith('>')) {
|
|
69
|
+
const header = line.slice(1);
|
|
70
|
+
result.set(header, '');
|
|
71
|
+
lastHeader = header;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const sequence = result.get(lastHeader);
|
|
75
|
+
if (sequence === undefined) {
|
|
76
|
+
throw new Error('Malformed kalign output, aborting.');
|
|
77
|
+
}
|
|
78
|
+
result.set(lastHeader, sequence + line);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function hash(rows: SequenceRow[]): Promise<string> {
|
|
84
|
+
const encoder = new TextEncoder();
|
|
85
|
+
const decoder = new TextDecoder();
|
|
86
|
+
const sha256 = (input: BufferSource) =>
|
|
87
|
+
crypto.subtle.digest('SHA-256', input);
|
|
88
|
+
const chunks = await Promise.all(rows.map(
|
|
89
|
+
({ header, sequence }) => sha256(encoder.encode(`${header} ${sequence}`)),
|
|
90
|
+
));
|
|
91
|
+
const data = chunks.reduce<Uint8Array>((acc, chunk, index) => {
|
|
92
|
+
acc.set(new Uint8Array(chunk), index * 32);
|
|
93
|
+
return acc;
|
|
94
|
+
}, new Uint8Array(chunks.length * 32));
|
|
95
|
+
return decoder.decode(await sha256(data));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (import.meta.vitest) {
|
|
99
|
+
const { test, expect } = import.meta.vitest;
|
|
100
|
+
|
|
101
|
+
test('parseKalignOutput', () => {
|
|
102
|
+
const serialized = `>1aab_
|
|
103
|
+
GKGDPKKPRG-KMSSYAFFVQTSREEHKKKHPDASVNFSEFSKKCSERWKTMSAKEKGKF
|
|
104
|
+
EDMAKADKARYEREMKTY-IPPKGE---------
|
|
105
|
+
>1j46_A
|
|
106
|
+
-----MQDRV-KRPMNAFIVWSRDQRRKMALENPRMRNSEISKQLGYQWKMLTEAEKWPF
|
|
107
|
+
FQEAQKLQAMHREKYPNYKYRPRRKAKMLPK---
|
|
108
|
+
>1k99_A
|
|
109
|
+
MKKLKKHPDFPKKPLTPYFRFFMEKRAKYAKLHPEMSNLDLTKILSKKYKELPEKKKMKY
|
|
110
|
+
IQDFQREKQ-EFERNLARFREDHPDLIQNAKK--
|
|
111
|
+
>2lef_A
|
|
112
|
+
-----MHI---KKPLNAFMLYMKEMRANVVAESTLKESAAINQILGRRWHALSREEQAKY
|
|
113
|
+
YELARKERQLHMQLYPGWSARDNYGKKKKRKREK`;
|
|
114
|
+
const parsed = new Map([
|
|
115
|
+
[
|
|
116
|
+
'1aab_',
|
|
117
|
+
'GKGDPKKPRG-KMSSYAFFVQTSREEHKKKHPDASVNFSEFSKKCSERWKTMSAKEKGKFEDMAKADKARYEREMKTY-IPPKGE---------',
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
'1j46_A',
|
|
121
|
+
'-----MQDRV-KRPMNAFIVWSRDQRRKMALENPRMRNSEISKQLGYQWKMLTEAEKWPFFQEAQKLQAMHREKYPNYKYRPRRKAKMLPK---',
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
'1k99_A',
|
|
125
|
+
'MKKLKKHPDFPKKPLTPYFRFFMEKRAKYAKLHPEMSNLDLTKILSKKYKELPEKKKMKYIQDFQREKQ-EFERNLARFREDHPDLIQNAKK--',
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
'2lef_A',
|
|
129
|
+
'-----MHI---KKPLNAFMLYMKEMRANVVAESTLKESAAINQILGRRWHALSREEQAKYYELARKERQLHMQLYPGWSARDNYGKKKKRKREK',
|
|
130
|
+
],
|
|
131
|
+
]);
|
|
132
|
+
expect(parseKalignOutput(serialized)).toEqual(parsed);
|
|
133
|
+
});
|
|
134
|
+
}
|
package/src/lib.ts
CHANGED
package/src/vite-env.d.ts
CHANGED
|
@@ -6,3 +6,16 @@
|
|
|
6
6
|
// const component: DefineComponent<{}, {}, any>;
|
|
7
7
|
// export default component;
|
|
8
8
|
// }
|
|
9
|
+
|
|
10
|
+
type Mount = File | { name: string; data: Blob | string };
|
|
11
|
+
|
|
12
|
+
declare module '@biowasm/aioli' {
|
|
13
|
+
class Aioli {
|
|
14
|
+
constructor(tools: string[]);
|
|
15
|
+
mount(mounts: Mount | Mount[]): Promise<void>;
|
|
16
|
+
exec(command: string): Promise<string>;
|
|
17
|
+
cat(filename: string): Promise<string>;
|
|
18
|
+
// Add any other methods used or known
|
|
19
|
+
}
|
|
20
|
+
export default Aioli;
|
|
21
|
+
}
|
package/tsconfig.lib.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
1
|
import vue from '@vitejs/plugin-vue';
|
|
3
|
-
import sourcemaps from 'rollup-plugin-sourcemaps2';
|
|
4
2
|
import { resolve } from 'path';
|
|
3
|
+
import sourcemaps from 'rollup-plugin-sourcemaps2';
|
|
4
|
+
import { defineConfig } from 'vite';
|
|
5
5
|
|
|
6
6
|
// https://vitejs.dev/config/
|
|
7
7
|
export default defineConfig({
|
|
@@ -37,4 +37,7 @@ export default defineConfig({
|
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
+
define: {
|
|
41
|
+
'import.meta.vitest': 'undefined',
|
|
42
|
+
},
|
|
40
43
|
});
|