@jbrowse/plugin-sequence 3.6.5 → 4.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.
Files changed (95) hide show
  1. package/esm/BgzipFastaAdapter/BgzipFastaAdapter.d.ts +1 -1
  2. package/esm/BgzipFastaAdapter/BgzipFastaAdapter.js +1 -1
  3. package/esm/BgzipFastaAdapter/configSchema.d.ts +2 -2
  4. package/esm/BgzipFastaAdapter/index.js +2 -2
  5. package/esm/ChromSizesAdapter/ChromSizesAdapter.js +1 -0
  6. package/esm/ChromSizesAdapter/configSchema.d.ts +2 -2
  7. package/esm/ChromSizesAdapter/index.js +2 -2
  8. package/esm/DivSequenceRenderer/components/DivSequenceRendering.js +25 -70
  9. package/esm/DivSequenceRenderer/components/Sequence.d.ts +10 -0
  10. package/esm/DivSequenceRenderer/components/Sequence.js +32 -0
  11. package/esm/DivSequenceRenderer/components/Translation.d.ts +14 -0
  12. package/esm/DivSequenceRenderer/components/Translation.js +54 -0
  13. package/esm/DivSequenceRenderer/configSchema.d.ts +2 -2
  14. package/esm/DivSequenceRenderer/index.js +6 -12
  15. package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js +15 -23
  16. package/esm/IndexedFastaAdapter/configSchema.d.ts +2 -2
  17. package/esm/IndexedFastaAdapter/index.js +2 -2
  18. package/esm/LinearReferenceSequenceDisplay/configSchema.d.ts +4 -4
  19. package/esm/LinearReferenceSequenceDisplay/configSchema.js +1 -1
  20. package/esm/LinearReferenceSequenceDisplay/index.js +2 -2
  21. package/esm/LinearReferenceSequenceDisplay/model.d.ts +1049 -91
  22. package/esm/LinearReferenceSequenceDisplay/model.js +16 -4
  23. package/esm/ReferenceSequenceTrack/configSchema.d.ts +6 -6
  24. package/esm/ReferenceSequenceTrack/configSchema.js +3 -3
  25. package/esm/ReferenceSequenceTrack/index.js +13 -2
  26. package/esm/SequenceSearchAdapter/SequenceSearchAdapter.d.ts +2 -2
  27. package/esm/SequenceSearchAdapter/SequenceSearchAdapter.js +3 -9
  28. package/esm/SequenceSearchAdapter/configSchema.d.ts +2 -2
  29. package/esm/SequenceSearchAdapter/index.js +2 -2
  30. package/esm/TwoBitAdapter/TwoBitAdapter.js +1 -0
  31. package/esm/TwoBitAdapter/configSchema.d.ts +2 -2
  32. package/esm/TwoBitAdapter/index.js +2 -2
  33. package/esm/UnindexedFastaAdapter/UnindexedFastaAdapter.js +1 -0
  34. package/esm/UnindexedFastaAdapter/configSchema.d.ts +2 -2
  35. package/esm/UnindexedFastaAdapter/index.js +2 -2
  36. package/esm/index.js +11 -14
  37. package/esm/saveTrackFormats/fasta.d.ts +4 -0
  38. package/esm/saveTrackFormats/fasta.js +13 -0
  39. package/package.json +28 -34
  40. package/dist/BgzipFastaAdapter/BgzipFastaAdapter.d.ts +0 -7
  41. package/dist/BgzipFastaAdapter/BgzipFastaAdapter.js +0 -22
  42. package/dist/BgzipFastaAdapter/configSchema.d.ts +0 -32
  43. package/dist/BgzipFastaAdapter/configSchema.js +0 -54
  44. package/dist/BgzipFastaAdapter/index.d.ts +0 -2
  45. package/dist/BgzipFastaAdapter/index.js +0 -54
  46. package/dist/ChromSizesAdapter/ChromSizesAdapter.d.ts +0 -15
  47. package/dist/ChromSizesAdapter/ChromSizesAdapter.js +0 -40
  48. package/dist/ChromSizesAdapter/configSchema.d.ts +0 -10
  49. package/dist/ChromSizesAdapter/configSchema.js +0 -27
  50. package/dist/ChromSizesAdapter/index.d.ts +0 -2
  51. package/dist/ChromSizesAdapter/index.js +0 -52
  52. package/dist/DivSequenceRenderer/components/DivSequenceRendering.d.ts +0 -18
  53. package/dist/DivSequenceRenderer/components/DivSequenceRendering.js +0 -103
  54. package/dist/DivSequenceRenderer/configSchema.d.ts +0 -8
  55. package/dist/DivSequenceRenderer/configSchema.js +0 -12
  56. package/dist/DivSequenceRenderer/index.d.ts +0 -2
  57. package/dist/DivSequenceRenderer/index.js +0 -30
  58. package/dist/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +0 -25
  59. package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js +0 -112
  60. package/dist/IndexedFastaAdapter/configSchema.d.ts +0 -25
  61. package/dist/IndexedFastaAdapter/configSchema.js +0 -40
  62. package/dist/IndexedFastaAdapter/index.d.ts +0 -2
  63. package/dist/IndexedFastaAdapter/index.js +0 -54
  64. package/dist/LinearReferenceSequenceDisplay/configSchema.d.ts +0 -9
  65. package/dist/LinearReferenceSequenceDisplay/configSchema.js +0 -12
  66. package/dist/LinearReferenceSequenceDisplay/index.d.ts +0 -2
  67. package/dist/LinearReferenceSequenceDisplay/index.js +0 -21
  68. package/dist/LinearReferenceSequenceDisplay/model.d.ts +0 -323
  69. package/dist/LinearReferenceSequenceDisplay/model.js +0 -132
  70. package/dist/ReferenceSequenceTrack/configSchema.d.ts +0 -37
  71. package/dist/ReferenceSequenceTrack/configSchema.js +0 -83
  72. package/dist/ReferenceSequenceTrack/index.d.ts +0 -2
  73. package/dist/ReferenceSequenceTrack/index.js +0 -20
  74. package/dist/SequenceSearchAdapter/SequenceSearchAdapter.d.ts +0 -8
  75. package/dist/SequenceSearchAdapter/SequenceSearchAdapter.js +0 -84
  76. package/dist/SequenceSearchAdapter/configSchema.d.ts +0 -24
  77. package/dist/SequenceSearchAdapter/configSchema.js +0 -28
  78. package/dist/SequenceSearchAdapter/index.d.ts +0 -2
  79. package/dist/SequenceSearchAdapter/index.js +0 -54
  80. package/dist/TwoBitAdapter/TwoBitAdapter.d.ts +0 -28
  81. package/dist/TwoBitAdapter/TwoBitAdapter.js +0 -85
  82. package/dist/TwoBitAdapter/configSchema.d.ts +0 -18
  83. package/dist/TwoBitAdapter/configSchema.js +0 -43
  84. package/dist/TwoBitAdapter/index.d.ts +0 -2
  85. package/dist/TwoBitAdapter/index.js +0 -52
  86. package/dist/UnindexedFastaAdapter/UnindexedFastaAdapter.d.ts +0 -31
  87. package/dist/UnindexedFastaAdapter/UnindexedFastaAdapter.js +0 -86
  88. package/dist/UnindexedFastaAdapter/configSchema.d.ts +0 -23
  89. package/dist/UnindexedFastaAdapter/configSchema.js +0 -40
  90. package/dist/UnindexedFastaAdapter/index.d.ts +0 -2
  91. package/dist/UnindexedFastaAdapter/index.js +0 -54
  92. package/dist/createExtensionPoints.d.ts +0 -2
  93. package/dist/createExtensionPoints.js +0 -86
  94. package/dist/index.d.ts +0 -6
  95. package/dist/index.js +0 -35
