@jbrowse/plugin-comparative-adapters 2.16.0 → 2.17.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 (47) hide show
  1. package/dist/BlastTabularAdapter/BlastTabularAdapter.d.ts +120 -0
  2. package/dist/BlastTabularAdapter/BlastTabularAdapter.js +207 -0
  3. package/dist/BlastTabularAdapter/configSchema.d.ts +45 -0
  4. package/dist/BlastTabularAdapter/configSchema.js +52 -0
  5. package/dist/BlastTabularAdapter/index.d.ts +2 -0
  6. package/dist/BlastTabularAdapter/index.js +42 -0
  7. package/dist/ChainAdapter/ChainAdapter.js +1 -3
  8. package/dist/ChainAdapter/configSchema.js +1 -1
  9. package/dist/ChainAdapter/util.js +2 -2
  10. package/dist/DeltaAdapter/DeltaAdapter.js +1 -3
  11. package/dist/DeltaAdapter/configSchema.js +5 -2
  12. package/dist/DeltaAdapter/util.js +2 -2
  13. package/dist/MashMapAdapter/MashMapAdapter.d.ts +12 -1
  14. package/dist/MashMapAdapter/MashMapAdapter.js +1 -3
  15. package/dist/MashMapAdapter/configSchema.js +1 -1
  16. package/dist/PAFAdapter/PAFAdapter.js +4 -6
  17. package/dist/PAFAdapter/configSchema.js +1 -1
  18. package/dist/PAFAdapter/util.d.ts +1 -1
  19. package/dist/PAFAdapter/util.js +1 -1
  20. package/dist/PairwiseIndexedPAFAdapter/configSchema.js +1 -1
  21. package/dist/index.js +2 -0
  22. package/dist/util.d.ts +1 -1
  23. package/dist/util.js +9 -6
  24. package/esm/BlastTabularAdapter/BlastTabularAdapter.d.ts +120 -0
  25. package/esm/BlastTabularAdapter/BlastTabularAdapter.js +202 -0
  26. package/esm/BlastTabularAdapter/configSchema.d.ts +45 -0
  27. package/esm/BlastTabularAdapter/configSchema.js +50 -0
  28. package/esm/BlastTabularAdapter/index.d.ts +2 -0
  29. package/esm/BlastTabularAdapter/index.js +13 -0
  30. package/esm/ChainAdapter/ChainAdapter.js +2 -4
  31. package/esm/ChainAdapter/configSchema.js +1 -1
  32. package/esm/ChainAdapter/util.js +2 -2
  33. package/esm/DeltaAdapter/DeltaAdapter.js +2 -4
  34. package/esm/DeltaAdapter/configSchema.js +5 -2
  35. package/esm/DeltaAdapter/util.js +2 -2
  36. package/esm/MashMapAdapter/MashMapAdapter.d.ts +12 -1
  37. package/esm/MashMapAdapter/MashMapAdapter.js +2 -4
  38. package/esm/MashMapAdapter/configSchema.js +1 -1
  39. package/esm/PAFAdapter/PAFAdapter.js +5 -7
  40. package/esm/PAFAdapter/configSchema.js +1 -1
  41. package/esm/PAFAdapter/util.d.ts +1 -1
  42. package/esm/PAFAdapter/util.js +1 -1
  43. package/esm/PairwiseIndexedPAFAdapter/configSchema.js +1 -1
  44. package/esm/index.js +2 -0
  45. package/esm/util.d.ts +1 -1
  46. package/esm/util.js +10 -7
  47. package/package.json +2 -2
