jbrowse-plugin-msaview 2.5.2 → 2.6.1
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 +4 -2
- package/dist/MsaViewPanel/afterCreateAutoruns.js +14 -1
- package/dist/MsaViewPanel/fetchIndexedMsa.d.ts +6 -0
- package/dist/MsaViewPanel/fetchIndexedMsa.js +36 -0
- package/dist/MsaViewPanel/types.d.ts +4 -0
- package/dist/jbrowse-plugin-msaview.umd.production.min.js +29 -28
- 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 -1
- package/src/LaunchMsaViewExtensionPoint/index.ts +7 -1
- package/src/MsaViewPanel/afterCreateAutoruns.ts +22 -1
- package/src/MsaViewPanel/fetchIndexedMsa.ts +47 -0
- package/src/MsaViewPanel/types.ts +7 -0
- package/src/version.ts +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default function LaunchMsaViewExtensionPointF(pluginManager) {
|
|
2
2
|
pluginManager.addToExtensionPoint('LaunchView-MsaView',
|
|
3
3
|
// @ts-expect-error
|
|
4
|
-
({ session, data, msaFileLocation, treeFileLocation, connectedViewId, connectedFeature, displayName, colorSchemeName, colWidth, rowHeight, treeAreaWidth, treeWidth, drawNodeBubbles, labelsAlignRight, showBranchLen, querySeqName, highlightColumns, }) => {
|
|
5
|
-
if (!data && !msaFileLocation) {
|
|
4
|
+
({ session, data, msaFileLocation, msaIndexedLocation, msaName, treeFileLocation, connectedViewId, connectedFeature, displayName, colorSchemeName, colWidth, rowHeight, treeAreaWidth, treeWidth, drawNodeBubbles, labelsAlignRight, showBranchLen, querySeqName, highlightColumns, }) => {
|
|
5
|
+
if (!data && !msaFileLocation && !msaIndexedLocation) {
|
|
6
6
|
throw new Error('No MSA data or file location provided when launching MSA view');
|
|
7
7
|
}
|
|
8
8
|
session.addView('MsaView', {
|
|
@@ -23,6 +23,8 @@ export default function LaunchMsaViewExtensionPointF(pluginManager) {
|
|
|
23
23
|
msaData: data?.msa,
|
|
24
24
|
treeData: data?.tree,
|
|
25
25
|
msaUrl: msaFileLocation?.uri,
|
|
26
|
+
msaIndexedLocation,
|
|
27
|
+
msaName,
|
|
26
28
|
treeUrl: treeFileLocation?.uri,
|
|
27
29
|
querySeqName,
|
|
28
30
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSession } from '@jbrowse/core/util';
|
|
2
2
|
import { doLaunchBlast } from './doLaunchBlast';
|
|
3
|
+
import { fetchIndexedMsa } from './fetchIndexedMsa';
|
|
3
4
|
import { genomeToMSA } from './genomeToMSA';
|
|
4
5
|
import { loadProteinDomains } from './loadProteinDomains';
|
|
5
6
|
import { cleanupOldData, generateDataStoreId, retrieveMsaData, storeMsaData, } from './msaDataStore';
|
|
@@ -121,7 +122,7 @@ export function processInit(self) {
|
|
|
121
122
|
void (async () => {
|
|
122
123
|
try {
|
|
123
124
|
self.setError(undefined);
|
|
124
|
-
const { msaData, msaUrl, treeData, treeUrl, querySeqName } = init;
|
|
125
|
+
const { msaData, msaUrl, msaIndexedLocation, msaName, treeData, treeUrl, querySeqName, } = init;
|
|
125
126
|
if (msaUrl) {
|
|
126
127
|
const id = getUniprotIdFromAlphaFoldUrl(msaUrl);
|
|
127
128
|
if (id) {
|
|
@@ -143,6 +144,18 @@ export function processInit(self) {
|
|
|
143
144
|
const data = await response.text();
|
|
144
145
|
self.setMSA(data);
|
|
145
146
|
}
|
|
147
|
+
else if (msaIndexedLocation && msaName) {
|
|
148
|
+
const fasta = await fetchIndexedMsa({
|
|
149
|
+
location: msaIndexedLocation,
|
|
150
|
+
name: msaName,
|
|
151
|
+
});
|
|
152
|
+
if (fasta) {
|
|
153
|
+
self.setMSA(fasta);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
throw new Error(`No alignment named ${msaName} in ${msaIndexedLocation.uri}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
146
159
|
if (treeData) {
|
|
147
160
|
self.setTree(treeData);
|
|
148
161
|
}
|
|
@@ -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
|
+
}
|