@@ -1,40 +0,0 @@
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
- class ChromSizesAdapter extends BaseAdapter_1.BaseAdapter {
6
- async setupPre() {
7
- const pm = this.pluginManager;
8
- const file = (0, io_1.openLocation)(this.getConf('chromSizesLocation'), pm);
9
- const data = await file.readFile('utf8');
10
- return Object.fromEntries(data
11
- .split(/\n|\r\n|\r/)
12
- .map(f => f.trim())
13
- .filter(f => !!f)
14
- .map(line => {
15
- const [name, length] = line.split('\t');
16
- return [name, +length];
17
- }));
18
- }
19
- async setup() {
20
- if (!this.setupP) {
21
- this.setupP = this.setupPre().catch((e) => {
22
- this.setupP = undefined;
23
- throw e;
24
- });
25
- }
26
- return this.setupP;
27
- }
28
- async getRegions() {
29
- const refSeqs = await this.setup();
30
- return Object.keys(refSeqs).map(refName => ({
31
- refName,
32
- start: 0,
33
- end: refSeqs[refName],
34
- }));
35
- }
36
- getHeader() {
37
- return {};
38
- }
39
- }
40
- exports.default = ChromSizesAdapter;
@@ -1,10 +0,0 @@
1
- declare const ChromSizesAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- chromSizesLocation: {
3
- type: string;
4
- defaultValue: {
5
- uri: string;
6
- locationType: string;
7
- };
8
- };
9
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
10
- export default ChromSizesAdapter;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const configuration_1 = require("@jbrowse/core/configuration");
4
- function x() { }
5
- const ChromSizesAdapter = (0, configuration_1.ConfigurationSchema)('ChromSizesAdapter', {
6
- chromSizesLocation: {
7
- type: 'fileLocation',
8
- defaultValue: {
9
- uri: '/path/to/species.chrom.sizes',
10
- locationType: 'UriLocation',
11
- },
12
- },
13
- }, {
14
- explicitlyTyped: true,
15
- preProcessSnapshot: snap => {
16
- return snap.uri
17
- ? {
18
- ...snap,
19
- chromSizesLocation: {
20
- uri: snap.uri,
21
- baseUri: snap.baseUri,
22
- },
23
- }
24
- : snap;
25
- },
26
- });
27
- exports.default = ChromSizesAdapter;
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function ChromSizesAdapterF(pluginManager: PluginManager): void;
@@ -1,52 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.default = ChromSizesAdapterF;
40
- const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
41
- const configSchema_1 = __importDefault(require("./configSchema"));
42
- function ChromSizesAdapterF(pluginManager) {
43
- pluginManager.addAdapterType(() => new AdapterType_1.default({
44
- name: 'ChromSizesAdapter',
45
- displayName: 'Chrom sizes adapter',
46
- configSchema: configSchema_1.default,
47
- adapterMetadata: {
48
- hiddenFromGUI: true,
49
- },
50
- getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./ChromSizesAdapter'))).then(r => r.default),
51
- }));
52
- }
@@ -1,18 +0,0 @@
1
- import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
2
- import type { Feature, Region } from '@jbrowse/core/util';
3
- declare const DivSequenceRendering: ({ exportSVG, features, regions, colorByCDS, bpPerPx, rowHeight, sequenceHeight, showForward, showReverse, showTranslation, }: {
4
- exportSVG?: {
5
- rasterizeLayers: boolean;
6
- };
7
- features: Map<string, Feature>;
8
- regions: Region[];
9
- colorByCDS: boolean;
10
- bpPerPx: number;
11
- rowHeight: number;
12
- sequenceHeight: number;
13
- config: AnyConfigurationModel;
14
- showForward?: boolean;
15
- showReverse?: boolean;
16
- showTranslation?: boolean;
17
- }) => import("react/jsx-runtime").JSX.Element;
18
- export default DivSequenceRendering;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
5
- const util_1 = require("@jbrowse/core/util");
6
- const material_1 = require("@mui/material");
7
- const mobx_react_1 = require("mobx-react");
8
- function Translation({ codonTable, seq, frame, width, bpPerPx, colorByCDS, region, seqStart, height, y, reverse = false, }) {
9
- var _a, _b;
10
- const normalizedFrame = Math.abs(frame) - 1;
11
- const seqFrame = seqStart % 3;
12
- const frameShift = (normalizedFrame - seqFrame + 3) % 3;
13
- const theme = (0, material_1.useTheme)();
14
- const frameShiftAdjustedSeqLength = seq.length - frameShift;
15
- const multipleOfThreeLength = frameShiftAdjustedSeqLength - (frameShiftAdjustedSeqLength % 3);
16
- const seqSliced = seq.slice(frameShift, frameShift + multipleOfThreeLength);
17
- const translated = [];
18
- for (let i = 0; i < seqSliced.length; i += 3) {
19
- const codon = seqSliced.slice(i, i + 3);
20
- const normalizedCodon = reverse ? (0, util_1.revcom)(codon) : codon;
21
- const aminoAcid = codonTable[normalizedCodon] || '';
22
- translated.push({
23
- letter: aminoAcid,
24
- codon: normalizedCodon.toUpperCase(),
25
- });
26
- }
27
- const codonWidth = (1 / bpPerPx) * 3;
28
- const renderLetter = 1 / bpPerPx >= 12;
29
- const frameOffset = frameShift / bpPerPx;
30
- const startOffset = (region.start - seqStart) / bpPerPx;
31
- const offset = frameOffset - startOffset;
32
- const dark = theme.palette.mode === 'dark' ? 'dark' : 'main';
33
- const defaultFill = colorByCDS
34
- ? (_a = theme.palette.framesCDS.at(frame)) === null || _a === void 0 ? void 0 : _a[dark]
35
- : (_b = theme.palette.frames.at(frame)) === null || _b === void 0 ? void 0 : _b[dark];
36
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("rect", { x: 0, y: y, width: width, height: height, fill: defaultFill }), translated.map((element, index) => {
37
- const x = region.reversed
38
- ? width - (index + 1) * codonWidth - offset
39
- : codonWidth * index + offset;
40
- const { letter, codon } = element;
41
- const codonFill = util_1.defaultStarts.includes(codon)
42
- ? theme.palette.startCodon
43
- : util_1.defaultStops.includes(codon)
44
- ? theme.palette.stopCodon
45
- : undefined;
46
- return !(renderLetter || codonFill) ? null : ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("rect", { x: x, y: y, width: renderLetter
47
- ? codonWidth
48
- : codonWidth + 0.7, height: height, stroke: renderLetter ? '#555' : 'none', fill: codonFill || 'none' }), renderLetter ? ((0, jsx_runtime_1.jsx)("text", { x: x + codonWidth / 2, fontSize: height - 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle", children: letter })) : null] }, `${index}-${letter}`));
49
- })] }));
50
- }
51
- function Sequence({ bpPerPx, region, feature, sequenceType, height, seq, y, }) {
52
- const render = 1 / bpPerPx >= 12;
53
- const s = feature.get('start');
54
- const e = feature.get('end');
55
- const [leftPx, rightPx] = (0, util_1.bpSpanPx)(s, e, region, bpPerPx);
56
- const reverse = region.reversed;
57
- const len = e - s;
58
- const w = Math.max((rightPx - leftPx) / len, 0.8);
59
- const theme = (0, material_1.useTheme)();
60
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: seq.split('').map((letter, index) => {
61
- const color = sequenceType === 'dna'
62
- ?
63
- theme.palette.bases[letter.toUpperCase()]
64
- : undefined;
65
- const dark = theme.palette.mode === 'dark';
66
- const x = reverse ? rightPx - (index + 1) * w : leftPx + index * w;
67
- return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("rect", { x: x, y: y, width: w, height: height, fill: color ? (dark ? color.dark : color.main) : '#aaa', stroke: render ? '#555' : 'none' }), render ? ((0, jsx_runtime_1.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}`));
68
- }) }));
69
- }
70
- function SequenceSVG({ regions, width, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
71
- const region = regions[0];
72
- const codonTable = (0, util_1.generateCodonTable)(util_1.defaultCodonTable);
73
- const [feature] = [...features.values()];
74
- if (!feature) {
75
- return null;
76
- }
77
- const seq = feature.get('seq');
78
- if (!seq) {
79
- return null;
80
- }
81
- let currY = -rowHeight;
82
- const showSequence = bpPerPx <= 1;
83
- const forwardFrames = showTranslation && showForward ? [3, 2, 1] : [];
84
- const reverseFrames = showTranslation && showReverse ? [-1, -2, -3] : [];
85
- const [topFrames, bottomFrames] = region.reversed
86
- ? [reverseFrames.toReversed(), forwardFrames.toReversed()]
87
- : [forwardFrames, reverseFrames];
88
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [topFrames.map(index => ((0, jsx_runtime_1.jsx)(Translation, { width: width, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), height: rowHeight, reverse: region.reversed }, `translation-${index}`))), showForward && showSequence ? ((0, jsx_runtime_1.jsx)(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? (0, util_1.complement)(seq) : seq, bpPerPx: bpPerPx })) : null, showReverse && showSequence ? ((0, jsx_runtime_1.jsx)(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : (0, util_1.complement)(seq), bpPerPx: bpPerPx })) : null, bottomFrames.map(index => ((0, jsx_runtime_1.jsx)(Translation, { width: width, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), height: rowHeight, reverse: !region.reversed }, `rev-translation-${index}`)))] }));
89
- }
90
- function Wrapper({ exportSVG, width, totalHeight, children, }) {
91
- return exportSVG ? (children) : ((0, jsx_runtime_1.jsx)("svg", { "data-testid": "sequence_track", width: width, height: totalHeight, style: {
92
- display: 'block',
93
- width,
94
- height: totalHeight,
95
- userSelect: 'none',
96
- }, children: children }));
97
- }
98
- const DivSequenceRendering = (0, mobx_react_1.observer)(function ({ exportSVG, features, regions, colorByCDS, bpPerPx, rowHeight, sequenceHeight, showForward, showReverse, showTranslation, }) {
99
- const region = regions[0];
100
- const width = Math.ceil((region.end - region.start) / bpPerPx);
101
- return ((0, jsx_runtime_1.jsx)(Wrapper, { exportSVG: exportSVG, totalHeight: sequenceHeight, width: width, children: (0, jsx_runtime_1.jsx)(SequenceSVG, { width: width, showReverse: showReverse, showForward: showForward, showTranslation: showTranslation, colorByCDS: colorByCDS, bpPerPx: bpPerPx, rowHeight: rowHeight, features: features, regions: regions }) }));
102
- });
103
- exports.default = DivSequenceRendering;
@@ -1,8 +0,0 @@
1
- declare const DivSequenceRenderer: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- height: {
3
- type: string;
4
- description: string;
5
- defaultValue: number;
6
- };
7
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
8
- export default DivSequenceRenderer;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const configuration_1 = require("@jbrowse/core/configuration");
4
- function x() { }
5
- const DivSequenceRenderer = (0, configuration_1.ConfigurationSchema)('DivSequenceRenderer', {
6
- height: {
7
- type: 'number',
8
- description: 'height in pixels of each line of sequence',
9
- defaultValue: 16,
10
- },
11
- }, { explicitlyTyped: true });
12
- exports.default = DivSequenceRenderer;
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function DivSequenceRendererF(pluginManager: PluginManager): void;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = DivSequenceRendererF;
7
- const FeatureRendererType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType"));
8
- const DivSequenceRendering_1 = __importDefault(require("./components/DivSequenceRendering"));
9
- const configSchema_1 = __importDefault(require("./configSchema"));
10
- class DivSequenceRenderer extends FeatureRendererType_1.default {
11
- constructor() {
12
- super(...arguments);
13
- this.supportsSVG = true;
14
- }
15
- getExpandedRegion(region) {
16
- return {
17
- ...region,
18
- start: Math.max(region.start - 3, 0),
19
- end: region.end + 3,
20
- };
21
- }
22
- }
23
- function DivSequenceRendererF(pluginManager) {
24
- pluginManager.addRendererType(() => new DivSequenceRenderer({
25
- name: 'DivSequenceRenderer',
26
- ReactComponent: DivSequenceRendering_1.default,
27
- configSchema: configSchema_1.default,
28
- pluginManager,
29
- }));
30
- }
@@ -1,25 +0,0 @@
1
- import { IndexedFasta } from '@gmod/indexedfasta';
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';
6
- export default class IndexedFastaAdapter extends BaseSequenceAdapter {
7
- protected setupP?: Promise<{
8
- fasta: IndexedFasta;
9
- }>;
10
- private seqCache;
11
- getRefNames(_opts?: BaseOptions): Promise<string[]>;
12
- getRegions(_opts?: BaseOptions): Promise<{
13
- refName: string;
14
- start: number;
15
- end: number;
16
- }[]>;
17
- setupPre(): Promise<{
18
- fasta: IndexedFasta;
19
- }>;
20
- getHeader(): Promise<string | null>;
21
- setup(): Promise<{
22
- fasta: IndexedFasta;
23
- }>;
24
- getFeatures(region: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
25
- }
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const abortable_promise_cache_1 = __importDefault(require("@gmod/abortable-promise-cache"));
7
- const indexedfasta_1 = require("@gmod/indexedfasta");
8
- const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
9
- const util_1 = require("@jbrowse/core/util");
10
- const QuickLRU_1 = __importDefault(require("@jbrowse/core/util/QuickLRU"));
11
- const io_1 = require("@jbrowse/core/util/io");
12
- const rxjs_1 = require("@jbrowse/core/util/rxjs");
13
- const stopToken_1 = require("@jbrowse/core/util/stopToken");
14
- class IndexedFastaAdapter extends BaseAdapter_1.BaseSequenceAdapter {
15
- constructor() {
16
- super(...arguments);
17
- this.seqCache = new abortable_promise_cache_1.default({
18
- cache: new QuickLRU_1.default({ maxSize: 200 }),
19
- fill: async (args) => {
20
- const { refName, start, end, fasta } = args;
21
- return fasta.getSequence(refName, start, end);
22
- },
23
- });
24
- }
25
- async getRefNames(_opts) {
26
- const { fasta } = await this.setup();
27
- return fasta.getSequenceNames();
28
- }
29
- async getRegions(_opts) {
30
- const { fasta } = await this.setup();
31
- const seqSizes = await fasta.getSequenceSizes();
32
- return Object.keys(seqSizes).map(refName => ({
33
- refName,
34
- start: 0,
35
- end: seqSizes[refName],
36
- }));
37
- }
38
- async setupPre() {
39
- const fastaLocation = this.getConf('fastaLocation');
40
- const faiLocation = this.getConf('faiLocation');
41
- return {
42
- fasta: new indexedfasta_1.IndexedFasta({
43
- fasta: (0, io_1.openLocation)(fastaLocation, this.pluginManager),
44
- fai: (0, io_1.openLocation)(faiLocation, this.pluginManager),
45
- }),
46
- };
47
- }
48
- async getHeader() {
49
- const loc = this.getConf('metadataLocation');
50
- return loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml'
51
- ? null
52
- : (0, io_1.openLocation)(loc, this.pluginManager).readFile('utf8');
53
- }
54
- async setup() {
55
- if (!this.setupP) {
56
- this.setupP = this.setupPre().catch((e) => {
57
- this.setupP = undefined;
58
- throw e;
59
- });
60
- }
61
- return this.setupP;
62
- }
63
- getFeatures(region, opts) {
64
- const { statusCallback = () => { }, stopToken } = opts || {};
65
- const { refName, start, end } = region;
66
- return (0, rxjs_1.ObservableCreate)(async (observer) => {
67
- await (0, util_1.updateStatus2)('Downloading sequence', statusCallback, stopToken, async () => {
68
- const { fasta } = await this.setup();
69
- const size = await fasta.getSequenceSize(refName);
70
- const regionEnd = Math.min(size || 0, end);
71
- const chunks = [];
72
- const chunkSize = 128000;
73
- const s = start - (start % chunkSize);
74
- const e = end + (chunkSize - (end % chunkSize));
75
- for (let chunkStart = s; chunkStart < e; chunkStart += chunkSize) {
76
- const r = {
77
- refName,
78
- start: chunkStart,
79
- end: chunkStart + chunkSize,
80
- };
81
- (0, stopToken_1.checkStopToken)(stopToken);
82
- const res = await this.seqCache.get(JSON.stringify(r), {
83
- ...r,
84
- fasta,
85
- });
86
- if (!res) {
87
- break;
88
- }
89
- chunks.push(res);
90
- }
91
- const seq = chunks
92
- .filter(f => !!f)
93
- .join('')
94
- .slice(start - s)
95
- .slice(0, end - start);
96
- if (seq) {
97
- observer.next(new util_1.SimpleFeature({
98
- id: `${refName}-${start}-${regionEnd}`,
99
- data: {
100
- refName,
101
- start,
102
- end: regionEnd,
103
- seq,
104
- },
105
- }));
106
- }
107
- });
108
- observer.complete();
109
- });
110
- }
111
- }
112
- exports.default = IndexedFastaAdapter;
@@ -1,25 +0,0 @@
1
- declare const IndexedFastaAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- fastaLocation: {
3
- type: string;
4
- defaultValue: {
5
- uri: string;
6
- locationType: string;
7
- };
8
- };
9
- faiLocation: {
10
- type: string;
11
- defaultValue: {
12
- uri: string;
13
- locationType: string;
14
- };
15
- };
16
- metadataLocation: {
17
- description: string;
18
- type: string;
19
- defaultValue: {
20
- uri: string;
21
- locationType: string;
22
- };
23
- };
24
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
25
- export default IndexedFastaAdapter;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const configuration_1 = require("@jbrowse/core/configuration");
4
- function x() { }
5
- const IndexedFastaAdapter = (0, configuration_1.ConfigurationSchema)('IndexedFastaAdapter', {
6
- fastaLocation: {
7
- type: 'fileLocation',
8
- defaultValue: { uri: '/path/to/seq.fa', locationType: 'UriLocation' },
9
- },
10
- faiLocation: {
11
- type: 'fileLocation',
12
- defaultValue: { uri: '/path/to/seq.fa.fai', locationType: 'UriLocation' },
13
- },
14
- metadataLocation: {
15
- description: 'Optional metadata file',
16
- type: 'fileLocation',
17
- defaultValue: {
18
- uri: '/path/to/fa.metadata.yaml',
19
- locationType: 'UriLocation',
20
- },
21
- },
22
- }, {
23
- explicitlyTyped: true,
24
- preProcessSnapshot: snap => {
25
- return snap.uri
26
- ? {
27
- ...snap,
28
- fastaLocation: {
29
- uri: snap.uri,
30
- baseUri: snap.baseUri,
31
- },
32
- faiLocation: {
33
- uri: `${snap.uri}.fai`,
34
- baseUri: snap.baseUri,
35
- },
36
- }
37
- : snap;
38
- },
39
- });
40
- exports.default = IndexedFastaAdapter;
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function IndexedFastaAdapterF(pluginManager: PluginManager): void;
@@ -1,54 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.default = IndexedFastaAdapterF;
40
- const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
41
- const configSchema_1 = __importDefault(require("./configSchema"));
42
- function IndexedFastaAdapterF(pluginManager) {
43
- pluginManager.addAdapterType(() => {
44
- return new AdapterType_1.default({
45
- name: 'IndexedFastaAdapter',
46
- displayName: 'Indexed FASTA adapter',
47
- configSchema: configSchema_1.default,
48
- adapterMetadata: {
49
- hiddenFromGUI: true,
50
- },
51
- getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./IndexedFastaAdapter'))).then(r => r.default),
52
- });
53
- });
54
- }
@@ -1,9 +0,0 @@
1
- export declare const configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- renderer: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
3
- height: {
4
- type: string;
5
- description: string;
6
- defaultValue: number;
7
- };
8
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
9
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "displayId">>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.configSchema = void 0;
7
- const configuration_1 = require("@jbrowse/core/configuration");
8
- const configSchema_1 = __importDefault(require("../DivSequenceRenderer/configSchema"));
9
- function x() { }
10
- exports.configSchema = (0, configuration_1.ConfigurationSchema)('LinearReferenceSequenceDisplay', {
11
- renderer: configSchema_1.default,
12
- }, { explicitIdentifier: 'displayId', explicitlyTyped: true });
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function LinearReferenceSequenceDisplayF(pluginManager: PluginManager): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = LinearReferenceSequenceDisplayF;
4
- const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
5
- const plugin_linear_genome_view_1 = require("@jbrowse/plugin-linear-genome-view");
6
- const configSchema_1 = require("./configSchema");
7
- const model_1 = require("./model");
8
- function LinearReferenceSequenceDisplayF(pluginManager) {
9
- pluginManager.addDisplayType(() => {
10
- const stateModel = (0, model_1.modelFactory)(configSchema_1.configSchema);
11
- return new pluggableElementTypes_1.DisplayType({
12
- name: 'LinearReferenceSequenceDisplay',
13
- configSchema: configSchema_1.configSchema,
14
- stateModel,
15
- displayName: 'Reference sequence display',
16
- trackType: 'ReferenceSequenceTrack',
17
- viewType: 'LinearGenomeView',
18
- ReactComponent: plugin_linear_genome_view_1.BaseLinearDisplayComponent,
19
- });
20
- });
21
- }