@jbrowse/plugin-trix 5.0.0-beta.1 → 5.0.0-beta.10
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.
|
@@ -2,8 +2,8 @@ import Trix from '@gmod/trix';
|
|
|
2
2
|
import BaseResult from '@jbrowse/core/TextSearch/BaseResults';
|
|
3
3
|
import { readConfObject } from '@jbrowse/core/configuration';
|
|
4
4
|
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
5
|
+
import { checkAbortSignal } from '@jbrowse/core/util/aborting';
|
|
5
6
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
6
|
-
import { checkStopToken } from '@jbrowse/core/util/stopToken';
|
|
7
7
|
function decodeURIComponentNoThrow(uri) {
|
|
8
8
|
try {
|
|
9
9
|
return decodeURIComponent(uri);
|
|
@@ -53,11 +53,11 @@ export default class TrixTextSearchAdapter extends BaseAdapter {
|
|
|
53
53
|
// any run of whitespace separates words; splitting on a single ' ' let a
|
|
54
54
|
// double space or a tab produce an empty word that matches everything
|
|
55
55
|
const words = query.split(/\s+/);
|
|
56
|
-
const results = await this.trixJs.search(query);
|
|
56
|
+
const results = await this.trixJs.search(query, { signal: args.signal });
|
|
57
57
|
// the index read has landed but nothing below it has run yet; a broad
|
|
58
58
|
// prefix returns thousands of records to JSON-parse, decode and snippet,
|
|
59
59
|
// and the keystroke that asked for them is 50ms stale by now
|
|
60
|
-
|
|
60
|
+
checkAbortSignal(args.signal);
|
|
61
61
|
const formatted = results
|
|
62
62
|
.map(([term, data]) => {
|
|
63
63
|
// record is ["loc"|"trackId"|"attr1"|...] with commas pre-encoded as
|
|
@@ -6,71 +6,40 @@ export declare function normalizeSnapshot(snap: Record<string, unknown>): Record
|
|
|
6
6
|
*
|
|
7
7
|
* #example
|
|
8
8
|
* `jbrowse text-index` writes this entry into `aggregateTextSearchAdapters` for
|
|
9
|
-
* you. The `uri` shorthand points at the `.ix
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* you. The `uri` shorthand points at the `.ix` and the sibling `.ixx` is derived
|
|
10
|
+
* from it, so the pair only needs spelling out when they are named against
|
|
11
|
+
* convention. Written by hand, the string `'trix/hg38.ix'` is the whole entry,
|
|
12
|
+
* the same as `{ uri: 'trix/hg38.ix' }`: a `.ix` implies this type, and
|
|
13
|
+
* `assemblyNames` defaults to the track's own for a per-track index or to the
|
|
14
|
+
* config's one assembly.
|
|
12
15
|
* ```js
|
|
13
16
|
* {
|
|
14
17
|
* type: 'TrixTextSearchAdapter',
|
|
15
|
-
* textSearchAdapterId: 'hg38-index',
|
|
16
18
|
* uri: 'trix/hg38.ix',
|
|
17
19
|
* assemblyNames: ['hg38'],
|
|
18
20
|
* }
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
21
23
|
declare const TrixTextSearchAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
type: {
|
|
25
|
+
type: "string";
|
|
26
|
+
} & {
|
|
27
|
+
defaultValue: string;
|
|
28
|
+
};
|
|
27
29
|
readonly ixFilePath: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
readonly locationType: "UriLocation";
|
|
32
|
-
};
|
|
30
|
+
type: "fileLocation";
|
|
31
|
+
} & {
|
|
32
|
+
defaultValue: unknown;
|
|
33
33
|
};
|
|
34
|
-
/**
|
|
35
|
-
* #slot
|
|
36
|
-
* location of the `.ixx` prefix index, which records where in the `.ix`
|
|
37
|
-
* each prefix begins. It is what makes a lookup a couple of range requests
|
|
38
|
-
* instead of a download of the whole index.
|
|
39
|
-
*/
|
|
40
34
|
readonly ixxFilePath: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
readonly locationType: "UriLocation";
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* #slot
|
|
49
|
-
* location of the `_meta.json` written beside the index, recording which
|
|
50
|
-
* tracks and assemblies it covers and the attributes it was built from.
|
|
51
|
-
*/
|
|
52
|
-
readonly metaFilePath: {
|
|
53
|
-
readonly type: "fileLocation";
|
|
54
|
-
readonly defaultValue: {
|
|
55
|
-
readonly uri: "meta.json";
|
|
56
|
-
readonly locationType: "UriLocation";
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* #slot
|
|
61
|
-
*/
|
|
62
|
-
readonly tracks: {
|
|
63
|
-
readonly type: "stringArray";
|
|
64
|
-
readonly defaultValue: readonly [];
|
|
65
|
-
readonly description: "List of tracks covered by text search adapter";
|
|
35
|
+
type: "fileLocation";
|
|
36
|
+
} & {
|
|
37
|
+
defaultValue: unknown;
|
|
66
38
|
};
|
|
67
|
-
/**
|
|
68
|
-
* #slot
|
|
69
|
-
*/
|
|
70
39
|
readonly assemblyNames: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
type: "stringArray";
|
|
41
|
+
} & {
|
|
42
|
+
defaultValue: unknown;
|
|
74
43
|
};
|
|
75
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
44
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined, true, import("@jbrowse/core/configuration").ConfigurationSchemaRequirement<Partial<Record<string, string[]>>, string>, any>>;
|
|
76
45
|
export default TrixTextSearchAdapter;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
1
|
+
import { ConfigurationSchema, fillLocations } from '@jbrowse/core/configuration';
|
|
2
2
|
export function normalizeSnapshot(snap) {
|
|
3
3
|
return typeof snap.uri === 'string'
|
|
4
|
-
? {
|
|
5
|
-
|
|
6
|
-
// `
|
|
7
|
-
// (the `jbrowse text-index` naming convention), so derive all three
|
|
4
|
+
? fillLocations(snap, {
|
|
5
|
+
// `uri` points at the `.ix` file and the `.ixx` sits beside it (the
|
|
6
|
+
// `jbrowse text-index` naming convention), so derive the pair
|
|
8
7
|
ixFilePath: {
|
|
9
8
|
uri: snap.uri,
|
|
10
9
|
baseUri: snap.baseUri,
|
|
@@ -13,11 +12,7 @@ export function normalizeSnapshot(snap) {
|
|
|
13
12
|
uri: `${snap.uri}x`,
|
|
14
13
|
baseUri: snap.baseUri,
|
|
15
14
|
},
|
|
16
|
-
|
|
17
|
-
uri: `${snap.uri.replace(/\.ix$/, '')}_meta.json`,
|
|
18
|
-
baseUri: snap.baseUri,
|
|
19
|
-
},
|
|
20
|
-
}
|
|
15
|
+
})
|
|
21
16
|
: snap;
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
@@ -27,13 +22,15 @@ export function normalizeSnapshot(snap) {
|
|
|
27
22
|
*
|
|
28
23
|
* #example
|
|
29
24
|
* `jbrowse text-index` writes this entry into `aggregateTextSearchAdapters` for
|
|
30
|
-
* you. The `uri` shorthand points at the `.ix
|
|
31
|
-
*
|
|
32
|
-
*
|
|
25
|
+
* you. The `uri` shorthand points at the `.ix` and the sibling `.ixx` is derived
|
|
26
|
+
* from it, so the pair only needs spelling out when they are named against
|
|
27
|
+
* convention. Written by hand, the string `'trix/hg38.ix'` is the whole entry,
|
|
28
|
+
* the same as `{ uri: 'trix/hg38.ix' }`: a `.ix` implies this type, and
|
|
29
|
+
* `assemblyNames` defaults to the track's own for a per-track index or to the
|
|
30
|
+
* config's one assembly.
|
|
33
31
|
* ```js
|
|
34
32
|
* {
|
|
35
33
|
* type: 'TrixTextSearchAdapter',
|
|
36
|
-
* textSearchAdapterId: 'hg38-index',
|
|
37
34
|
* uri: 'trix/hg38.ix',
|
|
38
35
|
* assemblyNames: ['hg38'],
|
|
39
36
|
* }
|
|
@@ -55,8 +52,8 @@ const TrixTextSearchAdapter = ConfigurationSchema('TrixTextSearchAdapter', {
|
|
|
55
52
|
/**
|
|
56
53
|
* #slot
|
|
57
54
|
* location of the `.ixx` prefix index, which records where in the `.ix`
|
|
58
|
-
* each prefix begins
|
|
59
|
-
*
|
|
55
|
+
* each prefix begins, so a lookup takes a couple of range requests instead
|
|
56
|
+
* of a download of the whole index.
|
|
60
57
|
*/
|
|
61
58
|
ixxFilePath: {
|
|
62
59
|
type: 'fileLocation',
|
|
@@ -65,26 +62,6 @@ const TrixTextSearchAdapter = ConfigurationSchema('TrixTextSearchAdapter', {
|
|
|
65
62
|
locationType: 'UriLocation',
|
|
66
63
|
},
|
|
67
64
|
},
|
|
68
|
-
/**
|
|
69
|
-
* #slot
|
|
70
|
-
* location of the `_meta.json` written beside the index, recording which
|
|
71
|
-
* tracks and assemblies it covers and the attributes it was built from.
|
|
72
|
-
*/
|
|
73
|
-
metaFilePath: {
|
|
74
|
-
type: 'fileLocation',
|
|
75
|
-
defaultValue: {
|
|
76
|
-
uri: 'meta.json',
|
|
77
|
-
locationType: 'UriLocation',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* #slot
|
|
82
|
-
*/
|
|
83
|
-
tracks: {
|
|
84
|
-
type: 'stringArray',
|
|
85
|
-
defaultValue: [],
|
|
86
|
-
description: 'List of tracks covered by text search adapter',
|
|
87
|
-
},
|
|
88
65
|
/**
|
|
89
66
|
* #slot
|
|
90
67
|
*/
|
|
@@ -95,24 +72,18 @@ const TrixTextSearchAdapter = ConfigurationSchema('TrixTextSearchAdapter', {
|
|
|
95
72
|
},
|
|
96
73
|
}, {
|
|
97
74
|
explicitlyTyped: true,
|
|
98
|
-
/**
|
|
99
|
-
* #identifier
|
|
100
|
-
* an explicit `textSearchAdapterId` is still honored when given
|
|
101
|
-
*/
|
|
102
|
-
implicitIdentifier: 'textSearchAdapterId',
|
|
103
75
|
/**
|
|
104
76
|
* #preProcessSnapshot
|
|
105
77
|
*
|
|
106
78
|
*
|
|
107
79
|
* preprocessor to allow minimal config: `uri` points at the `.ix` file and
|
|
108
|
-
* the sibling `.ixx`
|
|
109
|
-
*
|
|
80
|
+
* the sibling `.ixx` is derived from it (the `jbrowse text-index` naming
|
|
81
|
+
* convention):
|
|
110
82
|
* ```json
|
|
111
83
|
* {
|
|
112
84
|
* "type": "TrixTextSearchAdapter",
|
|
113
85
|
* "uri": "file.ix",
|
|
114
|
-
* "assemblyNames": ["hg19"]
|
|
115
|
-
* "textSearchAdapterId": "hg19SearchIndex"
|
|
86
|
+
* "assemblyNames": ["hg19"]
|
|
116
87
|
* }
|
|
117
88
|
* ```
|
|
118
89
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-trix",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "JBrowse 2 trix text search adapter",
|
|
6
6
|
"keywords": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@gmod/trix": "^3.0.22",
|
|
28
|
-
"@jbrowse/core": "^5.0.0-beta.
|
|
28
|
+
"@jbrowse/core": "^5.0.0-beta.10"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|