@jbrowse/plugin-sequence 2.13.0 → 2.14.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/ChromSizesAdapter/ChromSizesAdapter.js +2 -2
- package/dist/DivSequenceRenderer/components/DivSequenceRendering.js +19 -17
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js +2 -2
- package/dist/LinearReferenceSequenceDisplay/model.d.ts +25 -5
- package/dist/LinearReferenceSequenceDisplay/model.js +69 -29
- package/dist/ReferenceSequenceTrack/configSchema.d.ts +16 -0
- package/dist/ReferenceSequenceTrack/configSchema.js +17 -2
- package/dist/SequenceSearchAdapter/SequenceSearchAdapter.js +1 -1
- package/dist/TwoBitAdapter/TwoBitAdapter.js +4 -1
- package/dist/UnindexedFastaAdapter/UnindexedFastaAdapter.d.ts +31 -0
- package/dist/UnindexedFastaAdapter/UnindexedFastaAdapter.js +87 -0
- package/dist/UnindexedFastaAdapter/configSchema.d.ts +29 -0
- package/dist/UnindexedFastaAdapter/configSchema.js +36 -0
- package/dist/UnindexedFastaAdapter/index.d.ts +2 -0
- package/dist/UnindexedFastaAdapter/index.js +42 -0
- package/dist/createExtensionPoints.js +3 -3
- package/dist/index.js +2 -0
- package/esm/ChromSizesAdapter/ChromSizesAdapter.js +2 -2
- package/esm/DivSequenceRenderer/components/DivSequenceRendering.js +19 -17
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js +2 -2
- package/esm/LinearReferenceSequenceDisplay/model.d.ts +25 -5
- package/esm/LinearReferenceSequenceDisplay/model.js +71 -31
- package/esm/ReferenceSequenceTrack/configSchema.d.ts +16 -0
- package/esm/ReferenceSequenceTrack/configSchema.js +17 -2
- package/esm/SequenceSearchAdapter/SequenceSearchAdapter.js +1 -1
- package/esm/TwoBitAdapter/TwoBitAdapter.js +4 -1
- package/esm/UnindexedFastaAdapter/UnindexedFastaAdapter.d.ts +31 -0
- package/esm/UnindexedFastaAdapter/UnindexedFastaAdapter.js +84 -0
- package/esm/UnindexedFastaAdapter/configSchema.d.ts +29 -0
- package/esm/UnindexedFastaAdapter/configSchema.js +34 -0
- package/esm/UnindexedFastaAdapter/index.d.ts +2 -0
- package/esm/UnindexedFastaAdapter/index.js +13 -0
- package/esm/createExtensionPoints.js +3 -3
- package/esm/index.js +2 -0
- package/package.json +4 -4
|
@@ -11,14 +11,14 @@ class ChromSizesAdapter extends BaseAdapter_1.BaseAdapter {
|
|
|
11
11
|
.split(/\n|\r\n|\r/)
|
|
12
12
|
.map(f => f.trim())
|
|
13
13
|
.filter(f => !!f)
|
|
14
|
-
.map(
|
|
14
|
+
.map(line => {
|
|
15
15
|
const [name, length] = line.split('\t');
|
|
16
16
|
return [name, +length];
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
19
19
|
async setup() {
|
|
20
20
|
if (!this.setupP) {
|
|
21
|
-
this.setupP = this.setupPre().catch(e => {
|
|
21
|
+
this.setupP = this.setupPre().catch((e) => {
|
|
22
22
|
this.setupP = undefined;
|
|
23
23
|
throw e;
|
|
24
24
|
});
|
|
@@ -46,34 +46,36 @@ function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqS
|
|
|
46
46
|
: util_1.defaultStops.includes(codon)
|
|
47
47
|
? theme === null || theme === void 0 ? void 0 : theme.palette.stopCodon
|
|
48
48
|
: undefined;
|
|
49
|
-
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return (react_1.default.createElement(react_1.default.Fragment, { key: `${index}-${letter}` },
|
|
49
|
+
return !(renderLetter || codonFill) ? null : (react_1.default.createElement(react_1.default.Fragment, { key: `${index}-${letter}` },
|
|
53
50
|
react_1.default.createElement("rect", { x: x, y: y, width: renderLetter
|
|
54
51
|
? codonWidth
|
|
55
52
|
: codonWidth + 0.7 /* small fudge factor when zoomed out*/, height: height, stroke: renderLetter ? '#555' : 'none', fill: codonFill || 'none' }),
|
|
56
53
|
renderLetter ? (react_1.default.createElement("text", { x: x + codonWidth / 2, fontSize: height - 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle" }, letter)) : null));
|
|
57
54
|
})));
|
|
58
55
|
}
|
|
59
|
-
function
|
|
60
|
-
const { bpPerPx, region, feature, theme, height, seq, y } = props;
|
|
56
|
+
function Sequence({ bpPerPx, region, feature, sequenceType, theme, height, seq, y, }) {
|
|
61
57
|
const render = 1 / bpPerPx >= 12;
|
|
62
|
-
const
|
|
58
|
+
const s = feature.get('start');
|
|
59
|
+
const e = feature.get('end');
|
|
60
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(s, e, region, bpPerPx);
|
|
63
61
|
const reverse = region.reversed;
|
|
64
|
-
const len =
|
|
62
|
+
const len = e - s;
|
|
65
63
|
const w = Math.max((rightPx - leftPx) / len, 0.8);
|
|
66
64
|
return (react_1.default.createElement(react_1.default.Fragment, null, seq.split('').map((letter, index) => {
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const color = sequenceType === 'dna'
|
|
66
|
+
? // @ts-expect-error
|
|
67
|
+
theme.palette.bases[letter.toUpperCase()]
|
|
68
|
+
: undefined;
|
|
69
69
|
const x = reverse ? rightPx - (index + 1) * w : leftPx + index * w;
|
|
70
|
-
return (
|
|
70
|
+
return (
|
|
71
|
+
/* biome-ignore lint/suspicious/noArrayIndexKey: */
|
|
72
|
+
react_1.default.createElement(react_1.default.Fragment, { key: `${letter}-${index}` },
|
|
71
73
|
react_1.default.createElement("rect", { x: x, y: y, width: w, height: height, fill: color ? color.main : '#aaa', stroke: render ? '#555' : 'none' }),
|
|
72
74
|
render ? (react_1.default.createElement("text", { x: x + w / 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle", fontSize: height - 2, fill: color ? theme.palette.getContrastText(color.main) : 'black' }, letter)) : null));
|
|
73
75
|
})));
|
|
74
76
|
}
|
|
75
|
-
function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, bpPerPx, rowHeight, }) {
|
|
76
|
-
const
|
|
77
|
+
function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
|
|
78
|
+
const region = regions[0];
|
|
77
79
|
const theme = (0, ui_1.createJBrowseTheme)(configTheme);
|
|
78
80
|
const codonTable = (0, util_1.generateCodonTable)(util_1.defaultCodonTable);
|
|
79
81
|
const [feature] = [...features.values()];
|
|
@@ -87,7 +89,7 @@ function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new M
|
|
|
87
89
|
// incrementer for the y-position of the current sequence being rendered
|
|
88
90
|
// (applies to both translation rows and dna rows)
|
|
89
91
|
let currY = -rowHeight;
|
|
90
|
-
const
|
|
92
|
+
const showSequence = bpPerPx <= 1;
|
|
91
93
|
const forwardFrames = showTranslation && showForward ? [3, 2, 1] : [];
|
|
92
94
|
const reverseFrames = showTranslation && showReverse ? [-1, -2, -3] : [];
|
|
93
95
|
// if region.reversed, the forward translation is on bottom, reverse on top
|
|
@@ -96,8 +98,8 @@ function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new M
|
|
|
96
98
|
: [forwardFrames, reverseFrames];
|
|
97
99
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
98
100
|
topFrames.map(index => (react_1.default.createElement(Translation, { key: `translation-${index}`, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: region.reversed }))),
|
|
99
|
-
showForward &&
|
|
100
|
-
showReverse &&
|
|
101
|
+
showForward && showSequence ? (react_1.default.createElement(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? (0, util_1.complement)(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null,
|
|
102
|
+
showReverse && showSequence ? (react_1.default.createElement(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : (0, util_1.complement)(seq), bpPerPx: bpPerPx, theme: theme })) : null,
|
|
101
103
|
bottomFrames.map(index => (react_1.default.createElement(Translation, { key: `rev-translation-${index}`, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: !region.reversed })))));
|
|
102
104
|
}
|
|
103
105
|
function Wrapper({ exportSVG, width, totalHeight, children, }) {
|
|
@@ -111,7 +113,7 @@ function Wrapper({ exportSVG, width, totalHeight, children, }) {
|
|
|
111
113
|
}
|
|
112
114
|
const DivSequenceRendering = (0, mobx_react_1.observer)(function (props) {
|
|
113
115
|
const { regions, bpPerPx, sequenceHeight } = props;
|
|
114
|
-
const
|
|
116
|
+
const region = regions[0];
|
|
115
117
|
const width = (region.end - region.start) / bpPerPx;
|
|
116
118
|
return (react_1.default.createElement(Wrapper, { ...props, totalHeight: sequenceHeight, width: width },
|
|
117
119
|
react_1.default.createElement(SequenceSVG, { ...props })));
|
|
@@ -52,7 +52,7 @@ class IndexedFastaAdapter extends BaseAdapter_1.BaseSequenceAdapter {
|
|
|
52
52
|
}
|
|
53
53
|
async setup() {
|
|
54
54
|
if (!this.setupP) {
|
|
55
|
-
this.setupP = this.setupPre().catch(e => {
|
|
55
|
+
this.setupP = this.setupPre().catch((e) => {
|
|
56
56
|
this.setupP = undefined;
|
|
57
57
|
throw e;
|
|
58
58
|
});
|
|
@@ -64,7 +64,7 @@ class IndexedFastaAdapter extends BaseAdapter_1.BaseSequenceAdapter {
|
|
|
64
64
|
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
65
65
|
const { fasta } = await this.setup();
|
|
66
66
|
const size = await fasta.getSequenceSize(refName, opts);
|
|
67
|
-
const regionEnd =
|
|
67
|
+
const regionEnd = Math.min(size, end);
|
|
68
68
|
const chunks = [];
|
|
69
69
|
const chunkSize = 128000;
|
|
70
70
|
const s = start - (start % chunkSize);
|
|
@@ -18,7 +18,9 @@ export declare function modelFactory(configSchema: AnyConfigurationSchemaType):
|
|
|
18
18
|
region: import("mobx-state-tree").IModelType<{
|
|
19
19
|
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
20
20
|
start: import("mobx-state-tree").ISimpleType<number>;
|
|
21
|
-
end: import("mobx-state-tree"
|
|
21
|
+
end: import("mobx-state-tree" /**
|
|
22
|
+
* #property
|
|
23
|
+
*/).ISimpleType<number>;
|
|
22
24
|
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
23
25
|
} & {
|
|
24
26
|
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -123,7 +125,7 @@ export declare function modelFactory(configSchema: AnyConfigurationSchemaType):
|
|
|
123
125
|
error: unknown;
|
|
124
126
|
message: string | undefined;
|
|
125
127
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
126
|
-
onHorizontalScroll?:
|
|
128
|
+
onHorizontalScroll?: () => void;
|
|
127
129
|
blockState?: Record<string, any>;
|
|
128
130
|
}>;
|
|
129
131
|
readonly DisplayBlurb: import("react").FC<{
|
|
@@ -143,9 +145,7 @@ export declare function modelFactory(configSchema: AnyConfigurationSchemaType):
|
|
|
143
145
|
rendererTypeName: string;
|
|
144
146
|
error: unknown;
|
|
145
147
|
message: string | undefined;
|
|
146
|
-
}, import("mobx-state-tree"
|
|
147
|
-
* #action
|
|
148
|
-
*/)._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
148
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
149
149
|
}> | null;
|
|
150
150
|
readonly adapterConfig: any;
|
|
151
151
|
readonly parentTrack: any;
|
|
@@ -232,6 +232,26 @@ export declare function modelFactory(configSchema: AnyConfigurationSchemaType):
|
|
|
232
232
|
* #property
|
|
233
233
|
*/
|
|
234
234
|
rowHeight: number;
|
|
235
|
+
} & {
|
|
236
|
+
/**
|
|
237
|
+
* #getter
|
|
238
|
+
*/
|
|
239
|
+
readonly sequenceType: any;
|
|
240
|
+
/**
|
|
241
|
+
* #getter
|
|
242
|
+
* showReverse setting, it is NOT disabled for non-dna sequences
|
|
243
|
+
*/
|
|
244
|
+
readonly showForwardActual: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* #getter
|
|
247
|
+
* showReverse setting, is disabled for non-dna sequences
|
|
248
|
+
*/
|
|
249
|
+
readonly showReverseActual: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* #getter
|
|
252
|
+
* showTranslation setting is disabled for non-dna sequences
|
|
253
|
+
*/
|
|
254
|
+
readonly showTranslationActual: boolean;
|
|
235
255
|
} & {
|
|
236
256
|
/**
|
|
237
257
|
* #getter
|
|
@@ -40,18 +40,47 @@ function modelFactory(configSchema) {
|
|
|
40
40
|
* #property
|
|
41
41
|
*/
|
|
42
42
|
rowHeight: 15,
|
|
43
|
+
}))
|
|
44
|
+
.views(self => ({
|
|
45
|
+
/**
|
|
46
|
+
* #getter
|
|
47
|
+
*/
|
|
48
|
+
get sequenceType() {
|
|
49
|
+
return (0, configuration_1.getConf)((0, util_1.getContainingTrack)(self), 'sequenceType');
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* #getter
|
|
53
|
+
* showReverse setting, it is NOT disabled for non-dna sequences
|
|
54
|
+
*/
|
|
55
|
+
get showForwardActual() {
|
|
56
|
+
return self.showForward;
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* #getter
|
|
60
|
+
* showReverse setting, is disabled for non-dna sequences
|
|
61
|
+
*/
|
|
62
|
+
get showReverseActual() {
|
|
63
|
+
return this.sequenceType === 'dna' ? self.showReverse : false;
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* #getter
|
|
67
|
+
* showTranslation setting is disabled for non-dna sequences
|
|
68
|
+
*/
|
|
69
|
+
get showTranslationActual() {
|
|
70
|
+
return this.sequenceType === 'dna' ? self.showTranslation : false;
|
|
71
|
+
},
|
|
43
72
|
}))
|
|
44
73
|
.views(self => ({
|
|
45
74
|
/**
|
|
46
75
|
* #getter
|
|
47
76
|
*/
|
|
48
77
|
get sequenceHeight() {
|
|
49
|
-
const {
|
|
50
|
-
const r1 =
|
|
51
|
-
const r2 =
|
|
78
|
+
const { rowHeight, showTranslationActual, showReverseActual, showForwardActual, } = self;
|
|
79
|
+
const r1 = showReverseActual && showTranslationActual ? rowHeight * 3 : 0;
|
|
80
|
+
const r2 = showForwardActual && showTranslationActual ? rowHeight * 3 : 0;
|
|
52
81
|
const t = r1 + r2;
|
|
53
|
-
const r =
|
|
54
|
-
const s =
|
|
82
|
+
const r = showReverseActual ? rowHeight : 0;
|
|
83
|
+
const s = showForwardActual ? rowHeight : 0;
|
|
55
84
|
return t + r + s;
|
|
56
85
|
},
|
|
57
86
|
}))
|
|
@@ -62,15 +91,16 @@ function modelFactory(configSchema) {
|
|
|
62
91
|
* #method
|
|
63
92
|
*/
|
|
64
93
|
renderProps() {
|
|
65
|
-
const {
|
|
94
|
+
const { rpcDriverName, showForwardActual, showReverseActual, showTranslationActual, rowHeight, sequenceHeight, sequenceType, } = self;
|
|
66
95
|
return {
|
|
67
96
|
...superRenderProps(),
|
|
68
97
|
...(0, tracks_1.getParentRenderProps)(self),
|
|
69
98
|
config: self.configuration.renderer,
|
|
70
99
|
rpcDriverName,
|
|
71
|
-
showForward,
|
|
72
|
-
showReverse,
|
|
73
|
-
showTranslation,
|
|
100
|
+
showForward: showForwardActual,
|
|
101
|
+
showReverse: showReverseActual,
|
|
102
|
+
showTranslation: showTranslationActual,
|
|
103
|
+
sequenceType,
|
|
74
104
|
rowHeight,
|
|
75
105
|
sequenceHeight,
|
|
76
106
|
};
|
|
@@ -83,7 +113,7 @@ function modelFactory(configSchema) {
|
|
|
83
113
|
*/
|
|
84
114
|
regionCannotBeRendered( /* region */) {
|
|
85
115
|
const view = (0, util_1.getContainingView)(self);
|
|
86
|
-
return
|
|
116
|
+
return view.bpPerPx > 3 ? 'Zoom in to see sequence' : undefined;
|
|
87
117
|
},
|
|
88
118
|
/**
|
|
89
119
|
* #getter
|
|
@@ -114,7 +144,7 @@ function modelFactory(configSchema) {
|
|
|
114
144
|
afterAttach() {
|
|
115
145
|
(0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
|
|
116
146
|
const view = (0, util_1.getContainingView)(self);
|
|
117
|
-
if (
|
|
147
|
+
if (view.bpPerPx > 3) {
|
|
118
148
|
self.setHeight(50);
|
|
119
149
|
}
|
|
120
150
|
else {
|
|
@@ -129,24 +159,34 @@ function modelFactory(configSchema) {
|
|
|
129
159
|
*/
|
|
130
160
|
trackMenuItems() {
|
|
131
161
|
return [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
...(self.sequenceType === 'dna'
|
|
163
|
+
? [
|
|
164
|
+
{
|
|
165
|
+
label: 'Show forward',
|
|
166
|
+
type: 'checkbox',
|
|
167
|
+
checked: self.showForward,
|
|
168
|
+
onClick: () => {
|
|
169
|
+
self.toggleShowForward();
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
label: 'Show reverse',
|
|
174
|
+
type: 'checkbox',
|
|
175
|
+
checked: self.showReverse,
|
|
176
|
+
onClick: () => {
|
|
177
|
+
self.toggleShowReverse();
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: 'Show translation',
|
|
182
|
+
type: 'checkbox',
|
|
183
|
+
checked: self.showTranslation,
|
|
184
|
+
onClick: () => {
|
|
185
|
+
self.toggleShowTranslation();
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
]
|
|
189
|
+
: []),
|
|
150
190
|
];
|
|
151
191
|
},
|
|
152
192
|
}));
|
|
@@ -18,6 +18,22 @@ export declare function createReferenceSeqTrackConfig(pluginManager: PluginManag
|
|
|
18
18
|
description: string;
|
|
19
19
|
defaultValue: string;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* #slot
|
|
23
|
+
*/
|
|
24
|
+
sequenceType: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
defaultValue: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* #slot
|
|
31
|
+
*/
|
|
32
|
+
description: {
|
|
33
|
+
description: string;
|
|
34
|
+
type: string;
|
|
35
|
+
defaultValue: string;
|
|
36
|
+
};
|
|
21
37
|
/**
|
|
22
38
|
* #slot
|
|
23
39
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createReferenceSeqTrackConfig = createReferenceSeqTrackConfig;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
4
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
6
5
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
7
6
|
// Note: this is primarily a copy of createBaseTrackConfig, except with a
|
|
@@ -32,6 +31,22 @@ function createReferenceSeqTrackConfig(pluginManager) {
|
|
|
32
31
|
description: 'optional track name, otherwise uses the "Reference sequence (assemblyName)"',
|
|
33
32
|
defaultValue: '',
|
|
34
33
|
},
|
|
34
|
+
/**
|
|
35
|
+
* #slot
|
|
36
|
+
*/
|
|
37
|
+
sequenceType: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'either dna or pep',
|
|
40
|
+
defaultValue: 'dna',
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* #slot
|
|
44
|
+
*/
|
|
45
|
+
description: {
|
|
46
|
+
description: 'a description of the track',
|
|
47
|
+
type: 'string',
|
|
48
|
+
defaultValue: '',
|
|
49
|
+
},
|
|
35
50
|
/**
|
|
36
51
|
* #slot
|
|
37
52
|
*/
|
|
@@ -69,7 +84,7 @@ function createReferenceSeqTrackConfig(pluginManager) {
|
|
|
69
84
|
// snapshot
|
|
70
85
|
displays.forEach((d) => d && displayTypes.add(d.type));
|
|
71
86
|
const trackType = pluginManager.getTrackType(snap.type);
|
|
72
|
-
trackType.displayTypes.forEach(displayType => {
|
|
87
|
+
trackType === null || trackType === void 0 ? void 0 : trackType.displayTypes.forEach(displayType => {
|
|
73
88
|
if (!displayTypes.has(displayType.name)) {
|
|
74
89
|
displays.push({
|
|
75
90
|
displayId: `${snap.trackId}-${displayType.name}`,
|
|
@@ -40,7 +40,7 @@ class SequenceSearchAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
40
40
|
const searchForward = this.getConf('searchForward');
|
|
41
41
|
const searchReverse = this.getConf('searchReverse');
|
|
42
42
|
const caseInsensitive = this.getConf('caseInsensitive');
|
|
43
|
-
const re = new RegExp(search,
|
|
43
|
+
const re = new RegExp(search, `g${caseInsensitive ? 'i' : ''}`);
|
|
44
44
|
if (search) {
|
|
45
45
|
if (searchForward) {
|
|
46
46
|
const matches = residues.matchAll(re);
|
|
@@ -18,7 +18,10 @@ class TwoBitAdapter extends BaseAdapter_1.BaseSequenceAdapter {
|
|
|
18
18
|
if (conf.uri !== '/path/to/default.chrom.sizes' && conf.uri !== '') {
|
|
19
19
|
const file = (0, io_1.openLocation)(conf, this.pluginManager);
|
|
20
20
|
const data = await file.readFile('utf8');
|
|
21
|
-
return Object.fromEntries(data
|
|
21
|
+
return Object.fromEntries(data
|
|
22
|
+
.split(/\n|\r\n|\r/)
|
|
23
|
+
.filter(line => !!line.trim())
|
|
24
|
+
.map(line => {
|
|
22
25
|
const [name, length] = line.split('\t');
|
|
23
26
|
return [name, +length];
|
|
24
27
|
}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseSequenceAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
+
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
+
import { Feature } from '@jbrowse/core/util';
|
|
4
|
+
declare function parseSmallFasta(text: string): Map<string, {
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly sequence: string;
|
|
7
|
+
}>;
|
|
8
|
+
export default class UnindexedFastaAdapter extends BaseSequenceAdapter {
|
|
9
|
+
protected setupP?: Promise<{
|
|
10
|
+
fasta: ReturnType<typeof parseSmallFasta>;
|
|
11
|
+
}>;
|
|
12
|
+
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
13
|
+
getRegions(opts?: BaseOptions): Promise<{
|
|
14
|
+
refName: string;
|
|
15
|
+
start: number;
|
|
16
|
+
end: number;
|
|
17
|
+
}[]>;
|
|
18
|
+
setupPre(_opts?: BaseOptions): Promise<{
|
|
19
|
+
fasta: Map<any, {
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly sequence: string;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
getHeader(): Promise<string | null>;
|
|
25
|
+
setup(opts?: BaseOptions): Promise<{
|
|
26
|
+
fasta: ReturnType<typeof parseSmallFasta>;
|
|
27
|
+
}>;
|
|
28
|
+
getFeatures(region: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
29
|
+
freeResources(): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
4
|
+
const io_1 = require("@jbrowse/core/util/io");
|
|
5
|
+
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
6
|
+
const util_1 = require("@jbrowse/core/util");
|
|
7
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
8
|
+
function parseSmallFasta(text) {
|
|
9
|
+
return new Map(text
|
|
10
|
+
.split('>')
|
|
11
|
+
.filter(t => /\S/.test(t))
|
|
12
|
+
.map(entryText => {
|
|
13
|
+
const [defLine, ...seqLines] = entryText.split('\n');
|
|
14
|
+
const [id, ...description] = defLine.split(' ');
|
|
15
|
+
const sequence = seqLines.join('').replace(/\s/g, '');
|
|
16
|
+
return [
|
|
17
|
+
id,
|
|
18
|
+
{
|
|
19
|
+
description: description.join(' '),
|
|
20
|
+
sequence,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
class UnindexedFastaAdapter extends BaseAdapter_1.BaseSequenceAdapter {
|
|
26
|
+
async getRefNames(opts) {
|
|
27
|
+
const { fasta } = await this.setup(opts);
|
|
28
|
+
return [...fasta.keys()];
|
|
29
|
+
}
|
|
30
|
+
async getRegions(opts) {
|
|
31
|
+
const { fasta } = await this.setup(opts);
|
|
32
|
+
return [...fasta.entries()].map(([refName, data]) => ({
|
|
33
|
+
refName,
|
|
34
|
+
start: 0,
|
|
35
|
+
end: data.sequence.length,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
async setupPre(_opts) {
|
|
39
|
+
const fastaLocation = this.getConf('fastaLocation');
|
|
40
|
+
const res = parseSmallFasta(await (0, io_1.openLocation)(fastaLocation, this.pluginManager).readFile('utf8'));
|
|
41
|
+
return {
|
|
42
|
+
fasta: new Map([...res.entries()].map(([refName, val]) => {
|
|
43
|
+
return [
|
|
44
|
+
(0, configuration_1.readConfObject)(this.config, 'rewriteRefNames', { refName }) ||
|
|
45
|
+
refName,
|
|
46
|
+
val,
|
|
47
|
+
];
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async getHeader() {
|
|
52
|
+
const loc = this.getConf('metadataLocation');
|
|
53
|
+
return loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml'
|
|
54
|
+
? null
|
|
55
|
+
: (0, io_1.openLocation)(loc, this.pluginManager).readFile('utf8');
|
|
56
|
+
}
|
|
57
|
+
async setup(opts) {
|
|
58
|
+
if (!this.setupP) {
|
|
59
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
60
|
+
this.setupP = undefined;
|
|
61
|
+
throw e;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return this.setupP;
|
|
65
|
+
}
|
|
66
|
+
getFeatures(region, opts) {
|
|
67
|
+
const { refName, start, end } = region;
|
|
68
|
+
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
69
|
+
const { fasta } = await this.setup(opts);
|
|
70
|
+
const entry = fasta.get(refName);
|
|
71
|
+
if (entry) {
|
|
72
|
+
observer.next(new util_1.SimpleFeature({
|
|
73
|
+
id: `${refName}-${start}-${end}`,
|
|
74
|
+
data: {
|
|
75
|
+
refName,
|
|
76
|
+
start,
|
|
77
|
+
end,
|
|
78
|
+
seq: entry.sequence.slice(start, end),
|
|
79
|
+
},
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
observer.complete();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
freeResources( /* { region } */) { }
|
|
86
|
+
}
|
|
87
|
+
exports.default = UnindexedFastaAdapter;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const UnindexedFastaAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
+
rewriteRefNames: {
|
|
3
|
+
type: string;
|
|
4
|
+
defaultValue: string;
|
|
5
|
+
contextVariable: string[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* #slot
|
|
9
|
+
*/
|
|
10
|
+
fastaLocation: {
|
|
11
|
+
type: string;
|
|
12
|
+
defaultValue: {
|
|
13
|
+
uri: string;
|
|
14
|
+
locationType: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* #slot
|
|
19
|
+
*/
|
|
20
|
+
metadataLocation: {
|
|
21
|
+
description: string;
|
|
22
|
+
type: string;
|
|
23
|
+
defaultValue: {
|
|
24
|
+
uri: string;
|
|
25
|
+
locationType: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
29
|
+
export default UnindexedFastaAdapter;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
|
+
/**
|
|
5
|
+
* #config UnindexedFastaAdapter
|
|
6
|
+
*/
|
|
7
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8
|
+
const UnindexedFastaAdapter = (0, configuration_1.ConfigurationSchema)('UnindexedFastaAdapter', {
|
|
9
|
+
rewriteRefNames: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
defaultValue: '',
|
|
12
|
+
contextVariable: ['refName'],
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* #slot
|
|
16
|
+
*/
|
|
17
|
+
fastaLocation: {
|
|
18
|
+
type: 'fileLocation',
|
|
19
|
+
defaultValue: {
|
|
20
|
+
uri: '/path/to/seq.fa',
|
|
21
|
+
locationType: 'UriLocation',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* #slot
|
|
26
|
+
*/
|
|
27
|
+
metadataLocation: {
|
|
28
|
+
description: 'Optional metadata file',
|
|
29
|
+
type: 'fileLocation',
|
|
30
|
+
defaultValue: {
|
|
31
|
+
uri: '/path/to/fa.metadata.yaml',
|
|
32
|
+
locationType: 'UriLocation',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}, { explicitlyTyped: true });
|
|
36
|
+
exports.default = UnindexedFastaAdapter;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.default = UnindexedFastaAdapterF;
|
|
30
|
+
const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
|
|
31
|
+
const configSchema_1 = __importDefault(require("./configSchema"));
|
|
32
|
+
function UnindexedFastaAdapterF(pluginManager) {
|
|
33
|
+
pluginManager.addAdapterType(() => new AdapterType_1.default({
|
|
34
|
+
name: 'UnindexedFastaAdapter',
|
|
35
|
+
displayName: 'Unindexed FASTA adapter',
|
|
36
|
+
configSchema: configSchema_1.default,
|
|
37
|
+
adapterMetadata: {
|
|
38
|
+
hiddenFromGUI: true,
|
|
39
|
+
},
|
|
40
|
+
getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./UnindexedFastaAdapter'))).then(r => r.default),
|
|
41
|
+
}));
|
|
42
|
+
}
|