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
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
export default function LaunchMsaViewExtensionPointF(pluginManager) {
|
|
2
|
-
pluginManager.addToExtensionPoint('LaunchView-MsaView',
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!data && !msaFileLocation && !msaTabixLocation) {
|
|
2
|
+
pluginManager.addToExtensionPoint('LaunchView-MsaView', (args) => {
|
|
3
|
+
const { session, data, msaFileLocation, msaIndexedLocation, msaName, treeFileLocation, querySeqName, ...rest } = args;
|
|
4
|
+
if (!data && !msaFileLocation && !msaIndexedLocation) {
|
|
6
5
|
throw new Error('No MSA data or file location provided when launching MSA view');
|
|
7
6
|
}
|
|
7
|
+
// all data sources flow through `init` so processInit is the single place
|
|
8
|
+
// that resolves them (AlphaFold detection, native filehandle loading, etc.)
|
|
8
9
|
session.addView('MsaView', {
|
|
9
10
|
type: 'MsaView',
|
|
10
|
-
|
|
11
|
-
connectedViewId,
|
|
12
|
-
connectedFeature,
|
|
13
|
-
colorSchemeName,
|
|
14
|
-
colWidth,
|
|
15
|
-
rowHeight,
|
|
16
|
-
treeAreaWidth,
|
|
17
|
-
treeWidth,
|
|
18
|
-
drawNodeBubbles,
|
|
19
|
-
labelsAlignRight,
|
|
20
|
-
showBranchLen,
|
|
21
|
-
highlightColumns,
|
|
11
|
+
...rest,
|
|
22
12
|
init: {
|
|
23
13
|
msaData: data?.msa,
|
|
24
14
|
treeData: data?.tree,
|
|
25
15
|
msaUrl: msaFileLocation?.uri,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
msaId,
|
|
16
|
+
msaIndexedLocation,
|
|
17
|
+
msaName,
|
|
29
18
|
treeUrl: treeFileLocation?.uri,
|
|
30
19
|
querySeqName,
|
|
31
20
|
},
|
|
32
21
|
});
|
|
22
|
+
return args;
|
|
33
23
|
});
|
|
34
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSession } from '@jbrowse/core/util';
|
|
2
2
|
import { doLaunchBlast } from './doLaunchBlast';
|
|
3
|
-
import {
|
|
3
|
+
import { fetchIndexedMsa } from './fetchIndexedMsa';
|
|
4
4
|
import { genomeToMSA } from './genomeToMSA';
|
|
5
5
|
import { loadProteinDomains } from './loadProteinDomains';
|
|
6
6
|
import { cleanupOldData, generateDataStoreId, retrieveMsaData, storeMsaData, } from './msaDataStore';
|
|
@@ -116,13 +116,17 @@ export function autoLoadProteinDomains(self) {
|
|
|
116
116
|
})();
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
// Resolve the declarative `init` launch contract once. Inline strings go straight
|
|
120
|
+
// to the data model; URLs are handed to react-msaview's native filehandle loaders
|
|
121
|
+
// (openLocation + progress + abort + CORS-proxy) rather than a hand-rolled fetch;
|
|
122
|
+
// the bgzip name-indexed block is the one source with no native loader.
|
|
119
123
|
export function processInit(self) {
|
|
120
124
|
const { init } = self;
|
|
121
125
|
if (init) {
|
|
126
|
+
const { msaData, msaUrl, msaIndexedLocation, msaName, treeData, treeUrl, querySeqName, } = init;
|
|
122
127
|
void (async () => {
|
|
123
128
|
try {
|
|
124
129
|
self.setError(undefined);
|
|
125
|
-
const { msaData, msaUrl, msaTabixLocation, msaIndexLocation, msaId, treeData, treeUrl, querySeqName, } = init;
|
|
126
130
|
if (msaUrl) {
|
|
127
131
|
const id = getUniprotIdFromAlphaFoldUrl(msaUrl);
|
|
128
132
|
if (id) {
|
|
@@ -137,42 +141,25 @@ export function processInit(self) {
|
|
|
137
141
|
self.setMSA(msaData);
|
|
138
142
|
}
|
|
139
143
|
else if (msaUrl) {
|
|
140
|
-
|
|
141
|
-
if (!response.ok) {
|
|
142
|
-
throw new Error(`Failed to fetch MSA: ${response.status}`);
|
|
143
|
-
}
|
|
144
|
-
const data = await response.text();
|
|
145
|
-
self.setMSA(data);
|
|
144
|
+
self.setMSAFilehandle({ uri: msaUrl, locationType: 'UriLocation' });
|
|
146
145
|
}
|
|
147
|
-
else if (
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
if (fasta) {
|
|
159
|
-
self.setMSA(fasta);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
throw new Error(`No alignment for ${msaId ?? String(feature.name)} in ${msaTabixLocation.uri}`);
|
|
163
|
-
}
|
|
146
|
+
else if (msaIndexedLocation && msaName) {
|
|
147
|
+
const fasta = await fetchIndexedMsa({
|
|
148
|
+
location: msaIndexedLocation,
|
|
149
|
+
name: msaName,
|
|
150
|
+
});
|
|
151
|
+
if (fasta) {
|
|
152
|
+
self.setMSA(fasta);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
throw new Error(`No alignment named ${msaName} in ${msaIndexedLocation.uri}`);
|
|
164
156
|
}
|
|
165
157
|
}
|
|
166
158
|
if (treeData) {
|
|
167
159
|
self.setTree(treeData);
|
|
168
160
|
}
|
|
169
161
|
else if (treeUrl) {
|
|
170
|
-
|
|
171
|
-
if (!response.ok) {
|
|
172
|
-
throw new Error(`Failed to fetch tree: ${response.status}`);
|
|
173
|
-
}
|
|
174
|
-
const data = await response.text();
|
|
175
|
-
self.setTree(data);
|
|
162
|
+
self.setTreeFilehandle({ uri: treeUrl, locationType: 'UriLocation' });
|
|
176
163
|
}
|
|
177
164
|
self.setInit(undefined);
|
|
178
165
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BgzfFilehandle } from '@gmod/bgzf-filehandle';
|
|
2
|
+
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
|
+
// Pull one transcript's whole multiple-alignment out of a single bgzip file
|
|
4
|
+
// keyed by NAME. Given the `.fa.gz` uri, the bgzip index (`.gzi`) and name index
|
|
5
|
+
// (`.idx`, a TSV `name<TAB>offset<TAB>length` of each block's uncompressed byte
|
|
6
|
+
// offset + length) are found by suffix. We fetch the small `.idx` once, look up
|
|
7
|
+
// the name, and random-read just that block — already valid FASTA
|
|
8
|
+
// (`>hg38\nSEQ\n>panTro4\nSEQ\n...`). One genome-scale alignment serves any gene
|
|
9
|
+
// with no per-gene files or coordinates. See react-msaview's gene-explorer.
|
|
10
|
+
export async function fetchIndexedMsa({ location, name, }) {
|
|
11
|
+
const open = (uri) => openLocation({ uri, locationType: 'UriLocation' });
|
|
12
|
+
const idxText = await open(`${location.uri}.idx`).readFile('utf8');
|
|
13
|
+
const entry = lookup(idxText, name);
|
|
14
|
+
if (entry) {
|
|
15
|
+
const fh = new BgzfFilehandle({
|
|
16
|
+
filehandle: open(location.uri),
|
|
17
|
+
gziFilehandle: open(`${location.uri}.gzi`),
|
|
18
|
+
});
|
|
19
|
+
const bytes = await fh.read(entry.length, entry.offset);
|
|
20
|
+
return new TextDecoder().decode(bytes).trim();
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
// ids are matched versionless, so version drift between the alignment build and
|
|
25
|
+
// the live annotation never breaks the lookup
|
|
26
|
+
const versionless = (s) => s.replace(/\.\d+$/, '');
|
|
27
|
+
function lookup(idxText, name) {
|
|
28
|
+
const want = versionless(name);
|
|
29
|
+
for (const line of idxText.split('\n')) {
|
|
30
|
+
const [id, offset, length] = line.split('\t');
|
|
31
|
+
if (id && versionless(id) === want) {
|
|
32
|
+
return { offset: Number(offset), length: Number(length) };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export interface MsaViewInitState {
|
|
2
2
|
msaData?: string;
|
|
3
3
|
msaUrl?: string;
|
|
4
|
-
|
|
4
|
+
msaIndexedLocation?: {
|
|
5
5
|
uri: string;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
uri: string;
|
|
9
|
-
};
|
|
10
|
-
msaId?: string;
|
|
7
|
+
msaName?: string;
|
|
11
8
|
treeData?: string;
|
|
12
9
|
treeUrl?: string;
|
|
13
10
|
querySeqName?: string;
|