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