jbrowse-plugin-msaview 2.6.0 → 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 -5
- package/dist/MsaViewPanel/afterCreateAutoruns.js +12 -19
- 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 +28 -29
- 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 +7 -10
- package/src/MsaViewPanel/afterCreateAutoruns.ts +14 -22
- package/src/MsaViewPanel/fetchIndexedMsa.ts +47 -0
- package/src/MsaViewPanel/types.ts +7 -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.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.6.
|
|
1
|
+
export const version = '2.6.1';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.6.
|
|
2
|
+
"version": "2.6.1",
|
|
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",
|
|
@@ -11,9 +11,8 @@ export default function LaunchMsaViewExtensionPointF(
|
|
|
11
11
|
session,
|
|
12
12
|
data,
|
|
13
13
|
msaFileLocation,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
msaId,
|
|
14
|
+
msaIndexedLocation,
|
|
15
|
+
msaName,
|
|
17
16
|
treeFileLocation,
|
|
18
17
|
connectedViewId,
|
|
19
18
|
connectedFeature,
|
|
@@ -32,9 +31,8 @@ export default function LaunchMsaViewExtensionPointF(
|
|
|
32
31
|
session: AbstractSessionModel
|
|
33
32
|
data?: { msa: string; tree?: string }
|
|
34
33
|
msaFileLocation?: { uri: string }
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
msaId?: string
|
|
34
|
+
msaIndexedLocation?: { uri: string }
|
|
35
|
+
msaName?: string
|
|
38
36
|
treeFileLocation?: { uri: string }
|
|
39
37
|
connectedViewId?: string
|
|
40
38
|
connectedFeature?: Record<string, unknown>
|
|
@@ -50,7 +48,7 @@ export default function LaunchMsaViewExtensionPointF(
|
|
|
50
48
|
querySeqName?: string
|
|
51
49
|
highlightColumns?: number[]
|
|
52
50
|
}) => {
|
|
53
|
-
if (!data && !msaFileLocation && !
|
|
51
|
+
if (!data && !msaFileLocation && !msaIndexedLocation) {
|
|
54
52
|
throw new Error(
|
|
55
53
|
'No MSA data or file location provided when launching MSA view',
|
|
56
54
|
)
|
|
@@ -74,9 +72,8 @@ export default function LaunchMsaViewExtensionPointF(
|
|
|
74
72
|
msaData: data?.msa,
|
|
75
73
|
treeData: data?.tree,
|
|
76
74
|
msaUrl: msaFileLocation?.uri,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
msaId,
|
|
75
|
+
msaIndexedLocation,
|
|
76
|
+
msaName,
|
|
80
77
|
treeUrl: treeFileLocation?.uri,
|
|
81
78
|
querySeqName,
|
|
82
79
|
},
|
|
@@ -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 {
|
|
@@ -137,9 +137,8 @@ export function processInit(self: JBrowsePluginMsaViewModel) {
|
|
|
137
137
|
const {
|
|
138
138
|
msaData,
|
|
139
139
|
msaUrl,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
msaId,
|
|
140
|
+
msaIndexedLocation,
|
|
141
|
+
msaName,
|
|
143
142
|
treeData,
|
|
144
143
|
treeUrl,
|
|
145
144
|
querySeqName,
|
|
@@ -166,24 +165,17 @@ export function processInit(self: JBrowsePluginMsaViewModel) {
|
|
|
166
165
|
}
|
|
167
166
|
const data = await response.text()
|
|
168
167
|
self.setMSA(data)
|
|
169
|
-
} else if (
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
}
|
|
168
|
+
} else if (msaIndexedLocation && msaName) {
|
|
169
|
+
const fasta = await fetchIndexedMsa({
|
|
170
|
+
location: msaIndexedLocation,
|
|
171
|
+
name: msaName,
|
|
172
|
+
})
|
|
173
|
+
if (fasta) {
|
|
174
|
+
self.setMSA(fasta)
|
|
175
|
+
} else {
|
|
176
|
+
throw new Error(
|
|
177
|
+
`No alignment named ${msaName} in ${msaIndexedLocation.uri}`,
|
|
178
|
+
)
|
|
187
179
|
}
|
|
188
180
|
}
|
|
189
181
|
|
|
@@ -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,13 @@
|
|
|
1
1
|
export interface MsaViewInitState {
|
|
2
2
|
msaData?: string
|
|
3
3
|
msaUrl?: string
|
|
4
|
-
// a
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
msaId?: string
|
|
4
|
+
// a single bgzip `.fa.gz` of per-transcript FASTA blocks; its `.gzi` and name
|
|
5
|
+
// index `.idx` (name<TAB>offset<TAB>length) are found by suffix. `msaName`
|
|
6
|
+
// selects one transcript's block by name (a random read), so one genome-scale
|
|
7
|
+
// alignment serves any gene without per-gene files or coordinates. See
|
|
8
|
+
// react-msaview's gene-explorer.
|
|
9
|
+
msaIndexedLocation?: { uri: string }
|
|
10
|
+
msaName?: string
|
|
12
11
|
treeData?: string
|
|
13
12
|
treeUrl?: string
|
|
14
13
|
querySeqName?: string
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.6.
|
|
1
|
+
export const version = '2.6.1'
|
|
@@ -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
|
-
}
|