jbrowse-plugin-msaview 2.6.0 → 2.6.2
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/dist/LaunchMsaViewExtensionPoint/index.js +9 -19
- package/dist/MsaViewPanel/afterCreateAutoruns.js +18 -31
- package/dist/MsaViewPanel/fetchIndexedMsa.d.ts +6 -0
- package/dist/MsaViewPanel/fetchIndexedMsa.js +36 -0
- package/dist/MsaViewPanel/types.d.ts +2 -5
- package/dist/jbrowse-plugin-msaview.umd.production.min.js +26 -27
- package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/LaunchMsaViewExtensionPoint/index.ts +42 -60
- package/src/MsaViewPanel/afterCreateAutoruns.ts +27 -42
- package/src/MsaViewPanel/fetchIndexedMsa.ts +47 -0
- package/src/MsaViewPanel/types.ts +10 -8
- package/src/version.ts +1 -1
- package/dist/MsaViewPanel/fetchTabixMsa.d.ts +0 -12
- package/dist/MsaViewPanel/fetchTabixMsa.js +0 -33
- package/src/MsaViewPanel/fetchTabixMsa.ts +0 -50
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.6.
|
|
1
|
+
export declare const version = "2.6.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.6.
|
|
1
|
+
export const version = '2.6.2';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.6.
|
|
2
|
+
"version": "2.6.2",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "jbrowse-plugin-msaview",
|
|
5
5
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@emotion/styled": "^11.14.1",
|
|
20
|
-
"@gmod/
|
|
20
|
+
"@gmod/bgzf-filehandle": "^6.2.0",
|
|
21
21
|
"g2p_mapper": "^2.1.5",
|
|
22
22
|
"idb": "^8.0.3",
|
|
23
23
|
"pako-esm2": "^2.0.2",
|
|
@@ -1,86 +1,68 @@
|
|
|
1
1
|
import type PluginManager from '@jbrowse/core/PluginManager'
|
|
2
2
|
import type { AbstractSessionModel } from '@jbrowse/core/util'
|
|
3
3
|
|
|
4
|
+
interface LaunchMsaViewArgs {
|
|
5
|
+
session: AbstractSessionModel
|
|
6
|
+
data?: { msa: string; tree?: string }
|
|
7
|
+
msaFileLocation?: { uri: string }
|
|
8
|
+
msaIndexedLocation?: { uri: string }
|
|
9
|
+
msaName?: string
|
|
10
|
+
treeFileLocation?: { uri: string }
|
|
11
|
+
connectedViewId?: string
|
|
12
|
+
connectedFeature?: Record<string, unknown>
|
|
13
|
+
displayName?: string
|
|
14
|
+
colorSchemeName?: string
|
|
15
|
+
colWidth?: number
|
|
16
|
+
rowHeight?: number
|
|
17
|
+
treeAreaWidth?: number
|
|
18
|
+
treeWidth?: number
|
|
19
|
+
drawNodeBubbles?: boolean
|
|
20
|
+
labelsAlignRight?: boolean
|
|
21
|
+
showBranchLen?: boolean
|
|
22
|
+
querySeqName?: string
|
|
23
|
+
highlightColumns?: number[]
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
export default function LaunchMsaViewExtensionPointF(
|
|
5
27
|
pluginManager: PluginManager,
|
|
6
28
|
) {
|
|
7
29
|
pluginManager.addToExtensionPoint(
|
|
8
30
|
'LaunchView-MsaView',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
colWidth,
|
|
23
|
-
rowHeight,
|
|
24
|
-
treeAreaWidth,
|
|
25
|
-
treeWidth,
|
|
26
|
-
drawNodeBubbles,
|
|
27
|
-
labelsAlignRight,
|
|
28
|
-
showBranchLen,
|
|
29
|
-
querySeqName,
|
|
30
|
-
highlightColumns,
|
|
31
|
-
}: {
|
|
32
|
-
session: AbstractSessionModel
|
|
33
|
-
data?: { msa: string; tree?: string }
|
|
34
|
-
msaFileLocation?: { uri: string }
|
|
35
|
-
msaTabixLocation?: { uri: string }
|
|
36
|
-
msaIndexLocation?: { uri: string }
|
|
37
|
-
msaId?: string
|
|
38
|
-
treeFileLocation?: { uri: string }
|
|
39
|
-
connectedViewId?: string
|
|
40
|
-
connectedFeature?: Record<string, unknown>
|
|
41
|
-
displayName?: string
|
|
42
|
-
colorSchemeName?: string
|
|
43
|
-
colWidth?: number
|
|
44
|
-
rowHeight?: number
|
|
45
|
-
treeAreaWidth?: number
|
|
46
|
-
treeWidth?: number
|
|
47
|
-
drawNodeBubbles?: boolean
|
|
48
|
-
labelsAlignRight?: boolean
|
|
49
|
-
showBranchLen?: boolean
|
|
50
|
-
querySeqName?: string
|
|
51
|
-
highlightColumns?: number[]
|
|
52
|
-
}) => {
|
|
53
|
-
if (!data && !msaFileLocation && !msaTabixLocation) {
|
|
31
|
+
(args: LaunchMsaViewArgs) => {
|
|
32
|
+
const {
|
|
33
|
+
session,
|
|
34
|
+
data,
|
|
35
|
+
msaFileLocation,
|
|
36
|
+
msaIndexedLocation,
|
|
37
|
+
msaName,
|
|
38
|
+
treeFileLocation,
|
|
39
|
+
querySeqName,
|
|
40
|
+
...rest
|
|
41
|
+
} = args
|
|
42
|
+
|
|
43
|
+
if (!data && !msaFileLocation && !msaIndexedLocation) {
|
|
54
44
|
throw new Error(
|
|
55
45
|
'No MSA data or file location provided when launching MSA view',
|
|
56
46
|
)
|
|
57
47
|
}
|
|
58
48
|
|
|
49
|
+
// all data sources flow through `init` so processInit is the single place
|
|
50
|
+
// that resolves them (AlphaFold detection, native filehandle loading, etc.)
|
|
59
51
|
session.addView('MsaView', {
|
|
60
52
|
type: 'MsaView',
|
|
61
|
-
|
|
62
|
-
connectedViewId,
|
|
63
|
-
connectedFeature,
|
|
64
|
-
colorSchemeName,
|
|
65
|
-
colWidth,
|
|
66
|
-
rowHeight,
|
|
67
|
-
treeAreaWidth,
|
|
68
|
-
treeWidth,
|
|
69
|
-
drawNodeBubbles,
|
|
70
|
-
labelsAlignRight,
|
|
71
|
-
showBranchLen,
|
|
72
|
-
highlightColumns,
|
|
53
|
+
...rest,
|
|
73
54
|
init: {
|
|
74
55
|
msaData: data?.msa,
|
|
75
56
|
treeData: data?.tree,
|
|
76
57
|
msaUrl: msaFileLocation?.uri,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
msaId,
|
|
58
|
+
msaIndexedLocation,
|
|
59
|
+
msaName,
|
|
80
60
|
treeUrl: treeFileLocation?.uri,
|
|
81
61
|
querySeqName,
|
|
82
62
|
},
|
|
83
63
|
})
|
|
64
|
+
|
|
65
|
+
return args
|
|
84
66
|
},
|
|
85
67
|
)
|
|
86
68
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSession } from '@jbrowse/core/util'
|
|
2
2
|
|
|
3
3
|
import { doLaunchBlast } from './doLaunchBlast'
|
|
4
|
-
import {
|
|
4
|
+
import { fetchIndexedMsa } from './fetchIndexedMsa'
|
|
5
5
|
import { genomeToMSA } from './genomeToMSA'
|
|
6
6
|
import { loadProteinDomains } from './loadProteinDomains'
|
|
7
7
|
import {
|
|
@@ -128,22 +128,25 @@ export function autoLoadProteinDomains(self: JBrowsePluginMsaViewModel) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
// Resolve the declarative `init` launch contract once. Inline strings go straight
|
|
132
|
+
// to the data model; URLs are handed to react-msaview's native filehandle loaders
|
|
133
|
+
// (openLocation + progress + abort + CORS-proxy) rather than a hand-rolled fetch;
|
|
134
|
+
// the bgzip name-indexed block is the one source with no native loader.
|
|
131
135
|
export function processInit(self: JBrowsePluginMsaViewModel) {
|
|
132
136
|
const { init } = self
|
|
133
137
|
if (init) {
|
|
138
|
+
const {
|
|
139
|
+
msaData,
|
|
140
|
+
msaUrl,
|
|
141
|
+
msaIndexedLocation,
|
|
142
|
+
msaName,
|
|
143
|
+
treeData,
|
|
144
|
+
treeUrl,
|
|
145
|
+
querySeqName,
|
|
146
|
+
} = init
|
|
134
147
|
void (async () => {
|
|
135
148
|
try {
|
|
136
149
|
self.setError(undefined)
|
|
137
|
-
const {
|
|
138
|
-
msaData,
|
|
139
|
-
msaUrl,
|
|
140
|
-
msaTabixLocation,
|
|
141
|
-
msaIndexLocation,
|
|
142
|
-
msaId,
|
|
143
|
-
treeData,
|
|
144
|
-
treeUrl,
|
|
145
|
-
querySeqName,
|
|
146
|
-
} = init
|
|
147
150
|
|
|
148
151
|
if (msaUrl) {
|
|
149
152
|
const id = getUniprotIdFromAlphaFoldUrl(msaUrl)
|
|
@@ -152,7 +155,6 @@ export function processInit(self: JBrowsePluginMsaViewModel) {
|
|
|
152
155
|
self.setQuerySeqName('query')
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
|
|
156
158
|
if (querySeqName) {
|
|
157
159
|
self.setQuerySeqName(querySeqName)
|
|
158
160
|
}
|
|
@@ -160,42 +162,25 @@ export function processInit(self: JBrowsePluginMsaViewModel) {
|
|
|
160
162
|
if (msaData) {
|
|
161
163
|
self.setMSA(msaData)
|
|
162
164
|
} else if (msaUrl) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
msaId: msaId ?? String(feature.name),
|
|
176
|
-
refName: String(feature.refName),
|
|
177
|
-
start: Number(feature.start),
|
|
178
|
-
end: Number(feature.end),
|
|
179
|
-
})
|
|
180
|
-
if (fasta) {
|
|
181
|
-
self.setMSA(fasta)
|
|
182
|
-
} else {
|
|
183
|
-
throw new Error(
|
|
184
|
-
`No alignment for ${msaId ?? String(feature.name)} in ${msaTabixLocation.uri}`,
|
|
185
|
-
)
|
|
186
|
-
}
|
|
165
|
+
self.setMSAFilehandle({ uri: msaUrl, locationType: 'UriLocation' })
|
|
166
|
+
} else if (msaIndexedLocation && msaName) {
|
|
167
|
+
const fasta = await fetchIndexedMsa({
|
|
168
|
+
location: msaIndexedLocation,
|
|
169
|
+
name: msaName,
|
|
170
|
+
})
|
|
171
|
+
if (fasta) {
|
|
172
|
+
self.setMSA(fasta)
|
|
173
|
+
} else {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`No alignment named ${msaName} in ${msaIndexedLocation.uri}`,
|
|
176
|
+
)
|
|
187
177
|
}
|
|
188
178
|
}
|
|
189
179
|
|
|
190
180
|
if (treeData) {
|
|
191
181
|
self.setTree(treeData)
|
|
192
182
|
} else if (treeUrl) {
|
|
193
|
-
|
|
194
|
-
if (!response.ok) {
|
|
195
|
-
throw new Error(`Failed to fetch tree: ${response.status}`)
|
|
196
|
-
}
|
|
197
|
-
const data = await response.text()
|
|
198
|
-
self.setTree(data)
|
|
183
|
+
self.setTreeFilehandle({ uri: treeUrl, locationType: 'UriLocation' })
|
|
199
184
|
}
|
|
200
185
|
|
|
201
186
|
self.setInit(undefined)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BgzfFilehandle } from '@gmod/bgzf-filehandle'
|
|
2
|
+
import { openLocation } from '@jbrowse/core/util/io'
|
|
3
|
+
|
|
4
|
+
// Pull one transcript's whole multiple-alignment out of a single bgzip file
|
|
5
|
+
// keyed by NAME. Given the `.fa.gz` uri, the bgzip index (`.gzi`) and name index
|
|
6
|
+
// (`.idx`, a TSV `name<TAB>offset<TAB>length` of each block's uncompressed byte
|
|
7
|
+
// offset + length) are found by suffix. We fetch the small `.idx` once, look up
|
|
8
|
+
// the name, and random-read just that block — already valid FASTA
|
|
9
|
+
// (`>hg38\nSEQ\n>panTro4\nSEQ\n...`). One genome-scale alignment serves any gene
|
|
10
|
+
// with no per-gene files or coordinates. See react-msaview's gene-explorer.
|
|
11
|
+
export async function fetchIndexedMsa({
|
|
12
|
+
location,
|
|
13
|
+
name,
|
|
14
|
+
}: {
|
|
15
|
+
location: { uri: string }
|
|
16
|
+
name: string
|
|
17
|
+
}) {
|
|
18
|
+
const open = (uri: string) =>
|
|
19
|
+
openLocation({ uri, locationType: 'UriLocation' as const })
|
|
20
|
+
|
|
21
|
+
const idxText = await open(`${location.uri}.idx`).readFile('utf8')
|
|
22
|
+
const entry = lookup(idxText, name)
|
|
23
|
+
if (entry) {
|
|
24
|
+
const fh = new BgzfFilehandle({
|
|
25
|
+
filehandle: open(location.uri),
|
|
26
|
+
gziFilehandle: open(`${location.uri}.gzi`),
|
|
27
|
+
})
|
|
28
|
+
const bytes = await fh.read(entry.length, entry.offset)
|
|
29
|
+
return new TextDecoder().decode(bytes).trim()
|
|
30
|
+
}
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ids are matched versionless, so version drift between the alignment build and
|
|
35
|
+
// the live annotation never breaks the lookup
|
|
36
|
+
const versionless = (s: string) => s.replace(/\.\d+$/, '')
|
|
37
|
+
|
|
38
|
+
function lookup(idxText: string, name: string) {
|
|
39
|
+
const want = versionless(name)
|
|
40
|
+
for (const line of idxText.split('\n')) {
|
|
41
|
+
const [id, offset, length] = line.split('\t')
|
|
42
|
+
if (id && versionless(id) === want) {
|
|
43
|
+
return { offset: Number(offset), length: Number(length) }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined
|
|
47
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
// Declarative launch contract, resolved once by processInit. This is also a
|
|
2
|
+
// cross-repo contract: jbrowse-plugin-protein3d builds an MsaView snapshot
|
|
3
|
+
// directly with `init: { msaUrl }`, so these keys must stay stable.
|
|
1
4
|
export interface MsaViewInitState {
|
|
2
5
|
msaData?: string
|
|
3
6
|
msaUrl?: string
|
|
4
|
-
// a
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
msaId?: string
|
|
7
|
+
// a single bgzip `.fa.gz` of per-transcript FASTA blocks; its `.gzi` and name
|
|
8
|
+
// index `.idx` (name<TAB>offset<TAB>length) are found by suffix. `msaName`
|
|
9
|
+
// selects one transcript's block by name (a random read), so one genome-scale
|
|
10
|
+
// alignment serves any gene without per-gene files or coordinates. See
|
|
11
|
+
// react-msaview's gene-explorer.
|
|
12
|
+
msaIndexedLocation?: { uri: string }
|
|
13
|
+
msaName?: string
|
|
12
14
|
treeData?: string
|
|
13
15
|
treeUrl?: string
|
|
14
16
|
querySeqName?: string
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.6.
|
|
1
|
+
export const version = '2.6.2'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare function fetchTabixMsa({ location, indexLocation, msaId, refName, start, end, }: {
|
|
2
|
-
location: {
|
|
3
|
-
uri: string;
|
|
4
|
-
};
|
|
5
|
-
indexLocation?: {
|
|
6
|
-
uri: string;
|
|
7
|
-
};
|
|
8
|
-
msaId: string;
|
|
9
|
-
refName: string;
|
|
10
|
-
start: number;
|
|
11
|
-
end: number;
|
|
12
|
-
}): Promise<string | undefined>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TabixIndexedFile } from '@gmod/tabix';
|
|
2
|
-
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
|
-
// Pull one transcript's whole multiple-alignment out of a locus-keyed tabix
|
|
4
|
-
// file. Each line is `refName<TAB>start<TAB>end<TAB>msaId<TAB>packed`, where
|
|
5
|
-
// `packed` is `name:SEQ;name:SEQ;...` — no newlines, so the alignment survives
|
|
6
|
-
// as a single tabix column. We query the transcript's genomic locus, then pick
|
|
7
|
-
// the line whose msaId matches, and rebuild a FASTA string.
|
|
8
|
-
export async function fetchTabixMsa({ location, indexLocation, msaId, refName, start, end, }) {
|
|
9
|
-
const uri = (loc) => openLocation({ uri: loc.uri, locationType: 'UriLocation' });
|
|
10
|
-
const file = new TabixIndexedFile({
|
|
11
|
-
filehandle: uri(location),
|
|
12
|
-
csiFilehandle: uri(indexLocation ?? { uri: `${location.uri}.csi` }),
|
|
13
|
-
});
|
|
14
|
-
const lines = [];
|
|
15
|
-
await file.getLines(refName, start, end, {
|
|
16
|
-
lineCallback: line => {
|
|
17
|
-
lines.push(line);
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
const line = lines.find(l => l.split('\t')[3] === msaId);
|
|
21
|
-
return line ? unpack(line) : undefined;
|
|
22
|
-
}
|
|
23
|
-
function unpack(line) {
|
|
24
|
-
const packed = line.split('\t')[4] ?? '';
|
|
25
|
-
return packed
|
|
26
|
-
.split(';')
|
|
27
|
-
.filter(Boolean)
|
|
28
|
-
.map(pair => {
|
|
29
|
-
const colon = pair.indexOf(':');
|
|
30
|
-
return `>${pair.slice(0, colon)}\n${pair.slice(colon + 1)}`;
|
|
31
|
-
})
|
|
32
|
-
.join('\n');
|
|
33
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { TabixIndexedFile } from '@gmod/tabix'
|
|
2
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
3
|
-
|
|
4
|
-
// Pull one transcript's whole multiple-alignment out of a locus-keyed tabix
|
|
5
|
-
// file. Each line is `refName<TAB>start<TAB>end<TAB>msaId<TAB>packed`, where
|
|
6
|
-
// `packed` is `name:SEQ;name:SEQ;...` — no newlines, so the alignment survives
|
|
7
|
-
// as a single tabix column. We query the transcript's genomic locus, then pick
|
|
8
|
-
// the line whose msaId matches, and rebuild a FASTA string.
|
|
9
|
-
export async function fetchTabixMsa({
|
|
10
|
-
location,
|
|
11
|
-
indexLocation,
|
|
12
|
-
msaId,
|
|
13
|
-
refName,
|
|
14
|
-
start,
|
|
15
|
-
end,
|
|
16
|
-
}: {
|
|
17
|
-
location: { uri: string }
|
|
18
|
-
indexLocation?: { uri: string }
|
|
19
|
-
msaId: string
|
|
20
|
-
refName: string
|
|
21
|
-
start: number
|
|
22
|
-
end: number
|
|
23
|
-
}) {
|
|
24
|
-
const uri = (loc: { uri: string }) =>
|
|
25
|
-
openLocation({ uri: loc.uri, locationType: 'UriLocation' as const })
|
|
26
|
-
const file = new TabixIndexedFile({
|
|
27
|
-
filehandle: uri(location),
|
|
28
|
-
csiFilehandle: uri(indexLocation ?? { uri: `${location.uri}.csi` }),
|
|
29
|
-
})
|
|
30
|
-
const lines: string[] = []
|
|
31
|
-
await file.getLines(refName, start, end, {
|
|
32
|
-
lineCallback: line => {
|
|
33
|
-
lines.push(line)
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
const line = lines.find(l => l.split('\t')[3] === msaId)
|
|
37
|
-
return line ? unpack(line) : undefined
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function unpack(line: string) {
|
|
41
|
-
const packed = line.split('\t')[4] ?? ''
|
|
42
|
-
return packed
|
|
43
|
-
.split(';')
|
|
44
|
-
.filter(Boolean)
|
|
45
|
-
.map(pair => {
|
|
46
|
-
const colon = pair.indexOf(':')
|
|
47
|
-
return `>${pair.slice(0, colon)}\n${pair.slice(colon + 1)}`
|
|
48
|
-
})
|
|
49
|
-
.join('\n')
|
|
50
|
-
}
|