@jbrowse/plugin-linear-genome-view 2.7.2 → 2.9.0
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/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +18 -11
- package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +25 -2
- package/dist/BaseLinearDisplay/models/renderSvg.d.ts +1 -1
- package/dist/BaseLinearDisplay/models/renderSvg.js +2 -1
- package/dist/BasicTrack/configSchema.d.ts +5 -0
- package/dist/FeatureTrack/configSchema.d.ts +5 -0
- package/dist/LaunchLinearGenomeView/index.js +16 -14
- package/dist/LinearBasicDisplay/model.d.ts +3 -1
- package/dist/LinearGenomeView/components/CenterLine.js +1 -1
- package/dist/LinearGenomeView/components/ImportForm.js +26 -74
- package/dist/LinearGenomeView/components/ImportFormRefNameAutocomplete.d.ts +12 -0
- package/dist/LinearGenomeView/components/ImportFormRefNameAutocomplete.js +29 -0
- package/dist/LinearGenomeView/components/OverviewScalebar.js +1 -1
- package/dist/LinearGenomeView/components/SearchBox.js +18 -54
- package/dist/LinearGenomeView/model.d.ts +12 -1
- package/dist/LinearGenomeView/model.js +16 -0
- package/dist/index.d.ts +702 -6
- package/dist/index.js +2 -2
- package/dist/searchUtils.d.ts +26 -0
- package/dist/searchUtils.js +90 -0
- package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +18 -11
- package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js +1 -1
- package/esm/BaseLinearDisplay/models/renderSvg.d.ts +1 -1
- package/esm/BaseLinearDisplay/models/renderSvg.js +1 -1
- package/esm/BasicTrack/configSchema.d.ts +5 -0
- package/esm/FeatureTrack/configSchema.d.ts +5 -0
- package/esm/LaunchLinearGenomeView/index.js +16 -14
- package/esm/LinearBasicDisplay/model.d.ts +3 -1
- package/esm/LinearGenomeView/components/CenterLine.js +1 -1
- package/esm/LinearGenomeView/components/ImportForm.js +26 -74
- package/esm/LinearGenomeView/components/ImportFormRefNameAutocomplete.d.ts +12 -0
- package/esm/LinearGenomeView/components/ImportFormRefNameAutocomplete.js +24 -0
- package/esm/LinearGenomeView/components/OverviewScalebar.js +1 -1
- package/esm/LinearGenomeView/components/SearchBox.js +19 -55
- package/esm/LinearGenomeView/model.d.ts +12 -1
- package/esm/LinearGenomeView/model.js +16 -0
- package/esm/index.d.ts +702 -6
- package/esm/index.js +2 -2
- package/esm/searchUtils.d.ts +26 -0
- package/esm/searchUtils.js +79 -0
- package/package.json +2 -2
package/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
2
|
import { isAbstractMenuManager } from '@jbrowse/core/util';
|
|
3
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
4
|
+
import { types } from 'mobx-state-tree';
|
|
3
5
|
// icons
|
|
4
6
|
import LineStyleIcon from '@mui/icons-material/LineStyle';
|
|
5
7
|
// locals
|
|
@@ -10,8 +12,6 @@ import LinearBasicDisplayF from './LinearBasicDisplay';
|
|
|
10
12
|
import FeatureTrackF from './FeatureTrack';
|
|
11
13
|
import BasicTrackF from './BasicTrack';
|
|
12
14
|
import LaunchLinearGenomeViewF from './LaunchLinearGenomeView';
|
|
13
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
14
|
-
import { types } from 'mobx-state-tree';
|
|
15
15
|
export default class LinearGenomeViewPlugin extends Plugin {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(...arguments);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import BaseResult from '@jbrowse/core/TextSearch/BaseResults';
|
|
2
|
+
import { Assembly } from '@jbrowse/core/assemblyManager/assembly';
|
|
3
|
+
import { SearchType } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
import { SearchScope } from '@jbrowse/core/TextSearch/TextSearchManager';
|
|
5
|
+
import { TextSearchManager } from '@jbrowse/core/util';
|
|
6
|
+
import { LinearGenomeViewModel } from './LinearGenomeView';
|
|
7
|
+
export declare function navToOption({ option, model, assemblyName, }: {
|
|
8
|
+
model: LinearGenomeViewModel;
|
|
9
|
+
option: BaseResult;
|
|
10
|
+
assemblyName: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare function handleSelectedRegion({ input, model, assembly, }: {
|
|
13
|
+
input: string;
|
|
14
|
+
model: LinearGenomeViewModel;
|
|
15
|
+
assembly: Assembly;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
export declare function checkRef(str: string, allRefs: string[]): boolean;
|
|
18
|
+
export declare function fetchResults({ queryString, searchType, searchScope, rankSearchResults, textSearchManager, assembly, }: {
|
|
19
|
+
queryString: string;
|
|
20
|
+
searchScope: SearchScope;
|
|
21
|
+
rankSearchResults: (results: BaseResult[]) => BaseResult[];
|
|
22
|
+
searchType?: SearchType;
|
|
23
|
+
textSearchManager?: TextSearchManager;
|
|
24
|
+
assembly?: Assembly;
|
|
25
|
+
}): Promise<BaseResult[]>;
|
|
26
|
+
export declare function splitLast(str: string, split: string): [string, string];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { getSession } from '@jbrowse/core/util';
|
|
2
|
+
import BaseResult from '@jbrowse/core/TextSearch/BaseResults';
|
|
3
|
+
import { dedupe } from '@jbrowse/core/util';
|
|
4
|
+
export async function navToOption({ option, model, assemblyName, }) {
|
|
5
|
+
const location = option.getLocation();
|
|
6
|
+
const trackId = option.getTrackId();
|
|
7
|
+
if (location) {
|
|
8
|
+
await model.navToLocString(location, assemblyName);
|
|
9
|
+
if (trackId) {
|
|
10
|
+
model.showTrack(trackId);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// gets a string as input, or use stored option results from previous query,
|
|
15
|
+
// then re-query and
|
|
16
|
+
// 1) if it has multiple results: pop a dialog
|
|
17
|
+
// 2) if it's a single result navigate to it
|
|
18
|
+
// 3) else assume it's a locstring and navigate to it
|
|
19
|
+
export async function handleSelectedRegion({ input, model, assembly, }) {
|
|
20
|
+
const allRefs = (assembly === null || assembly === void 0 ? void 0 : assembly.allRefNamesWithLowerCase) || [];
|
|
21
|
+
const assemblyName = assembly.name;
|
|
22
|
+
if (input.split(' ').every(entry => checkRef(entry, allRefs))) {
|
|
23
|
+
await model.navToLocString(input, assembly.name);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const searchScope = model.searchScope(assemblyName);
|
|
27
|
+
const { textSearchManager } = getSession(model);
|
|
28
|
+
const results = await fetchResults({
|
|
29
|
+
queryString: input,
|
|
30
|
+
searchType: 'exact',
|
|
31
|
+
searchScope,
|
|
32
|
+
rankSearchResults: model.rankSearchResults,
|
|
33
|
+
textSearchManager,
|
|
34
|
+
assembly,
|
|
35
|
+
});
|
|
36
|
+
if (results.length > 1) {
|
|
37
|
+
model.setSearchResults(results, input.toLowerCase(), assemblyName);
|
|
38
|
+
}
|
|
39
|
+
else if (results.length === 1) {
|
|
40
|
+
await navToOption({
|
|
41
|
+
option: results[0],
|
|
42
|
+
model,
|
|
43
|
+
assemblyName,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
await model.navToLocString(input, assemblyName);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function checkRef(str, allRefs) {
|
|
52
|
+
const [ref, rest] = splitLast(str, ':');
|
|
53
|
+
return (allRefs.includes(str) ||
|
|
54
|
+
(allRefs.includes(ref) && !Number.isNaN(Number.parseInt(rest, 10))));
|
|
55
|
+
}
|
|
56
|
+
export async function fetchResults({ queryString, searchType, searchScope, rankSearchResults, textSearchManager, assembly, }) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (!textSearchManager) {
|
|
59
|
+
console.warn('No text search manager');
|
|
60
|
+
}
|
|
61
|
+
const textSearchResults = await (textSearchManager === null || textSearchManager === void 0 ? void 0 : textSearchManager.search({
|
|
62
|
+
queryString,
|
|
63
|
+
searchType,
|
|
64
|
+
}, searchScope, rankSearchResults));
|
|
65
|
+
const refNameResults = (_a = assembly === null || assembly === void 0 ? void 0 : assembly.allRefNames) === null || _a === void 0 ? void 0 : _a.filter(ref => ref.toLowerCase().startsWith(queryString.toLowerCase())).slice(0, 10).map(r => new BaseResult({ label: r }));
|
|
66
|
+
return dedupe([...(refNameResults || []), ...(textSearchResults || [])], elt => elt.getId());
|
|
67
|
+
}
|
|
68
|
+
// splits on the last instance of a character
|
|
69
|
+
export function splitLast(str, split) {
|
|
70
|
+
const lastIndex = str.lastIndexOf(split);
|
|
71
|
+
if (lastIndex === -1) {
|
|
72
|
+
return [str, ''];
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const before = str.slice(0, lastIndex);
|
|
76
|
+
const after = str.slice(lastIndex + 1);
|
|
77
|
+
return [before, after];
|
|
78
|
+
}
|
|
79
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-linear-genome-view",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "JBrowse 2 linear genome view",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"module": "esm/index.js",
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "a50b6f67cf8c8f3c65a7b8cd858de2fcca1f2909"
|
|
69
69
|
}
|