@jbrowse/plugin-comparative-adapters 2.16.1 → 2.18.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 (101) hide show
  1. package/dist/BlastTabularAdapter/BlastTabularAdapter.d.ts +66 -0
  2. package/dist/BlastTabularAdapter/BlastTabularAdapter.js +200 -0
  3. package/dist/BlastTabularAdapter/configSchema.d.ts +30 -0
  4. package/dist/BlastTabularAdapter/configSchema.js +34 -0
  5. package/dist/BlastTabularAdapter/index.d.ts +2 -0
  6. package/dist/BlastTabularAdapter/index.js +42 -0
  7. package/dist/ChainAdapter/ChainAdapter.d.ts +1 -1
  8. package/dist/ChainAdapter/ChainAdapter.js +3 -6
  9. package/dist/ChainAdapter/configSchema.d.ts +0 -14
  10. package/dist/ChainAdapter/configSchema.js +1 -19
  11. package/dist/ChainAdapter/index.d.ts +1 -1
  12. package/dist/ChainAdapter/util.js +3 -50
  13. package/dist/DeltaAdapter/DeltaAdapter.d.ts +1 -1
  14. package/dist/DeltaAdapter/DeltaAdapter.js +3 -6
  15. package/dist/DeltaAdapter/configSchema.d.ts +0 -14
  16. package/dist/DeltaAdapter/configSchema.js +1 -19
  17. package/dist/DeltaAdapter/index.d.ts +1 -1
  18. package/dist/DeltaAdapter/util.js +4 -31
  19. package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.d.ts +3 -7
  20. package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +2 -15
  21. package/dist/MCScanAnchorsAdapter/configSchema.d.ts +0 -12
  22. package/dist/MCScanAnchorsAdapter/configSchema.js +1 -16
  23. package/dist/MCScanAnchorsAdapter/index.d.ts +1 -1
  24. package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.d.ts +4 -8
  25. package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +2 -13
  26. package/dist/MCScanSimpleAnchorsAdapter/configSchema.d.ts +0 -12
  27. package/dist/MCScanSimpleAnchorsAdapter/configSchema.js +1 -16
  28. package/dist/MCScanSimpleAnchorsAdapter/index.d.ts +1 -1
  29. package/dist/MashMapAdapter/MashMapAdapter.d.ts +13 -2
  30. package/dist/MashMapAdapter/MashMapAdapter.js +2 -5
  31. package/dist/MashMapAdapter/configSchema.d.ts +0 -12
  32. package/dist/MashMapAdapter/configSchema.js +1 -16
  33. package/dist/MashMapAdapter/index.d.ts +1 -1
  34. package/dist/PAFAdapter/PAFAdapter.d.ts +6 -5
  35. package/dist/PAFAdapter/PAFAdapter.js +5 -18
  36. package/dist/PAFAdapter/configSchema.d.ts +0 -12
  37. package/dist/PAFAdapter/configSchema.js +1 -16
  38. package/dist/PAFAdapter/index.d.ts +1 -1
  39. package/dist/PAFAdapter/util.d.ts +1 -1
  40. package/dist/PAFAdapter/util.js +1 -36
  41. package/dist/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.d.ts +7 -6
  42. package/dist/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.js +5 -6
  43. package/dist/PairwiseIndexedPAFAdapter/configSchema.d.ts +0 -21
  44. package/dist/PairwiseIndexedPAFAdapter/configSchema.js +1 -25
  45. package/dist/PairwiseIndexedPAFAdapter/index.d.ts +1 -1
  46. package/dist/SyntenyFeature/index.js +0 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +7 -5
  49. package/dist/util.d.ts +4 -4
  50. package/dist/util.js +9 -6
  51. package/esm/BlastTabularAdapter/BlastTabularAdapter.d.ts +66 -0
  52. package/esm/BlastTabularAdapter/BlastTabularAdapter.js +195 -0
  53. package/esm/BlastTabularAdapter/configSchema.d.ts +30 -0
  54. package/esm/BlastTabularAdapter/configSchema.js +32 -0
  55. package/esm/BlastTabularAdapter/index.d.ts +2 -0
  56. package/esm/BlastTabularAdapter/index.js +13 -0
  57. package/esm/ChainAdapter/ChainAdapter.d.ts +1 -1
  58. package/esm/ChainAdapter/ChainAdapter.js +3 -6
  59. package/esm/ChainAdapter/configSchema.d.ts +0 -14
  60. package/esm/ChainAdapter/configSchema.js +1 -19
  61. package/esm/ChainAdapter/index.d.ts +1 -1
  62. package/esm/ChainAdapter/util.js +3 -50
  63. package/esm/DeltaAdapter/DeltaAdapter.d.ts +1 -1
  64. package/esm/DeltaAdapter/DeltaAdapter.js +3 -6
  65. package/esm/DeltaAdapter/configSchema.d.ts +0 -14
  66. package/esm/DeltaAdapter/configSchema.js +1 -19
  67. package/esm/DeltaAdapter/index.d.ts +1 -1
  68. package/esm/DeltaAdapter/util.js +4 -31
  69. package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.d.ts +3 -7
  70. package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +4 -17
  71. package/esm/MCScanAnchorsAdapter/configSchema.d.ts +0 -12
  72. package/esm/MCScanAnchorsAdapter/configSchema.js +1 -16
  73. package/esm/MCScanAnchorsAdapter/index.d.ts +1 -1
  74. package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.d.ts +4 -8
  75. package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +4 -15
  76. package/esm/MCScanSimpleAnchorsAdapter/configSchema.d.ts +0 -12
  77. package/esm/MCScanSimpleAnchorsAdapter/configSchema.js +1 -16
  78. package/esm/MCScanSimpleAnchorsAdapter/index.d.ts +1 -1
  79. package/esm/MashMapAdapter/MashMapAdapter.d.ts +13 -2
  80. package/esm/MashMapAdapter/MashMapAdapter.js +2 -5
  81. package/esm/MashMapAdapter/configSchema.d.ts +0 -12
  82. package/esm/MashMapAdapter/configSchema.js +1 -16
  83. package/esm/MashMapAdapter/index.d.ts +1 -1
  84. package/esm/PAFAdapter/PAFAdapter.d.ts +6 -5
  85. package/esm/PAFAdapter/PAFAdapter.js +7 -20
  86. package/esm/PAFAdapter/configSchema.d.ts +0 -12
  87. package/esm/PAFAdapter/configSchema.js +1 -16
  88. package/esm/PAFAdapter/index.d.ts +1 -1
  89. package/esm/PAFAdapter/util.d.ts +1 -1
  90. package/esm/PAFAdapter/util.js +1 -36
  91. package/esm/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.d.ts +7 -6
  92. package/esm/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.js +6 -7
  93. package/esm/PairwiseIndexedPAFAdapter/configSchema.d.ts +0 -21
  94. package/esm/PairwiseIndexedPAFAdapter/configSchema.js +1 -25
  95. package/esm/PairwiseIndexedPAFAdapter/index.d.ts +1 -1
  96. package/esm/SyntenyFeature/index.js +0 -1
  97. package/esm/index.d.ts +1 -1
  98. package/esm/index.js +7 -5
  99. package/esm/util.d.ts +4 -4
  100. package/esm/util.js +10 -7
  101. package/package.json +2 -2
