@jbrowse/plugin-comparative-adapters 2.16.1 → 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.
- package/dist/BlastTabularAdapter/BlastTabularAdapter.d.ts +120 -0
- package/dist/BlastTabularAdapter/BlastTabularAdapter.js +207 -0
- package/dist/BlastTabularAdapter/configSchema.d.ts +45 -0
- package/dist/BlastTabularAdapter/configSchema.js +52 -0
- package/dist/BlastTabularAdapter/index.d.ts +2 -0
- package/dist/BlastTabularAdapter/index.js +42 -0
- package/dist/ChainAdapter/ChainAdapter.js +1 -3
- package/dist/ChainAdapter/util.js +2 -2
- package/dist/DeltaAdapter/DeltaAdapter.js +1 -3
- package/dist/DeltaAdapter/util.js +2 -2
- package/dist/MashMapAdapter/MashMapAdapter.d.ts +12 -1
- package/dist/MashMapAdapter/MashMapAdapter.js +1 -3
- package/dist/PAFAdapter/PAFAdapter.js +4 -6
- package/dist/PAFAdapter/util.d.ts +1 -1
- package/dist/PAFAdapter/util.js +1 -1
- package/dist/index.js +2 -0
- package/dist/util.d.ts +1 -1
- package/dist/util.js +9 -6
- package/esm/BlastTabularAdapter/BlastTabularAdapter.d.ts +120 -0
- package/esm/BlastTabularAdapter/BlastTabularAdapter.js +202 -0
- package/esm/BlastTabularAdapter/configSchema.d.ts +45 -0
- package/esm/BlastTabularAdapter/configSchema.js +50 -0
- package/esm/BlastTabularAdapter/index.d.ts +2 -0
- package/esm/BlastTabularAdapter/index.js +13 -0
- package/esm/ChainAdapter/ChainAdapter.js +2 -4
- package/esm/ChainAdapter/util.js +2 -2
- package/esm/DeltaAdapter/DeltaAdapter.js +2 -4
- package/esm/DeltaAdapter/util.js +2 -2
- package/esm/MashMapAdapter/MashMapAdapter.d.ts +12 -1
- package/esm/MashMapAdapter/MashMapAdapter.js +2 -4
- package/esm/PAFAdapter/PAFAdapter.js +5 -7
- package/esm/PAFAdapter/util.d.ts +1 -1
- package/esm/PAFAdapter/util.js +1 -1
- package/esm/index.js +2 -0
- package/esm/util.d.ts +1 -1
- package/esm/util.js +10 -7
- package/package.json +2 -2
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
|
|
33
|
-
|
|
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 =
|
|
48
|
+
const line = decoder.decode(b).trim();
|
|
49
49
|
if (line) {
|
|
50
|
-
|
|
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,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 {
|
|
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
|
|
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
|
}
|
package/esm/ChainAdapter/util.js
CHANGED
|
@@ -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 =
|
|
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 {
|
|
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
|
|
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
|
}
|
package/esm/DeltaAdapter/util.js
CHANGED
|
@@ -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 =
|
|
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<
|
|
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
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
2
|
-
import {
|
|
3
|
-
import { isGzip } from '@jbrowse/core/util';
|
|
2
|
+
import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
4
3
|
import PAFAdapter from '../PAFAdapter/PAFAdapter';
|
|
5
4
|
import { parseLineByLine } from '../util';
|
|
6
5
|
export default class MashMapAdapter extends PAFAdapter {
|
|
7
6
|
async setupPre(opts) {
|
|
8
7
|
const outLoc = openLocation(this.getConf('outLocation'), this.pluginManager);
|
|
9
|
-
const
|
|
10
|
-
const buf = isGzip(buffer) ? await unzip(buffer) : buffer;
|
|
8
|
+
const buf = await fetchAndMaybeUnzip(outLoc, opts);
|
|
11
9
|
return parseLineByLine(buf, parseMashMapLine);
|
|
12
10
|
}
|
|
13
11
|
}
|
|
@@ -2,9 +2,8 @@ import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter
|
|
|
2
2
|
import { doesIntersect2 } from '@jbrowse/core/util/range';
|
|
3
3
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
4
4
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
5
|
-
import {
|
|
5
|
+
import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
6
6
|
import { readConfObject, } from '@jbrowse/core/configuration';
|
|
7
|
-
import { unzip } from '@gmod/bgzf-filehandle';
|
|
8
7
|
import { MismatchParser } from '@jbrowse/plugin-alignments';
|
|
9
8
|
// locals
|
|
10
9
|
import SyntenyFeature from '../SyntenyFeature';
|
|
@@ -24,14 +23,13 @@ class PAFAdapter extends BaseFeatureDataAdapter {
|
|
|
24
23
|
async setupPre(opts) {
|
|
25
24
|
const pm = this.pluginManager;
|
|
26
25
|
const pafLocation = openLocation(this.getConf('pafLocation'), pm);
|
|
27
|
-
const
|
|
28
|
-
const buf = isGzip(buffer) ? await unzip(buffer) : buffer;
|
|
26
|
+
const buf = await fetchAndMaybeUnzip(pafLocation, opts);
|
|
29
27
|
return parseLineByLine(buf, parsePAFLine);
|
|
30
28
|
}
|
|
31
29
|
async hasDataForRefName() {
|
|
32
|
-
// determining this properly is basically a call to getFeatures
|
|
33
|
-
//
|
|
34
|
-
//
|
|
30
|
+
// determining this properly is basically a call to getFeatures so is not
|
|
31
|
+
// really that important, and has to be true or else getFeatures is never
|
|
32
|
+
// called (BaseAdapter filters it out)
|
|
35
33
|
return true;
|
|
36
34
|
}
|
|
37
35
|
getAssemblyNames() {
|
package/esm/PAFAdapter/util.d.ts
CHANGED
package/esm/PAFAdapter/util.js
CHANGED
|
@@ -42,7 +42,7 @@ export function getWeightedMeans(ret) {
|
|
|
42
42
|
if (!scoreMap[key]) {
|
|
43
43
|
scoreMap[key] = { quals: [], len: [] };
|
|
44
44
|
}
|
|
45
|
-
scoreMap[key].quals.push(entry.extra.mappingQual);
|
|
45
|
+
scoreMap[key].quals.push(entry.extra.mappingQual || 1);
|
|
46
46
|
scoreMap[key].len.push(entry.extra.blockLen || 1);
|
|
47
47
|
}
|
|
48
48
|
const meanScoreMap = Object.fromEntries(Object.entries(scoreMap).map(([key, val]) => {
|
package/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import MCScanSimpleAnchorsAdapterF from './MCScanSimpleAnchorsAdapter';
|
|
|
6
6
|
import MashMapAdapterF from './MashMapAdapter';
|
|
7
7
|
import DeltaAdapterF from './DeltaAdapter';
|
|
8
8
|
import ChainAdapterF from './ChainAdapter';
|
|
9
|
+
import BlastTabularAdapter from './BlastTabularAdapter';
|
|
9
10
|
import { getFileName, } from '@jbrowse/core/util/tracks';
|
|
10
11
|
export default class ComparativeAdaptersPlugin extends Plugin {
|
|
11
12
|
constructor() {
|
|
@@ -20,6 +21,7 @@ export default class ComparativeAdaptersPlugin extends Plugin {
|
|
|
20
21
|
MCScanAnchorsAdapterF(pluginManager);
|
|
21
22
|
MCScanSimpleAnchorsAdapterF(pluginManager);
|
|
22
23
|
MashMapAdapterF(pluginManager);
|
|
24
|
+
BlastTabularAdapter(pluginManager);
|
|
23
25
|
pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
|
|
24
26
|
return (file, index, adapterHint) => {
|
|
25
27
|
const regexGuess = /\.paf/i;
|
package/esm/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) =>
|
|
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;
|