@@ -9,7 +9,7 @@ export interface PAFRecord {
9
9
  extra: {
10
10
  cg?: string;
11
11
  blockLen?: number;
12
- mappingQual: number;
12
+ mappingQual?: number;
13
13
  numMatches?: number;
14
14
  meanScore?: number;
15
15
  };
@@ -45,7 +45,7 @@ function getWeightedMeans(ret) {
45
45
  if (!scoreMap[key]) {
46
46
  scoreMap[key] = { quals: [], len: [] };
47
47
  }
48
- scoreMap[key].quals.push(entry.extra.mappingQual);
48
+ scoreMap[key].quals.push(entry.extra.mappingQual || 1);
49
49
  scoreMap[key].len.push(entry.extra.blockLen || 1);
50
50
  }
51
51
  const meanScoreMap = Object.fromEntries(Object.entries(scoreMap).map(([key, val]) => {
@@ -13,7 +13,7 @@ const PairwiseIndexedPAFAdapter = (0, configuration_1.ConfigurationSchema)('Pair
13
13
  assemblyNames: {
14
14
  type: 'stringArray',
15
15
  defaultValue: [],
16
- description: 'Array of assembly names to use for this file. The target assembly name is the first value in the array, query assembly name is the second',
16
+ 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
17
  },
18
18
  /**
19
19
  * #slot
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ const MCScanSimpleAnchorsAdapter_1 = __importDefault(require("./MCScanSimpleAnch
11
11
  const MashMapAdapter_1 = __importDefault(require("./MashMapAdapter"));
12
12
  const DeltaAdapter_1 = __importDefault(require("./DeltaAdapter"));
13
13
  const ChainAdapter_1 = __importDefault(require("./ChainAdapter"));
14
+ const BlastTabularAdapter_1 = __importDefault(require("./BlastTabularAdapter"));
14
15
  const tracks_1 = require("@jbrowse/core/util/tracks");
15
16
  class ComparativeAdaptersPlugin extends Plugin_1.default {
16
17
  constructor() {
@@ -25,6 +26,7 @@ class ComparativeAdaptersPlugin extends Plugin_1.default {
25
26
  (0, MCScanAnchorsAdapter_1.default)(pluginManager);
26
27
  (0, MCScanSimpleAnchorsAdapter_1.default)(pluginManager);
27
28
  (0, MashMapAdapter_1.default)(pluginManager);
29
+ (0, BlastTabularAdapter_1.default)(pluginManager);
28
30
  pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
29
31
  return (file, index, adapterHint) => {
30
32
  const regexGuess = /\.paf/i;
package/dist/util.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare function parseBed(text: string): Map<string | undefined, {
12
12
  }>;
13
13
  export declare function readFile(file: GenericFilehandle, opts?: BaseOptions): Promise<string>;
14
14
  export declare function zip(a: number[], b: number[]): [number, number][];
15
- export declare function parseLineByLine(buffer: Buffer, cb: (line: string) => PAFRecord): PAFRecord[];
15
+ export declare function parseLineByLine<T>(buffer: Buffer, cb: (line: string) => T | undefined): T[];
16
16
  export declare function parsePAFLine(line: string): PAFRecord;
17
17
  export declare function flipCigar(cigar: string[]): (string | undefined)[];
18
18
  export declare function swapIndelCigar(cigar: string): string;
package/dist/util.js CHANGED
@@ -7,7 +7,6 @@ exports.parseLineByLine = parseLineByLine;
7
7
  exports.parsePAFLine = parsePAFLine;
8
8
  exports.flipCigar = flipCigar;
9
9
  exports.swapIndelCigar = swapIndelCigar;
10
- const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
11
10
  const util_1 = require("@jbrowse/core/util");
12
11
  function parseBed(text) {
13
12
  return new Map(text
@@ -29,25 +28,29 @@ function parseBed(text) {
29
28
  }));
30
29
  }
31
30
  async function readFile(file, opts) {
32
- const buffer = (await file.readFile(opts));
33
- return new TextDecoder('utf8', { fatal: true }).decode((0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer);
31
+ const buf = await (0, util_1.fetchAndMaybeUnzip)(file, opts);
32
+ const decoder = new TextDecoder('utf8');
33
+ return decoder.decode(buf);
34
34
  }
35
35
  function zip(a, b) {
36
36
  return a.map((e, i) => [e, b[i]]);
37
37
  }
38
- const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
39
38
  function parseLineByLine(buffer, cb) {
40
39
  let blockStart = 0;
41
40
  const entries = [];
41
+ const decoder = new TextDecoder('utf8');
42
42
  while (blockStart < buffer.length) {
43
43
  const n = buffer.indexOf('\n', blockStart);
44
44
  if (n === -1) {
45
45
  break;
46
46
  }
47
47
  const b = buffer.subarray(blockStart, n);
48
- const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
48
+ const line = decoder.decode(b).trim();
49
49
  if (line) {
50
- entries.push(cb(line));
50
+ const entry = cb(line);
51
+ if (entry) {
52
+ entries.push(entry);
53
+ }
51
54
  }
52
55
  blockStart = n + 1;
53
56
  }
@@ -0,0 +1,120 @@
1
+ import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
+ import { Feature, Region } from '@jbrowse/core/util';
3
+ interface BlastColumns {
4
+ /** Query Seq-id */
5
+ qseqid?: string;
6
+ /** Query GI */
7
+ qgi?: string;
8
+ /** Query accesion */
9
+ qacc?: string;
10
+ /** Subject Seq-id */
11
+ sseqid?: string;
12
+ /** All subject Seq-id(s), separated by a ';' */
13
+ sallseqid?: string;
14
+ /** Subject GI */
15
+ sgi?: string;
16
+ /** All subject GIs */
17
+ sallgi?: string;
18
+ /** Subject accession */
19
+ sacc?: string;
20
+ /** All subject accessions */
21
+ sallacc?: string;
22
+ /** Start of alignment in query */
23
+ qstart?: number;
24
+ /** End of alignment in query */
25
+ qend?: number;
26
+ /** Start of alignment in subject */
27
+ sstart?: number;
28
+ /** End of alignment in subject */
29
+ send?: number;
30
+ /** Aligned part of query sequence */
31
+ qseq?: string;
32
+ /** Aligned part of subject sequence */
33
+ sseq?: string;
34
+ /** Expect value */
35
+ evalue?: string;
36
+ /** Bit score */
37
+ bitscore?: string;
38
+ /** Raw score */
39
+ score?: string;
40
+ /** Alignment length */
41
+ length?: string;
42
+ /** Percentage of identical matches */
43
+ pident?: string;
44
+ /** Number of identical matches */
45
+ nident?: string;
46
+ /** Number of mismatches */
47
+ mismatch?: string;
48
+ /** Number of positive-scoring matches */
49
+ positive?: string;
50
+ /** Number of gap openings */
51
+ gapopen?: string;
52
+ /** Total number of gap */
53
+ gaps?: string;
54
+ /** Percentage of positive-scoring matches */
55
+ ppos?: string;
56
+ /** Query and subject frames separated by a '/' */
57
+ frames?: string;
58
+ /** Query frame */
59
+ qframe?: string;
60
+ /** Subject frame */
61
+ sframe?: string;
62
+ /** Blast traceback operations (BTOP) */
63
+ btop?: string;
64
+ /** Unique Subject Taxonomy ID(s), separated by a ';'(in numerical order) */
65
+ staxids?: string;
66
+ /** Unique Subject Scientific Name(s), separated by a ';' */
67
+ sscinames?: string;
68
+ /** Unique Subject Common Name(s), separated by a ';' */
69
+ scomnames?: string;
70
+ /**
71
+ * Unique Subject Blast Name(s), separated by a ';' (in alphabetical order)
72
+ */
73
+ sblastnames?: string;
74
+ /**
75
+ * Unique Subject Super Kingdom(s), separated by a ';' (in alphabetical order)
76
+ */
77
+ sskingdoms?: string;
78
+ /** Subject Title */
79
+ stitle?: string;
80
+ /** All Subject Title(s), separated by a '<>' */
81
+ salltitles?: string;
82
+ /** Subject Strand */
83
+ sstrand?: string;
84
+ /** Query Coverage Per Subject (for all HSPs) */
85
+ qcovs?: string;
86
+ /** Query Coverage Per HSP */
87
+ qcovhsp?: string;
88
+ /**
89
+ * A measure of Query Coverage that counts a position in a subject sequence
90
+ * for this measure only once. The second time the position is aligned to the
91
+ * query is not counted towards this measure.
92
+ */
93
+ qcovus?: string;
94
+ }
95
+ interface BlastRecord extends BlastColumns {
96
+ /** Query Seq-id */
97
+ qseqid: string;
98
+ /** Subject Seq-id */
99
+ sseqid: string;
100
+ /** Start of alignment in query */
101
+ qstart: number;
102
+ /** End of alignment in query */
103
+ qend: number;
104
+ /** Start of alignment in subject */
105
+ sstart: number;
106
+ /** End of alignment in subject */
107
+ send: number;
108
+ }
109
+ export default class BlastTabularAdapter extends BaseFeatureDataAdapter {
110
+ private data;
111
+ static capabilities: string[];
112
+ getData(opts?: BaseOptions): Promise<BlastRecord[]>;
113
+ setup(opts?: BaseOptions): Promise<BlastRecord[]>;
114
+ hasDataForRefName(): Promise<boolean>;
115
+ getAssemblyNames(): string[];
116
+ getRefNames(opts?: BaseOptions): Promise<string[]>;
117
+ getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
118
+ freeResources(): void;
119
+ }
120
+ export {};
@@ -0,0 +1,202 @@
1
+ import { readConfObject } from '@jbrowse/core/configuration';
2
+ import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { ObservableCreate } from '@jbrowse/core/util/rxjs';
4
+ import { doesIntersect2, fetchAndMaybeUnzip, } from '@jbrowse/core/util';
5
+ import { openLocation } from '@jbrowse/core/util/io';
6
+ import { parseLineByLine } from '../util';
7
+ import SyntenyFeature from '../SyntenyFeature';
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
+ // @ts-expect-error
67
+ record[columnName] = value;
68
+ }
69
+ return record;
70
+ };
71
+ }
72
+ class BlastTabularAdapter extends BaseFeatureDataAdapter {
73
+ getData(opts) {
74
+ if (!this.data) {
75
+ this.data = this.setup(opts).catch((e) => {
76
+ this.data = undefined;
77
+ throw e;
78
+ });
79
+ }
80
+ return this.data;
81
+ }
82
+ async setup(opts) {
83
+ const pm = this.pluginManager;
84
+ const buf = await fetchAndMaybeUnzip(openLocation(readConfObject(this.config, 'blastTableLocation'), pm), opts);
85
+ const columns = readConfObject(this.config, 'columns');
86
+ return parseLineByLine(buf, createBlastLineParser(columns));
87
+ }
88
+ async hasDataForRefName() {
89
+ // determining this properly is basically a call to getFeatures
90
+ // so is not really that important, and has to be true or else
91
+ // getFeatures is never called (BaseAdapter filters it out)
92
+ return true;
93
+ }
94
+ getAssemblyNames() {
95
+ const assemblyNames = this.getConf('assemblyNames');
96
+ if (assemblyNames.length === 0) {
97
+ const query = this.getConf('queryAssembly');
98
+ const target = this.getConf('targetAssembly');
99
+ return [query, target];
100
+ }
101
+ return assemblyNames;
102
+ }
103
+ async getRefNames(opts = {}) {
104
+ var _a;
105
+ // @ts-expect-error
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 ObservableCreate(async (observer) => {
121
+ const blastRecords = await this.getData(opts);
122
+ const [queryAssembly, targetAssembly] = this.getAssemblyNames();
123
+ // The index of the assembly name in the query list corresponds to the
124
+ // adapter in the subadapters list
125
+ const { refName: queryRefName, assemblyName: queryAssemblyName, start: queryStart, end: queryEnd, } = query;
126
+ if (queryAssemblyName !== targetAssembly &&
127
+ queryAssemblyName !== queryAssembly) {
128
+ console.warn(`${queryAssemblyName} not found in this adapter`);
129
+ observer.complete();
130
+ return;
131
+ }
132
+ for (let i = 0; i < blastRecords.length; i++) {
133
+ const r = blastRecords[i];
134
+ let start;
135
+ let end;
136
+ let refName;
137
+ let assemblyName;
138
+ let mateStart;
139
+ let mateEnd;
140
+ let mateRefName;
141
+ let mateAssemblyName;
142
+ const { qseqid, sseqid, qstart, qend, sstart, send, ...rest } = r;
143
+ if (queryAssemblyName === queryAssembly) {
144
+ start = qstart;
145
+ end = qend;
146
+ refName = qseqid;
147
+ assemblyName = queryAssembly;
148
+ mateStart = sstart;
149
+ mateEnd = send;
150
+ mateRefName = sseqid;
151
+ mateAssemblyName = targetAssembly;
152
+ }
153
+ else {
154
+ start = sstart;
155
+ end = send;
156
+ refName = sseqid;
157
+ assemblyName = targetAssembly;
158
+ mateStart = qstart;
159
+ mateEnd = qend;
160
+ mateRefName = qseqid;
161
+ mateAssemblyName = queryAssembly;
162
+ }
163
+ let strand = 1;
164
+ let mateStrand = 1;
165
+ if (start > end) {
166
+ ;
167
+ [start, end] = [end, start];
168
+ strand = -1;
169
+ }
170
+ if (mateStart > mateEnd) {
171
+ ;
172
+ [mateStart, mateEnd] = [mateEnd, mateStart];
173
+ mateStrand = -1;
174
+ }
175
+ if (refName === queryRefName &&
176
+ doesIntersect2(queryStart, queryEnd, start, end)) {
177
+ observer.next(new SyntenyFeature({
178
+ uniqueId: i + queryAssemblyName,
179
+ assemblyName,
180
+ start,
181
+ end,
182
+ type: 'match',
183
+ refName,
184
+ strand: strand * mateStrand,
185
+ syntenyId: i,
186
+ ...rest,
187
+ mate: {
188
+ start: mateStart,
189
+ end: mateEnd,
190
+ refName: mateRefName,
191
+ assemblyName: mateAssemblyName,
192
+ },
193
+ }));
194
+ }
195
+ }
196
+ observer.complete();
197
+ });
198
+ }
199
+ freeResources( /* { query } */) { }
200
+ }
201
+ BlastTabularAdapter.capabilities = ['getFeatures', 'getRefNames'];
202
+ export default BlastTabularAdapter;
@@ -0,0 +1,45 @@
1
+ declare const BlastTabularAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ /**
3
+ * #slot
4
+ */
5
+ assemblyNames: {
6
+ type: string;
7
+ defaultValue: never[];
8
+ description: string;
9
+ };
10
+ /**
11
+ * #slot
12
+ */
13
+ targetAssembly: {
14
+ type: string;
15
+ defaultValue: string;
16
+ description: string;
17
+ };
18
+ /**
19
+ * #slot
20
+ */
21
+ queryAssembly: {
22
+ type: string;
23
+ defaultValue: string;
24
+ description: string;
25
+ };
26
+ /**
27
+ * #slot
28
+ */
29
+ blastTableLocation: {
30
+ type: string;
31
+ defaultValue: {
32
+ uri: string;
33
+ locationType: string;
34
+ };
35
+ };
36
+ /**
37
+ * #slot
38
+ */
39
+ columns: {
40
+ type: string;
41
+ description: string;
42
+ defaultValue: string;
43
+ };
44
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
45
+ export default BlastTabularAdapter;
@@ -0,0 +1,50 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ /**
3
+ * #config BlastTabularAdapter
4
+ */
5
+ function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
6
+ const BlastTabularAdapter = ConfigurationSchema('BlastTabularAdapter', {
7
+ /**
8
+ * #slot
9
+ */
10
+ assemblyNames: {
11
+ type: 'stringArray',
12
+ defaultValue: [],
13
+ description: 'Query assembly is the first value in the array, target assembly is the second',
14
+ },
15
+ /**
16
+ * #slot
17
+ */
18
+ targetAssembly: {
19
+ type: 'string',
20
+ defaultValue: '',
21
+ description: 'Alternative to assemblyNames array: the target assembly',
22
+ },
23
+ /**
24
+ * #slot
25
+ */
26
+ queryAssembly: {
27
+ type: 'string',
28
+ defaultValue: '',
29
+ description: 'Alternative to assemblyNames array: the query assembly',
30
+ },
31
+ /**
32
+ * #slot
33
+ */
34
+ blastTableLocation: {
35
+ type: 'fileLocation',
36
+ defaultValue: {
37
+ uri: '/path/to/blastTable.tsv',
38
+ locationType: 'UriLocation',
39
+ },
40
+ },
41
+ /**
42
+ * #slot
43
+ */
44
+ columns: {
45
+ type: 'string',
46
+ 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',
47
+ defaultValue: 'qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore',
48
+ },
49
+ }, { explicitlyTyped: true });
50
+ export default BlastTabularAdapter;
@@ -0,0 +1,2 @@
1
+ import 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,14 +1,12 @@
1
1
  import { openLocation } from '@jbrowse/core/util/io';
2
- import { isGzip } from '@jbrowse/core/util';
3
- import { unzip } from '@gmod/bgzf-filehandle';
2
+ import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
4
3
  // locals
5
4
  import PAFAdapter from '../PAFAdapter/PAFAdapter';
6
5
  import { paf_chain2paf } from './util';
7
6
  export default class ChainAdapter extends PAFAdapter {
8
7
  async setupPre(opts) {
9
8
  const loc = openLocation(this.getConf('chainLocation'), this.pluginManager);
10
- const buffer = (await loc.readFile(opts));
11
- const buf = isGzip(buffer) ? await unzip(buffer) : buffer;
9
+ const buf = await fetchAndMaybeUnzip(loc, opts);
12
10
  return paf_chain2paf(buf);
13
11
  }
14
12
  }
@@ -11,7 +11,7 @@ const ChainAdapter = ConfigurationSchema('ChainAdapter', {
11
11
  assemblyNames: {
12
12
  type: 'stringArray',
13
13
  defaultValue: [],
14
- description: 'Target is the first value in the array, query is the second',
14
+ 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
15
  },
16
16
  /**
17
17
  * #slot
@@ -1,4 +1,3 @@
1
- const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
2
1
  /* adapted from chain2paf by Andrea Guarracino, license reproduced below
3
2
  *
4
3
  * MIT License
@@ -53,13 +52,14 @@ export function paf_chain2paf(buffer) {
53
52
  let cigar = '';
54
53
  const records = [];
55
54
  let blockStart = 0;
55
+ const decoder = new TextDecoder('utf8');
56
56
  while (blockStart < buffer.length) {
57
57
  const n = buffer.indexOf('\n', blockStart);
58
58
  if (n === -1) {
59
59
  break;
60
60
  }
61
61
  const b = buffer.subarray(blockStart, n);
62
- const l = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
62
+ const l = decoder.decode(b).trim();
63
63
  blockStart = n + 1;
64
64
  const l_tab = l.replaceAll(' ', '\t'); // There are CHAIN files with space-separated fields
65
65
  const l_vec = l_tab.split('\t');
@@ -1,14 +1,12 @@
1
1
  import { openLocation } from '@jbrowse/core/util/io';
2
- import { unzip } from '@gmod/bgzf-filehandle';
3
- import { isGzip } from '@jbrowse/core/util';
2
+ import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
4
3
  // locals
5
4
  import PAFAdapter from '../PAFAdapter/PAFAdapter';
6
5
  import { paf_delta2paf } from './util';
7
6
  export default class DeltaAdapter extends PAFAdapter {
8
7
  async setupPre(opts) {
9
8
  const loc = openLocation(this.getConf('deltaLocation'), this.pluginManager);
10
- const buffer = (await loc.readFile(opts));
11
- const buf = isGzip(buffer) ? await unzip(buffer) : buffer;
9
+ const buf = await fetchAndMaybeUnzip(loc, opts);
12
10
  return paf_delta2paf(buf);
13
11
  }
14
12
  }
@@ -11,7 +11,7 @@ const DeltaAdapter = ConfigurationSchema('DeltaAdapter', {
11
11
  assemblyNames: {
12
12
  type: 'stringArray',
13
13
  defaultValue: [],
14
- description: 'Array of assembly names to use for this file. The target assembly name is the first value in the array, query assembly name is the second',
14
+ 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
15
  },
16
16
  /**
17
17
  * #slot
@@ -36,7 +36,10 @@ const DeltaAdapter = ConfigurationSchema('DeltaAdapter', {
36
36
  */
37
37
  deltaLocation: {
38
38
  type: 'fileLocation',
39
- defaultValue: { uri: '/path/to/file.delta', locationType: 'UriLocation' },
39
+ defaultValue: {
40
+ uri: '/path/to/file.delta',
41
+ locationType: 'UriLocation',
42
+ },
40
43
  },
41
44
  }, { explicitlyTyped: true });
42
45
  export default DeltaAdapter;
@@ -1,4 +1,3 @@
1
- const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
2
1
  /* paf2delta from paftools.js in the minimap2 repository, license reproduced below
3
2
  *
4
3
  * The MIT License
@@ -43,13 +42,14 @@ export function paf_delta2paf(buffer) {
43
42
  const regex = new RegExp(/^>(\S+)\s+(\S+)\s+(\d+)\s+(\d+)/);
44
43
  let blockStart = 0;
45
44
  let i = 0;
45
+ const decoder = new TextDecoder('utf8');
46
46
  while (blockStart < buffer.length) {
47
47
  const n = buffer.indexOf('\n', blockStart);
48
48
  if (n === -1) {
49
49
  break;
50
50
  }
51
51
  const b = buffer.subarray(blockStart, n);
52
- const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
52
+ const line = decoder.decode(b).trim();
53
53
  blockStart = n + 1;
54
54
  i++;
55
55
  if (line) {
@@ -1,5 +1,16 @@
1
1
  import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
2
  import PAFAdapter from '../PAFAdapter/PAFAdapter';
3
3
  export default class MashMapAdapter extends PAFAdapter {
4
- setupPre(opts?: BaseOptions): Promise<import("../PAFAdapter/util").PAFRecord[]>;
4
+ setupPre(opts?: BaseOptions): Promise<{
5
+ tname: string;
6
+ tstart: number;
7
+ tend: number;
8
+ qname: string;
9
+ qstart: number;
10
+ qend: number;
11
+ strand: number;
12
+ extra: {
13
+ mappingQual: number;
14
+ };
15
+ }[]>;
5
16
  }