@@ -0,0 +1,66 @@
1
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
2
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import type { Feature, Region } from '@jbrowse/core/util';
4
+ interface BlastColumns {
5
+ qseqid?: string;
6
+ qgi?: string;
7
+ qacc?: string;
8
+ sseqid?: string;
9
+ sallseqid?: string;
10
+ sgi?: string;
11
+ sallgi?: string;
12
+ sacc?: string;
13
+ sallacc?: string;
14
+ qstart?: number;
15
+ qend?: number;
16
+ sstart?: number;
17
+ send?: number;
18
+ qseq?: string;
19
+ sseq?: string;
20
+ evalue?: string;
21
+ bitscore?: string;
22
+ score?: string;
23
+ length?: string;
24
+ pident?: string;
25
+ nident?: string;
26
+ mismatch?: string;
27
+ positive?: string;
28
+ gapopen?: string;
29
+ gaps?: string;
30
+ ppos?: string;
31
+ frames?: string;
32
+ qframe?: string;
33
+ sframe?: string;
34
+ btop?: string;
35
+ staxids?: string;
36
+ sscinames?: string;
37
+ scomnames?: string;
38
+ sblastnames?: string;
39
+ sskingdoms?: string;
40
+ stitle?: string;
41
+ salltitles?: string;
42
+ sstrand?: string;
43
+ qcovs?: string;
44
+ qcovhsp?: string;
45
+ qcovus?: string;
46
+ }
47
+ interface BlastRecord extends BlastColumns {
48
+ qseqid: string;
49
+ sseqid: string;
50
+ qstart: number;
51
+ qend: number;
52
+ sstart: number;
53
+ send: number;
54
+ }
55
+ export default class BlastTabularAdapter extends BaseFeatureDataAdapter {
56
+ private data;
57
+ static capabilities: string[];
58
+ getData(opts?: BaseOptions): Promise<BlastRecord[]>;
59
+ setup(opts?: BaseOptions): Promise<BlastRecord[]>;
60
+ hasDataForRefName(): Promise<boolean>;
61
+ getAssemblyNames(): string[];
62
+ getRefNames(opts?: BaseOptions): Promise<string[]>;
63
+ getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
64
+ freeResources(): void;
65
+ }
66
+ export {};
@@ -0,0 +1,200 @@
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 configuration_1 = require("@jbrowse/core/configuration");
7
+ const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
8
+ const util_1 = require("@jbrowse/core/util");
9
+ const io_1 = require("@jbrowse/core/util/io");
10
+ const rxjs_1 = require("@jbrowse/core/util/rxjs");
11
+ const SyntenyFeature_1 = __importDefault(require("../SyntenyFeature"));
12
+ const util_2 = require("../util");
13
+ function createBlastLineParser(columns) {
14
+ const columnNames = columns.trim().split(' ');
15
+ const qseqidIndex = columnNames.indexOf('qseqid');
16
+ if (qseqidIndex === -1) {
17
+ throw new Error('Missing required column "qseqid"');
18
+ }
19
+ const sseqidIndex = columnNames.indexOf('sseqid');
20
+ if (sseqidIndex === -1) {
21
+ throw new Error('Missing required column "sseqid"');
22
+ }
23
+ const qstartIndex = columnNames.indexOf('qstart');
24
+ if (qstartIndex === -1) {
25
+ throw new Error('Missing required column "qstart"');
26
+ }
27
+ const qendIndex = columnNames.indexOf('qend');
28
+ if (qendIndex === -1) {
29
+ throw new Error('Missing required column "qend"');
30
+ }
31
+ const sstartIndex = columnNames.indexOf('sstart');
32
+ if (sstartIndex === -1) {
33
+ throw new Error('Missing required column "sstart"');
34
+ }
35
+ const sendIndex = columnNames.indexOf('send');
36
+ if (sendIndex === -1) {
37
+ throw new Error('Missing required column "send"');
38
+ }
39
+ const columnNameSet = new Map(columnNames
40
+ .map((c, idx) => [c, idx])
41
+ .filter(f => !['qseqid', 'sseqid', 'qstart', 'qend', 'sstart', 'send'].includes(f[0])));
42
+ return (line) => {
43
+ if (line.startsWith('#')) {
44
+ return;
45
+ }
46
+ const row = line.split('\t');
47
+ const qseqid = row[qseqidIndex];
48
+ const sseqid = row[sseqidIndex];
49
+ const qstart = row[qstartIndex];
50
+ const qend = row[qendIndex];
51
+ const sstart = row[sstartIndex];
52
+ const send = row[sendIndex];
53
+ if (!(qseqid && sseqid && qstart && qend && sstart && send)) {
54
+ console.warn('Invalid BLAST line');
55
+ console.warn(line);
56
+ return;
57
+ }
58
+ const record = {
59
+ qseqid,
60
+ sseqid,
61
+ qstart: Number.parseInt(qstart),
62
+ qend: Number.parseInt(qend),
63
+ sstart: Number.parseInt(sstart),
64
+ send: Number.parseInt(send),
65
+ };
66
+ for (const [columnName, idx] of columnNameSet.entries()) {
67
+ const value = row[idx];
68
+ if (!value) {
69
+ continue;
70
+ }
71
+ record[columnName] = value;
72
+ }
73
+ return record;
74
+ };
75
+ }
76
+ class BlastTabularAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
77
+ getData(opts) {
78
+ if (!this.data) {
79
+ this.data = this.setup(opts).catch((e) => {
80
+ this.data = undefined;
81
+ throw e;
82
+ });
83
+ }
84
+ return this.data;
85
+ }
86
+ async setup(opts) {
87
+ const pm = this.pluginManager;
88
+ const buf = await (0, util_1.fetchAndMaybeUnzip)((0, io_1.openLocation)((0, configuration_1.readConfObject)(this.config, 'blastTableLocation'), pm), opts);
89
+ const columns = (0, configuration_1.readConfObject)(this.config, 'columns');
90
+ return (0, util_2.parseLineByLine)(buf, createBlastLineParser(columns));
91
+ }
92
+ async hasDataForRefName() {
93
+ return true;
94
+ }
95
+ getAssemblyNames() {
96
+ const assemblyNames = this.getConf('assemblyNames');
97
+ if (assemblyNames.length === 0) {
98
+ const query = this.getConf('queryAssembly');
99
+ const target = this.getConf('targetAssembly');
100
+ return [query, target];
101
+ }
102
+ return assemblyNames;
103
+ }
104
+ async getRefNames(opts = {}) {
105
+ var _a;
106
+ const r1 = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0].assemblyName;
107
+ const feats = await this.getData(opts);
108
+ const idx = this.getAssemblyNames().indexOf(r1);
109
+ if (idx !== -1) {
110
+ const set = new Set();
111
+ for (const feat of feats) {
112
+ set.add(idx === 0 ? feat.qseqid : feat.sseqid);
113
+ }
114
+ return [...set];
115
+ }
116
+ console.warn('Unable to do ref renaming on adapter');
117
+ return [];
118
+ }
119
+ getFeatures(query, opts = {}) {
120
+ return (0, rxjs_1.ObservableCreate)(async (observer) => {
121
+ const blastRecords = await this.getData(opts);
122
+ const [queryAssembly, targetAssembly] = this.getAssemblyNames();
123
+ const { refName: queryRefName, assemblyName: queryAssemblyName, start: queryStart, end: queryEnd, } = query;
124
+ if (queryAssemblyName !== targetAssembly &&
125
+ queryAssemblyName !== queryAssembly) {
126
+ console.warn(`${queryAssemblyName} not found in this adapter`);
127
+ observer.complete();
128
+ return;
129
+ }
130
+ for (let i = 0; i < blastRecords.length; i++) {
131
+ const r = blastRecords[i];
132
+ let start;
133
+ let end;
134
+ let refName;
135
+ let assemblyName;
136
+ let mateStart;
137
+ let mateEnd;
138
+ let mateRefName;
139
+ let mateAssemblyName;
140
+ const { qseqid, sseqid, qstart, qend, sstart, send, ...rest } = r;
141
+ if (queryAssemblyName === queryAssembly) {
142
+ start = qstart;
143
+ end = qend;
144
+ refName = qseqid;
145
+ assemblyName = queryAssembly;
146
+ mateStart = sstart;
147
+ mateEnd = send;
148
+ mateRefName = sseqid;
149
+ mateAssemblyName = targetAssembly;
150
+ }
151
+ else {
152
+ start = sstart;
153
+ end = send;
154
+ refName = sseqid;
155
+ assemblyName = targetAssembly;
156
+ mateStart = qstart;
157
+ mateEnd = qend;
158
+ mateRefName = qseqid;
159
+ mateAssemblyName = queryAssembly;
160
+ }
161
+ let strand = 1;
162
+ let mateStrand = 1;
163
+ if (start > end) {
164
+ ;
165
+ [start, end] = [end, start];
166
+ strand = -1;
167
+ }
168
+ if (mateStart > mateEnd) {
169
+ ;
170
+ [mateStart, mateEnd] = [mateEnd, mateStart];
171
+ mateStrand = -1;
172
+ }
173
+ if (refName === queryRefName &&
174
+ (0, util_1.doesIntersect2)(queryStart, queryEnd, start, end)) {
175
+ observer.next(new SyntenyFeature_1.default({
176
+ uniqueId: i + queryAssemblyName,
177
+ assemblyName,
178
+ start,
179
+ end,
180
+ type: 'match',
181
+ refName,
182
+ strand: strand * mateStrand,
183
+ syntenyId: i,
184
+ ...rest,
185
+ mate: {
186
+ start: mateStart,
187
+ end: mateEnd,
188
+ refName: mateRefName,
189
+ assemblyName: mateAssemblyName,
190
+ },
191
+ }));
192
+ }
193
+ }
194
+ observer.complete();
195
+ });
196
+ }
197
+ freeResources() { }
198
+ }
199
+ BlastTabularAdapter.capabilities = ['getFeatures', 'getRefNames'];
200
+ exports.default = BlastTabularAdapter;
@@ -0,0 +1,30 @@
1
+ declare const BlastTabularAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ assemblyNames: {
3
+ type: string;
4
+ defaultValue: never[];
5
+ description: string;
6
+ };
7
+ targetAssembly: {
8
+ type: string;
9
+ defaultValue: string;
10
+ description: string;
11
+ };
12
+ queryAssembly: {
13
+ type: string;
14
+ defaultValue: string;
15
+ description: string;
16
+ };
17
+ blastTableLocation: {
18
+ type: string;
19
+ defaultValue: {
20
+ uri: string;
21
+ locationType: string;
22
+ };
23
+ };
24
+ columns: {
25
+ type: string;
26
+ description: string;
27
+ defaultValue: string;
28
+ };
29
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
30
+ export default BlastTabularAdapter;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configuration_1 = require("@jbrowse/core/configuration");
4
+ function x() { }
5
+ const BlastTabularAdapter = (0, configuration_1.ConfigurationSchema)('BlastTabularAdapter', {
6
+ assemblyNames: {
7
+ type: 'stringArray',
8
+ defaultValue: [],
9
+ description: 'Query assembly is the first value in the array, target assembly is the second',
10
+ },
11
+ targetAssembly: {
12
+ type: 'string',
13
+ defaultValue: '',
14
+ description: 'Alternative to assemblyNames array: the target assembly',
15
+ },
16
+ queryAssembly: {
17
+ type: 'string',
18
+ defaultValue: '',
19
+ description: 'Alternative to assemblyNames array: the query assembly',
20
+ },
21
+ blastTableLocation: {
22
+ type: 'fileLocation',
23
+ defaultValue: {
24
+ uri: '/path/to/blastTable.tsv',
25
+ locationType: 'UriLocation',
26
+ },
27
+ },
28
+ columns: {
29
+ type: 'string',
30
+ description: 'Optional space-separated column name list. If custom columns were used in outfmt, enter them here exactly as specified in the command. At least qseqid, sseqid, qstart, qend, sstart, and send are required',
31
+ defaultValue: 'qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore',
32
+ },
33
+ }, { explicitlyTyped: true });
34
+ exports.default = BlastTabularAdapter;
@@ -0,0 +1,2 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function BlastTabularAdapterF(pluginManager: PluginManager): void;
@@ -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 = BlastTabularAdapterF;
30
+ const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
31
+ const configSchema_1 = __importDefault(require("./configSchema"));
32
+ function BlastTabularAdapterF(pluginManager) {
33
+ pluginManager.addAdapterType(() => new AdapterType_1.default({
34
+ name: 'BlastTabularAdapter',
35
+ displayName: 'Tabular BLAST output adapter',
36
+ configSchema: configSchema_1.default,
37
+ adapterMetadata: {
38
+ hiddenFromGUI: true,
39
+ },
40
+ getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./BlastTabularAdapter'))).then(r => r.default),
41
+ }));
42
+ }
@@ -1,5 +1,5 @@
1
- import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
1
  import PAFAdapter from '../PAFAdapter/PAFAdapter';
