@jbrowse/plugin-sequence 2.17.0 → 3.0.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/BgzipFastaAdapter/configSchema.d.ts +0 -12
- package/dist/BgzipFastaAdapter/configSchema.js +1 -16
- package/dist/BgzipFastaAdapter/index.d.ts +1 -1
- package/dist/BgzipFastaAdapter/index.js +28 -16
- package/dist/ChromSizesAdapter/ChromSizesAdapter.d.ts +2 -1
- package/dist/ChromSizesAdapter/ChromSizesAdapter.js +1 -1
- package/dist/ChromSizesAdapter/configSchema.d.ts +0 -3
- package/dist/ChromSizesAdapter/configSchema.js +1 -7
- package/dist/ChromSizesAdapter/index.d.ts +1 -1
- package/dist/ChromSizesAdapter/index.js +17 -7
- package/dist/DivSequenceRenderer/components/DivSequenceRendering.d.ts +4 -5
- package/dist/DivSequenceRenderer/components/DivSequenceRendering.js +29 -48
- package/dist/DivSequenceRenderer/configSchema.d.ts +0 -3
- package/dist/DivSequenceRenderer/configSchema.js +1 -7
- package/dist/DivSequenceRenderer/index.d.ts +1 -1
- package/dist/DivSequenceRenderer/index.js +0 -1
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +6 -10
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js +46 -40
- package/dist/IndexedFastaAdapter/configSchema.d.ts +0 -9
- package/dist/IndexedFastaAdapter/configSchema.js +1 -13
- package/dist/IndexedFastaAdapter/index.d.ts +1 -1
- package/dist/IndexedFastaAdapter/index.js +28 -16
- package/dist/LinearReferenceSequenceDisplay/configSchema.d.ts +0 -3
- package/dist/LinearReferenceSequenceDisplay/configSchema.js +1 -7
- package/dist/LinearReferenceSequenceDisplay/index.d.ts +1 -1
- package/dist/LinearReferenceSequenceDisplay/model.d.ts +17 -98
- package/dist/LinearReferenceSequenceDisplay/model.js +4 -65
- package/dist/ReferenceSequenceTrack/configSchema.d.ts +1 -27
- package/dist/ReferenceSequenceTrack/configSchema.js +2 -42
- package/dist/ReferenceSequenceTrack/index.d.ts +1 -1
- package/dist/SequenceSearchAdapter/SequenceSearchAdapter.d.ts +3 -2
- package/dist/SequenceSearchAdapter/SequenceSearchAdapter.js +2 -2
- package/dist/SequenceSearchAdapter/configSchema.d.ts +0 -15
- package/dist/SequenceSearchAdapter/configSchema.js +1 -19
- package/dist/SequenceSearchAdapter/index.d.ts +1 -1
- package/dist/SequenceSearchAdapter/index.js +28 -16
- package/dist/TwoBitAdapter/TwoBitAdapter.d.ts +22 -19
- package/dist/TwoBitAdapter/TwoBitAdapter.js +35 -37
- package/dist/TwoBitAdapter/configSchema.d.ts +0 -6
- package/dist/TwoBitAdapter/configSchema.js +1 -10
- package/dist/TwoBitAdapter/index.d.ts +1 -1
- package/dist/TwoBitAdapter/index.js +17 -7
- package/dist/UnindexedFastaAdapter/UnindexedFastaAdapter.d.ts +4 -3
- package/dist/UnindexedFastaAdapter/UnindexedFastaAdapter.js +3 -3
- package/dist/UnindexedFastaAdapter/configSchema.d.ts +0 -6
- package/dist/UnindexedFastaAdapter/configSchema.js +1 -10
- package/dist/UnindexedFastaAdapter/index.d.ts +1 -1
- package/dist/UnindexedFastaAdapter/index.js +28 -16
- package/dist/createExtensionPoints.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/esm/BgzipFastaAdapter/configSchema.d.ts +0 -12
- package/esm/BgzipFastaAdapter/configSchema.js +1 -16
- package/esm/BgzipFastaAdapter/index.d.ts +1 -1
- package/esm/BgzipFastaAdapter/index.js +11 -9
- package/esm/ChromSizesAdapter/ChromSizesAdapter.d.ts +2 -1
- package/esm/ChromSizesAdapter/ChromSizesAdapter.js +2 -2
- package/esm/ChromSizesAdapter/configSchema.d.ts +0 -3
- package/esm/ChromSizesAdapter/configSchema.js +1 -7
- package/esm/ChromSizesAdapter/index.d.ts +1 -1
- package/esm/DivSequenceRenderer/components/DivSequenceRendering.d.ts +4 -5
- package/esm/DivSequenceRenderer/components/DivSequenceRendering.js +29 -45
- package/esm/DivSequenceRenderer/configSchema.d.ts +0 -3
- package/esm/DivSequenceRenderer/configSchema.js +1 -7
- package/esm/DivSequenceRenderer/index.d.ts +1 -1
- package/esm/DivSequenceRenderer/index.js +0 -1
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +6 -10
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js +47 -41
- package/esm/IndexedFastaAdapter/configSchema.d.ts +0 -9
- package/esm/IndexedFastaAdapter/configSchema.js +1 -13
- package/esm/IndexedFastaAdapter/index.d.ts +1 -1
- package/esm/IndexedFastaAdapter/index.js +11 -9
- package/esm/LinearReferenceSequenceDisplay/configSchema.d.ts +0 -3
- package/esm/LinearReferenceSequenceDisplay/configSchema.js +1 -7
- package/esm/LinearReferenceSequenceDisplay/index.d.ts +1 -1
- package/esm/LinearReferenceSequenceDisplay/model.d.ts +17 -98
- package/esm/LinearReferenceSequenceDisplay/model.js +5 -66
- package/esm/ReferenceSequenceTrack/configSchema.d.ts +1 -27
- package/esm/ReferenceSequenceTrack/configSchema.js +2 -42
- package/esm/ReferenceSequenceTrack/index.d.ts +1 -1
- package/esm/SequenceSearchAdapter/SequenceSearchAdapter.d.ts +3 -2
- package/esm/SequenceSearchAdapter/SequenceSearchAdapter.js +3 -3
- package/esm/SequenceSearchAdapter/configSchema.d.ts +0 -15
- package/esm/SequenceSearchAdapter/configSchema.js +1 -19
- package/esm/SequenceSearchAdapter/index.d.ts +1 -1
- package/esm/SequenceSearchAdapter/index.js +11 -9
- package/esm/TwoBitAdapter/TwoBitAdapter.d.ts +22 -19
- package/esm/TwoBitAdapter/TwoBitAdapter.js +35 -37
- package/esm/TwoBitAdapter/configSchema.d.ts +0 -6
- package/esm/TwoBitAdapter/configSchema.js +1 -10
- package/esm/TwoBitAdapter/index.d.ts +1 -1
- package/esm/UnindexedFastaAdapter/UnindexedFastaAdapter.d.ts +4 -3
- package/esm/UnindexedFastaAdapter/UnindexedFastaAdapter.js +4 -4
- package/esm/UnindexedFastaAdapter/configSchema.d.ts +0 -6
- package/esm/UnindexedFastaAdapter/configSchema.js +1 -10
- package/esm/UnindexedFastaAdapter/index.d.ts +1 -1
- package/esm/UnindexedFastaAdapter/index.js +11 -9
- package/esm/createExtensionPoints.d.ts +1 -1
- package/esm/createExtensionPoints.js +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +5 -5
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseAdapter
|
|
1
|
+
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
2
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
3
|
export default class ChromSizesAdapter extends BaseAdapter {
|
|
4
4
|
async setupPre() {
|
|
@@ -34,5 +34,5 @@ export default class ChromSizesAdapter extends BaseAdapter {
|
|
|
34
34
|
getHeader() {
|
|
35
35
|
return {};
|
|
36
36
|
}
|
|
37
|
-
freeResources(
|
|
37
|
+
freeResources() { }
|
|
38
38
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
3
|
-
* #config ChromSizesAdapter
|
|
4
|
-
*/
|
|
5
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
function x() { }
|
|
6
3
|
const ChromSizesAdapter = ConfigurationSchema('ChromSizesAdapter', {
|
|
7
|
-
/**
|
|
8
|
-
* #slot
|
|
9
|
-
*/
|
|
10
4
|
chromSizesLocation: {
|
|
11
5
|
type: 'fileLocation',
|
|
12
6
|
defaultValue: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function ChromSizesAdapterF(pluginManager: PluginManager): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Theme } from '@mui/material';
|
|
1
|
+
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
2
|
+
import type { Feature, Region } from '@jbrowse/core/util';
|
|
3
|
+
import type { Theme } from '@mui/material';
|
|
5
4
|
declare const DivSequenceRendering: (props: {
|
|
6
5
|
exportSVG?: {
|
|
7
6
|
rasterizeLayers: boolean;
|
|
@@ -17,5 +16,5 @@ declare const DivSequenceRendering: (props: {
|
|
|
17
16
|
showForward?: boolean;
|
|
18
17
|
showReverse?: boolean;
|
|
19
18
|
showTranslation?: boolean;
|
|
20
|
-
}) =>
|
|
19
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
20
|
export default DivSequenceRendering;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
2
3
|
import { createJBrowseTheme } from '@jbrowse/core/ui';
|
|
4
|
+
import { bpSpanPx, complement, defaultCodonTable, defaultStarts, defaultStops, generateCodonTable, revcom, } from '@jbrowse/core/util';
|
|
3
5
|
import { observer } from 'mobx-react';
|
|
4
|
-
import { bpSpanPx, revcom, complement, defaultStarts, defaultStops, defaultCodonTable, generateCodonTable, } from '@jbrowse/core/util';
|
|
5
6
|
function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqStart, height, y, reverse = false, theme, }) {
|
|
6
7
|
var _a, _b;
|
|
7
8
|
const normalizedFrame = Math.abs(frame) - 1;
|
|
@@ -29,24 +30,20 @@ function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqS
|
|
|
29
30
|
const defaultFill = colorByCDS
|
|
30
31
|
? (_a = theme === null || theme === void 0 ? void 0 : theme.palette.framesCDS.at(frame)) === null || _a === void 0 ? void 0 : _a.main
|
|
31
32
|
: (_b = theme === null || theme === void 0 ? void 0 : theme.palette.frames.at(frame)) === null || _b === void 0 ? void 0 : _b.main;
|
|
32
|
-
return (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
? codonWidth
|
|
47
|
-
: codonWidth + 0.7 /* small fudge factor when zoomed out*/, height: height, stroke: renderLetter ? '#555' : 'none', fill: codonFill || 'none' }),
|
|
48
|
-
renderLetter ? (React.createElement("text", { x: x + codonWidth / 2, fontSize: height - 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle" }, letter)) : null));
|
|
49
|
-
})));
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx("rect", { x: 0, y: y, width: width, height: height, fill: defaultFill }), translated.map((element, index) => {
|
|
34
|
+
const x = region.reversed
|
|
35
|
+
? width - (index + 1) * codonWidth - offset
|
|
36
|
+
: codonWidth * index + offset;
|
|
37
|
+
const { letter, codon } = element;
|
|
38
|
+
const codonFill = defaultStarts.includes(codon)
|
|
39
|
+
? theme === null || theme === void 0 ? void 0 : theme.palette.startCodon
|
|
40
|
+
: defaultStops.includes(codon)
|
|
41
|
+
? theme === null || theme === void 0 ? void 0 : theme.palette.stopCodon
|
|
42
|
+
: undefined;
|
|
43
|
+
return !(renderLetter || codonFill) ? null : (_jsxs(Fragment, { children: [_jsx("rect", { x: x, y: y, width: renderLetter
|
|
44
|
+
? codonWidth
|
|
45
|
+
: codonWidth + 0.7, height: height, stroke: renderLetter ? '#555' : 'none', fill: codonFill || 'none' }), renderLetter ? (_jsx("text", { x: x + codonWidth / 2, fontSize: height - 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle", children: letter })) : null] }, `${index}-${letter}`));
|
|
46
|
+
})] }));
|
|
50
47
|
}
|
|
51
48
|
function Sequence({ bpPerPx, region, feature, sequenceType, theme, height, seq, y, }) {
|
|
52
49
|
const render = 1 / bpPerPx >= 12;
|
|
@@ -56,18 +53,14 @@ function Sequence({ bpPerPx, region, feature, sequenceType, theme, height, seq,
|
|
|
56
53
|
const reverse = region.reversed;
|
|
57
54
|
const len = e - s;
|
|
58
55
|
const w = Math.max((rightPx - leftPx) / len, 0.8);
|
|
59
|
-
return (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
React.createElement(React.Fragment, { key: `${letter}-${index}` },
|
|
68
|
-
React.createElement("rect", { x: x, y: y, width: w, height: height, fill: color ? color.main : '#aaa', stroke: render ? '#555' : 'none' }),
|
|
69
|
-
render ? (React.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));
|
|
70
|
-
})));
|
|
56
|
+
return (_jsx(_Fragment, { children: seq.split('').map((letter, index) => {
|
|
57
|
+
const color = sequenceType === 'dna'
|
|
58
|
+
?
|
|
59
|
+
theme.palette.bases[letter.toUpperCase()]
|
|
60
|
+
: undefined;
|
|
61
|
+
const x = reverse ? rightPx - (index + 1) * w : leftPx + index * w;
|
|
62
|
+
return (_jsxs(Fragment, { children: [_jsx("rect", { x: x, y: y, width: w, height: height, fill: color ? color.main : '#aaa', stroke: render ? '#555' : 'none' }), render ? (_jsx("text", { x: x + w / 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle", fontSize: height - 2, fill: color ? theme.palette.getContrastText(color.main) : 'black', children: letter })) : null] }, `${letter}-${index}`));
|
|
63
|
+
}) }));
|
|
71
64
|
}
|
|
72
65
|
function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
|
|
73
66
|
const region = regions[0];
|
|
@@ -81,36 +74,27 @@ function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new M
|
|
|
81
74
|
if (!seq) {
|
|
82
75
|
return null;
|
|
83
76
|
}
|
|
84
|
-
// incrementer for the y-position of the current sequence being rendered
|
|
85
|
-
// (applies to both translation rows and dna rows)
|
|
86
77
|
let currY = -rowHeight;
|
|
87
78
|
const showSequence = bpPerPx <= 1;
|
|
88
79
|
const forwardFrames = showTranslation && showForward ? [3, 2, 1] : [];
|
|
89
80
|
const reverseFrames = showTranslation && showReverse ? [-1, -2, -3] : [];
|
|
90
|
-
// if region.reversed, the forward translation is on bottom, reverse on top
|
|
91
81
|
const [topFrames, bottomFrames] = region.reversed
|
|
92
82
|
? [reverseFrames.toReversed(), forwardFrames.toReversed()]
|
|
93
83
|
: [forwardFrames, reverseFrames];
|
|
94
|
-
return (
|
|
95
|
-
topFrames.map(index => (React.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 }))),
|
|
96
|
-
showForward && showSequence ? (React.createElement(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? complement(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null,
|
|
97
|
-
showReverse && showSequence ? (React.createElement(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : complement(seq), bpPerPx: bpPerPx, theme: theme })) : null,
|
|
98
|
-
bottomFrames.map(index => (React.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 })))));
|
|
84
|
+
return (_jsxs(_Fragment, { children: [topFrames.map(index => (_jsx(Translation, { 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 }, `translation-${index}`))), showForward && showSequence ? (_jsx(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? complement(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null, showReverse && showSequence ? (_jsx(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : complement(seq), bpPerPx: bpPerPx, theme: theme })) : null, bottomFrames.map(index => (_jsx(Translation, { 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 }, `rev-translation-${index}`)))] }));
|
|
99
85
|
}
|
|
100
86
|
function Wrapper({ exportSVG, width, totalHeight, children, }) {
|
|
101
|
-
return exportSVG ? (children) : (
|
|
102
|
-
// use block because svg by default is inline, which adds a margin
|
|
87
|
+
return exportSVG ? (children) : (_jsx("svg", { "data-testid": "sequence_track", width: width, height: totalHeight, style: {
|
|
103
88
|
display: 'block',
|
|
104
89
|
width,
|
|
105
90
|
height: totalHeight,
|
|
106
91
|
userSelect: 'none',
|
|
107
|
-
}
|
|
92
|
+
}, children: children }));
|
|
108
93
|
}
|
|
109
94
|
const DivSequenceRendering = observer(function (props) {
|
|
110
95
|
const { regions, bpPerPx, sequenceHeight } = props;
|
|
111
96
|
const region = regions[0];
|
|
112
97
|
const width = (region.end - region.start) / bpPerPx;
|
|
113
|
-
return (
|
|
114
|
-
React.createElement(SequenceSVG, { ...props })));
|
|
98
|
+
return (_jsx(Wrapper, { ...props, totalHeight: sequenceHeight, width: width, children: _jsx(SequenceSVG, { ...props }) }));
|
|
115
99
|
});
|
|
116
100
|
export default DivSequenceRendering;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
3
|
-
* #config DivSequenceRenderer
|
|
4
|
-
*/
|
|
5
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
function x() { }
|
|
6
3
|
const DivSequenceRenderer = ConfigurationSchema('DivSequenceRenderer', {
|
|
7
|
-
/**
|
|
8
|
-
* #slot
|
|
9
|
-
*/
|
|
10
4
|
height: {
|
|
11
5
|
type: 'number',
|
|
12
6
|
description: 'height in pixels of each line of sequence',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function DivSequenceRendererF(pluginManager: PluginManager): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import FeatureRendererType from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
|
|
2
2
|
import ReactComponent from './components/DivSequenceRendering';
|
|
3
3
|
import configSchema from './configSchema';
|
|
4
|
-
/* adjust in both directions */
|
|
5
4
|
class DivSequenceRenderer extends FeatureRendererType {
|
|
6
5
|
constructor() {
|
|
7
6
|
super(...arguments);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { IndexedFasta } from '@gmod/indexedfasta';
|
|
2
|
-
import { BaseSequenceAdapter
|
|
3
|
-
import {
|
|
4
|
-
import { Feature } from '@jbrowse/core/util';
|
|
2
|
+
import { BaseSequenceAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
import type { Feature } from '@jbrowse/core/util';
|
|
5
|
+
import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
5
6
|
export default class IndexedFastaAdapter extends BaseSequenceAdapter {
|
|
6
7
|
protected setupP?: Promise<{
|
|
7
8
|
fasta: IndexedFasta;
|
|
8
9
|
}>;
|
|
9
10
|
private seqCache;
|
|
10
|
-
getRefNames(
|
|
11
|
-
getRegions(
|
|
11
|
+
getRefNames(_opts?: BaseOptions): Promise<string[]>;
|
|
12
|
+
getRegions(_opts?: BaseOptions): Promise<{
|
|
12
13
|
refName: string;
|
|
13
14
|
start: number;
|
|
14
15
|
end: number;
|
|
@@ -21,10 +22,5 @@ export default class IndexedFastaAdapter extends BaseSequenceAdapter {
|
|
|
21
22
|
fasta: IndexedFasta;
|
|
22
23
|
}>;
|
|
23
24
|
getFeatures(region: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
24
|
-
/**
|
|
25
|
-
* called to provide a hint that data tied to a certain region
|
|
26
|
-
* will not be needed for the foreseeable future and can be purged
|
|
27
|
-
* from caches, etc
|
|
28
|
-
*/
|
|
29
25
|
freeResources(): void;
|
|
30
26
|
}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
+
import AbortablePromiseCache from '@gmod/abortable-promise-cache';
|
|
1
2
|
import { IndexedFasta } from '@gmod/indexedfasta';
|
|
2
|
-
import { BaseSequenceAdapter
|
|
3
|
+
import { BaseSequenceAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
import { SimpleFeature, updateStatus2 } from '@jbrowse/core/util';
|
|
5
|
+
import QuickLRU from '@jbrowse/core/util/QuickLRU';
|
|
3
6
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
4
7
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
5
|
-
import {
|
|
6
|
-
import AbortablePromiseCache from '@gmod/abortable-promise-cache';
|
|
7
|
-
import QuickLRU from '@jbrowse/core/util/QuickLRU';
|
|
8
|
+
import { checkStopToken } from '@jbrowse/core/util/stopToken';
|
|
8
9
|
export default class IndexedFastaAdapter extends BaseSequenceAdapter {
|
|
9
10
|
constructor() {
|
|
10
11
|
super(...arguments);
|
|
11
12
|
this.seqCache = new AbortablePromiseCache({
|
|
12
13
|
cache: new QuickLRU({ maxSize: 200 }),
|
|
13
|
-
fill: async (args
|
|
14
|
+
fill: async (args) => {
|
|
14
15
|
const { refName, start, end, fasta } = args;
|
|
15
|
-
return fasta.getSequence(refName, start, end
|
|
16
|
+
return fasta.getSequence(refName, start, end);
|
|
16
17
|
},
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
|
-
async getRefNames(
|
|
20
|
+
async getRefNames(_opts) {
|
|
20
21
|
const { fasta } = await this.setup();
|
|
21
|
-
return fasta.getSequenceNames(
|
|
22
|
+
return fasta.getSequenceNames();
|
|
22
23
|
}
|
|
23
|
-
async getRegions(
|
|
24
|
+
async getRegions(_opts) {
|
|
24
25
|
const { fasta } = await this.setup();
|
|
25
|
-
const seqSizes = await fasta.getSequenceSizes(
|
|
26
|
+
const seqSizes = await fasta.getSequenceSizes();
|
|
26
27
|
return Object.keys(seqSizes).map(refName => ({
|
|
27
28
|
refName,
|
|
28
29
|
start: 0,
|
|
@@ -55,40 +56,45 @@ export default class IndexedFastaAdapter extends BaseSequenceAdapter {
|
|
|
55
56
|
return this.setupP;
|
|
56
57
|
}
|
|
57
58
|
getFeatures(region, opts) {
|
|
59
|
+
const { statusCallback = () => { }, stopToken } = opts || {};
|
|
58
60
|
const { refName, start, end } = region;
|
|
59
61
|
return ObservableCreate(async (observer) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
62
|
+
await updateStatus2('Downloading sequence', statusCallback, stopToken, async () => {
|
|
63
|
+
const { fasta } = await this.setup();
|
|
64
|
+
const size = await fasta.getSequenceSize(refName);
|
|
65
|
+
const regionEnd = Math.min(size || 0, end);
|
|
66
|
+
const chunks = [];
|
|
67
|
+
const chunkSize = 128000;
|
|
68
|
+
const s = start - (start % chunkSize);
|
|
69
|
+
const e = end + (chunkSize - (end % chunkSize));
|
|
70
|
+
for (let chunkStart = s; chunkStart < e; chunkStart += chunkSize) {
|
|
71
|
+
const r = {
|
|
72
|
+
refName,
|
|
73
|
+
start: chunkStart,
|
|
74
|
+
end: chunkStart + chunkSize,
|
|
75
|
+
};
|
|
76
|
+
checkStopToken(stopToken);
|
|
77
|
+
chunks.push(await this.seqCache.get(JSON.stringify(r), { ...r, fasta }));
|
|
78
|
+
}
|
|
79
|
+
const seq = chunks
|
|
80
|
+
.filter(f => !!f)
|
|
81
|
+
.join('')
|
|
82
|
+
.slice(start - s)
|
|
83
|
+
.slice(0, end - start);
|
|
84
|
+
if (seq) {
|
|
85
|
+
observer.next(new SimpleFeature({
|
|
86
|
+
id: `${refName}-${start}-${regionEnd}`,
|
|
87
|
+
data: {
|
|
88
|
+
refName,
|
|
89
|
+
start,
|
|
90
|
+
end: regionEnd,
|
|
91
|
+
seq,
|
|
92
|
+
},
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
85
96
|
observer.complete();
|
|
86
97
|
});
|
|
87
98
|
}
|
|
88
|
-
|
|
89
|
-
* called to provide a hint that data tied to a certain region
|
|
90
|
-
* will not be needed for the foreseeable future and can be purged
|
|
91
|
-
* from caches, etc
|
|
92
|
-
*/
|
|
93
|
-
freeResources( /* { region } */) { }
|
|
99
|
+
freeResources() { }
|
|
94
100
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
declare const IndexedFastaAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
/**
|
|
3
|
-
* #slot
|
|
4
|
-
*/
|
|
5
2
|
fastaLocation: {
|
|
6
3
|
type: string;
|
|
7
4
|
defaultValue: {
|
|
@@ -9,9 +6,6 @@ declare const IndexedFastaAdapter: import("@jbrowse/core/configuration/configura
|
|
|
9
6
|
locationType: string;
|
|
10
7
|
};
|
|
11
8
|
};
|
|
12
|
-
/**
|
|
13
|
-
* #slot
|
|
14
|
-
*/
|
|
15
9
|
faiLocation: {
|
|
16
10
|
type: string;
|
|
17
11
|
defaultValue: {
|
|
@@ -19,9 +13,6 @@ declare const IndexedFastaAdapter: import("@jbrowse/core/configuration/configura
|
|
|
19
13
|
locationType: string;
|
|
20
14
|
};
|
|
21
15
|
};
|
|
22
|
-
/**
|
|
23
|
-
* #slot
|
|
24
|
-
*/
|
|
25
16
|
metadataLocation: {
|
|
26
17
|
description: string;
|
|
27
18
|
type: string;
|
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
3
|
-
* #config IndexedFastaAdapter
|
|
4
|
-
*/
|
|
5
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
function x() { }
|
|
6
3
|
const IndexedFastaAdapter = ConfigurationSchema('IndexedFastaAdapter', {
|
|
7
|
-
/**
|
|
8
|
-
* #slot
|
|
9
|
-
*/
|
|
10
4
|
fastaLocation: {
|
|
11
5
|
type: 'fileLocation',
|
|
12
6
|
defaultValue: { uri: '/path/to/seq.fa', locationType: 'UriLocation' },
|
|
13
7
|
},
|
|
14
|
-
/**
|
|
15
|
-
* #slot
|
|
16
|
-
*/
|
|
17
8
|
faiLocation: {
|
|
18
9
|
type: 'fileLocation',
|
|
19
10
|
defaultValue: { uri: '/path/to/seq.fa.fai', locationType: 'UriLocation' },
|
|
20
11
|
},
|
|
21
|
-
/**
|
|
22
|
-
* #slot
|
|
23
|
-
*/
|
|
24
12
|
metadataLocation: {
|
|
25
13
|
description: 'Optional metadata file',
|
|
26
14
|
type: 'fileLocation',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function IndexedFastaAdapterF(pluginManager: PluginManager): void;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
2
|
import configSchema from './configSchema';
|
|
3
3
|
export default function IndexedFastaAdapterF(pluginManager) {
|
|
4
|
-
pluginManager.addAdapterType(() =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
pluginManager.addAdapterType(() => {
|
|
5
|
+
return new AdapterType({
|
|
6
|
+
name: 'IndexedFastaAdapter',
|
|
7
|
+
displayName: 'Indexed FASTA adapter',
|
|
8
|
+
configSchema,
|
|
9
|
+
adapterMetadata: {
|
|
10
|
+
hiddenFromGUI: true,
|
|
11
|
+
},
|
|
12
|
+
getAdapterClass: () => import('./IndexedFastaAdapter').then(r => r.default),
|
|
13
|
+
});
|
|
14
|
+
});
|
|
13
15
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
2
|
import { default as divSequenceRendererConfigSchema } from '../DivSequenceRenderer/configSchema';
|
|
3
|
-
|
|
4
|
-
* #config LinearReferenceSequenceDisplay
|
|
5
|
-
*/
|
|
6
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
function x() { }
|
|
7
4
|
export const configSchema = ConfigurationSchema('LinearReferenceSequenceDisplay', {
|
|
8
|
-
/**
|
|
9
|
-
* #slot
|
|
10
|
-
*/
|
|
11
5
|
renderer: divSequenceRendererConfigSchema,
|
|
12
6
|
}, { explicitIdentifier: 'displayId', explicitlyTyped: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function LinearReferenceSequenceDisplayF(pluginManager: PluginManager): void;
|