2
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
3
3
  export default class ChainAdapter extends PAFAdapter {
4
4
  setupPre(opts?: BaseOptions): Promise<{
5
5
  qname: string;
@@ -3,17 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const io_1 = require("@jbrowse/core/util/io");
7
6
  const util_1 = require("@jbrowse/core/util");
8
- const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
9
- // locals
10
- const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
7
+ const io_1 = require("@jbrowse/core/util/io");
11
8
  const util_2 = require("./util");
9
+ const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
12
10
  class ChainAdapter extends PAFAdapter_1.default {
13
11
  async setupPre(opts) {
14
12
  const loc = (0, io_1.openLocation)(this.getConf('chainLocation'), this.pluginManager);
15
- const buffer = (await loc.readFile(opts));
16
- const buf = (0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
13
+ const buf = await (0, util_1.fetchAndMaybeUnzip)(loc, opts);
17
14
  return (0, util_2.paf_chain2paf)(buf);
18
15
  }
19
16
  }
@@ -1,33 +1,19 @@
1
1
  declare const ChainAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- /**
3
- * #slot
4
- */
5
2
  assemblyNames: {
6
3
  type: string;
7
4
  defaultValue: never[];
8
5
  description: string;
9
6
  };
10
- /**
11
- * #slot
12
- * can be specified as alternative to assemblyNames
13
- */
14
7
  targetAssembly: {
15
8
  type: string;
16
9
  defaultValue: string;
17
10
  description: string;
18
11
  };
19
- /**
20
- * #slot
21
- * can be specified as alternative to assemblyNames
22
- */
23
12
  queryAssembly: {
24
13
  type: string;
25
14
  defaultValue: string;
26
15
  description: string;
27
16
  };
28
- /**
29
- * #slot
30
- */
31
17
  chainLocation: {
32
18
  type: string;
33
19
  defaultValue: {
@@ -1,41 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const configuration_1 = require("@jbrowse/core/configuration");
4
- /**
5
- * #config ChainAdapter
6
- * #category adapter
7
- */
8
- function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ function x() { }
9
5
  const ChainAdapter = (0, configuration_1.ConfigurationSchema)('ChainAdapter', {
10
- /**
11
- * #slot
12
- */
13
6
  assemblyNames: {
14
7
  type: 'stringArray',
15
8
  defaultValue: [],
16
9
  description: 'Array of assembly names to use for this file. The query assembly name is the first value in the array, target assembly name is the second',
17
10
  },
18
- /**
19
- * #slot
20
- * can be specified as alternative to assemblyNames
21
- */
22
11
  targetAssembly: {
23
12
  type: 'string',
24
13
  defaultValue: '',
25
14
  description: 'Alternative to assemblyNames array: the target assembly',
26
15
  },
27
- /**
28
- * #slot
29
- * can be specified as alternative to assemblyNames
30
- */
31
16
  queryAssembly: {
32
17
  type: 'string',
33
18
  defaultValue: '',
34
19
  description: 'Alternative to assemblyNames array: the query assembly',
35
20
  },
36
- /**
37
- * #slot
38
- */
39
21
  chainLocation: {
40
22
  type: 'fileLocation',
41
23
  defaultValue: { uri: '/path/to/file.chain', locationType: 'UriLocation' },
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function ChainAdapterF(pluginManager: PluginManager): void;
@@ -1,31 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.paf_chain2paf = paf_chain2paf;
4
- const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
5
- /* adapted from chain2paf by Andrea Guarracino, license reproduced below
6
- *
7
- * MIT License
8
- *
9
- * Copyright (c) 2021 Andrea Guarracino
10
- *
11
- * Permission is hereby granted, free of charge, to any person obtaining a copy
12
- * of this software and associated documentation files (the "Software"), to deal
13
- * in the Software without restriction, including without limitation the rights
14
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- * copies of the Software, and to permit persons to whom the Software is
16
- * furnished to do so, subject to the following conditions:
17
- *
18
- * The above copyright notice and this permission notice shall be included in all
19
- * copies or substantial portions of the Software.
20
- *
21
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- * SOFTWARE.
28
- */
29
4
  function generate_record(qname, qstart, qend, qstrand, tname, tstart, tend, cigar, numMatches) {
30
5
  return {
31
6
  qname,
@@ -56,34 +31,21 @@ function paf_chain2paf(buffer) {
56
31
  let cigar = '';
57
32
  const records = [];
58
33
  let blockStart = 0;
34
+ const decoder = new TextDecoder('utf8');
59
35
  while (blockStart < buffer.length) {
60
36
  const n = buffer.indexOf('\n', blockStart);
61
37
  if (n === -1) {
62
38
  break;
63
39
  }
64
40
  const b = buffer.subarray(blockStart, n);
65
- const l = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
41
+ const l = decoder.decode(b).trim();
66
42
  blockStart = n + 1;
67
- const l_tab = l.replaceAll(' ', '\t'); // There are CHAIN files with space-separated fields
43
+ const l_tab = l.replaceAll(' ', '\t');
68
44
  const l_vec = l_tab.split('\t');
69
45
  if (l_vec[0] === 'chain') {
70
- // Emit previous PAF row, if available
71
46
  if (cigar) {
72
47
  records.push(generate_record(q_name, q_start, q_end, q_strand, t_name, t_start, t_end, cigar, num_matches));
73
48
  }
74
- // Save query/target information
75
- // score -- chain score
76
- // tName -- chromosome (reference sequence)
77
- // tSize -- chromosome size (reference sequence)
78
- // tStrand -- strand (reference sequence)
79
- // tStart -- alignment start position (reference sequence)
80
- // tEnd -- alignment end position (reference sequence)
81
- // qName -- chromosome (query sequence)
82
- // qSize -- chromosome size (query sequence)
83
- // qStrand -- strand (query sequence)
84
- // qStart -- alignment start position (query sequence)
85
- // qEnd -- alignment end position (query sequence)
86
- // id -- chain ID
87
49
  t_name = l_vec[2];
88
50
  t_start = +l_vec[5];
89
51
  t_end = +l_vec[6];
@@ -97,18 +59,10 @@ function paf_chain2paf(buffer) {
97
59
  q_start = +q_size - q_end;
98
60
  q_end = +q_size - tmp;
99
61
  }
100
- // Initialize PAF fields
101
62
  num_matches = 0;
102
63
  cigar = '';
103
64
  }
104
65
  else {
105
- // size -- the size of the ungapped alignment
106
- //
107
- // dt -- the difference between the end of this block and the beginning
108
- // of the next block (reference sequence)
109
- //
110
- // dq -- the difference between the end of this block and the beginning
111
- // of the next block (query sequence)
112
66
  const size_ungapped_alignment = +l_vec[0] || 0;
113
67
  const diff_in_target = l_vec.length > 1 ? +l_vec[1] : 0;
114
68
  const diff_in_query = l_vec.length > 2 ? +l_vec[2] : 0;
@@ -124,7 +78,6 @@ function paf_chain2paf(buffer) {
124
78
  }
125
79
  }
126
80
  }
127
- // Emit last PAF row, if available
128
81
  if (cigar) {
129
82
  generate_record(q_name, q_start, q_end, q_strand, t_name, t_start, t_end, cigar, num_matches);
130
83
  }
@@ -1,5 +1,5 @@
1
- import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
1
  import PAFAdapter from '../PAFAdapter/PAFAdapter';
2
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
3
3
  export default class DeltaAdapter extends PAFAdapter {
4
4
  setupPre(opts?: BaseOptions): Promise<{
5
5
  qname: string;
@@ -3,17 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const io_1 = require("@jbrowse/core/util/io");
7
- const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
8
6
  const util_1 = require("@jbrowse/core/util");
9
- // locals
10
- const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
7
+ const io_1 = require("@jbrowse/core/util/io");
11
8
  const util_2 = require("./util");
9
+ const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
12
10
  class DeltaAdapter extends PAFAdapter_1.default {
13
11
  async setupPre(opts) {
14
12
  const loc = (0, io_1.openLocation)(this.getConf('deltaLocation'), this.pluginManager);
15
- const buffer = (await loc.readFile(opts));
16
- const buf = (0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
13
+ const buf = await (0, util_1.fetchAndMaybeUnzip)(loc, opts);
17
14
  return (0, util_2.paf_delta2paf)(buf);
18
15
  }
19
16
  }
@@ -1,33 +1,19 @@
1
1
  declare const DeltaAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- /**
3
- * #slot
4
- */
5
2
  assemblyNames: {
6
3
  type: string;
7
4
  defaultValue: never[];
8
5
  description: string;
9
6
  };
10
- /**
11
- * #slot
12
- * alternative to assembly names
13
- */
14
7
  targetAssembly: {
15
8
  type: string;
16
9
  defaultValue: string;
17
10
  description: string;
18
11
  };
19
- /**
20
- * #slot
21
- * alternative to assembly names
22
- */
23
12
  queryAssembly: {
24
13
  type: string;
25
14
  defaultValue: string;
26
15
  description: string;
27
16
  };
28
- /**
29
- * #slot
30
- */
31
17
  deltaLocation: {
32
18
  type: string;
33
19
  defaultValue: {