@jbrowse/plugin-comparative-adapters 2.13.1 → 2.15.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/ChainAdapter/ChainAdapter.js +4 -6
- package/dist/ChainAdapter/util.js +4 -4
- package/dist/DeltaAdapter/DeltaAdapter.js +2 -4
- package/dist/DeltaAdapter/util.js +1 -3
- package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +1 -1
- package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +1 -1
- package/dist/MashMapAdapter/MashMapAdapter.js +7 -9
- package/dist/PAFAdapter/PAFAdapter.js +8 -7
- package/dist/PAFAdapter/util.js +2 -3
- package/dist/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.js +5 -3
- package/dist/SyntenyFeature/index.js +0 -1
- package/dist/util.d.ts +4 -5
- package/dist/util.js +3 -6
- package/esm/ChainAdapter/ChainAdapter.js +1 -3
- package/esm/ChainAdapter/util.js +4 -4
- package/esm/DeltaAdapter/DeltaAdapter.js +1 -3
- package/esm/DeltaAdapter/util.js +1 -3
- package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +1 -1
- package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +1 -1
- package/esm/MashMapAdapter/MashMapAdapter.js +4 -6
- package/esm/PAFAdapter/PAFAdapter.js +3 -2
- package/esm/PAFAdapter/util.js +2 -3
- package/esm/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.js +5 -3
- package/esm/SyntenyFeature/index.js +0 -1
- package/esm/util.d.ts +4 -5
- package/esm/util.js +2 -4
- package/package.json +4 -4
|
@@ -4,18 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const io_1 = require("@jbrowse/core/util/io");
|
|
7
|
+
const util_1 = require("@jbrowse/core/util");
|
|
7
8
|
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
8
9
|
const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
|
|
9
|
-
const
|
|
10
|
-
function isGzip(buf) {
|
|
11
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
12
|
-
}
|
|
10
|
+
const util_2 = require("./util");
|
|
13
11
|
class ChainAdapter extends PAFAdapter_1.default {
|
|
14
12
|
async setupPre(opts) {
|
|
15
13
|
const loc = (0, io_1.openLocation)(this.getConf('chainLocation'), this.pluginManager);
|
|
16
14
|
const buffer = (await loc.readFile(opts));
|
|
17
|
-
const buf = isGzip(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
18
|
-
return (0,
|
|
15
|
+
const buf = (0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
16
|
+
return (0, util_2.paf_chain2paf)(buf);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
exports.default = ChainAdapter;
|
|
@@ -61,7 +61,7 @@ function paf_chain2paf(buffer) {
|
|
|
61
61
|
if (n === -1) {
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
|
-
const b = buffer.
|
|
64
|
+
const b = buffer.subarray(blockStart, n);
|
|
65
65
|
const l = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
|
|
66
66
|
blockStart = n + 1;
|
|
67
67
|
const l_tab = l.replaceAll(' ', '\t'); // There are CHAIN files with space-separated fields
|
|
@@ -114,13 +114,13 @@ function paf_chain2paf(buffer) {
|
|
|
114
114
|
const diff_in_query = l_vec.length > 2 ? +l_vec[2] : 0;
|
|
115
115
|
if (size_ungapped_alignment !== 0) {
|
|
116
116
|
num_matches += +size_ungapped_alignment;
|
|
117
|
-
cigar += size_ungapped_alignment
|
|
117
|
+
cigar += `${size_ungapped_alignment}M`;
|
|
118
118
|
}
|
|
119
119
|
if (diff_in_query !== 0) {
|
|
120
|
-
cigar += diff_in_query
|
|
120
|
+
cigar += `${diff_in_query}I`;
|
|
121
121
|
}
|
|
122
122
|
if (diff_in_target !== 0) {
|
|
123
|
-
cigar += diff_in_target
|
|
123
|
+
cigar += `${diff_in_target}D`;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -7,14 +7,12 @@ const io_1 = require("@jbrowse/core/util/io");
|
|
|
7
7
|
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
8
8
|
const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
|
|
9
9
|
const util_1 = require("./util");
|
|
10
|
-
|
|
11
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
12
|
-
}
|
|
10
|
+
const util_2 = require("@jbrowse/core/util");
|
|
13
11
|
class DeltaAdapter extends PAFAdapter_1.default {
|
|
14
12
|
async setupPre(opts) {
|
|
15
13
|
const loc = (0, io_1.openLocation)(this.getConf('deltaLocation'), this.pluginManager);
|
|
16
14
|
const buffer = (await loc.readFile(opts));
|
|
17
|
-
const buf = isGzip(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
15
|
+
const buf = (0, util_2.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
18
16
|
return (0, util_1.paf_delta2paf)(buf);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -51,7 +51,7 @@ function paf_delta2paf(buffer) {
|
|
|
51
51
|
if (n === -1) {
|
|
52
52
|
break;
|
|
53
53
|
}
|
|
54
|
-
const b = buffer.
|
|
54
|
+
const b = buffer.subarray(blockStart, n);
|
|
55
55
|
const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
|
|
56
56
|
blockStart = n + 1;
|
|
57
57
|
i++;
|
|
@@ -120,7 +120,6 @@ function paf_delta2paf(buffer) {
|
|
|
120
120
|
if (l > 0) {
|
|
121
121
|
cigar.push(l << 4);
|
|
122
122
|
}
|
|
123
|
-
// eslint-disable-next-line unicorn/prefer-at
|
|
124
123
|
if (cigar.length > 0 && (cigar[cigar.length - 1] & 0xf) === 2) {
|
|
125
124
|
cigar[cigar.length - 1] += 1 << 4;
|
|
126
125
|
}
|
|
@@ -135,7 +134,6 @@ function paf_delta2paf(buffer) {
|
|
|
135
134
|
if (l > 0) {
|
|
136
135
|
cigar.push(l << 4);
|
|
137
136
|
}
|
|
138
|
-
// eslint-disable-next-line unicorn/prefer-at
|
|
139
137
|
if (cigar.length > 0 && (cigar[cigar.length - 1] & 0xf) === 1) {
|
|
140
138
|
cigar[cigar.length - 1] += 1 << 4;
|
|
141
139
|
}
|
|
@@ -8,7 +8,7 @@ const util_2 = require("../util");
|
|
|
8
8
|
class MCScanAnchorsAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
9
9
|
async setup(opts) {
|
|
10
10
|
if (!this.setupP) {
|
|
11
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
11
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
12
12
|
this.setupP = undefined;
|
|
13
13
|
throw e;
|
|
14
14
|
});
|
|
@@ -12,7 +12,7 @@ const util_2 = require("../util");
|
|
|
12
12
|
class MCScanAnchorsAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
13
13
|
async setup(opts) {
|
|
14
14
|
if (!this.setupP) {
|
|
15
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
15
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
16
16
|
this.setupP = undefined;
|
|
17
17
|
throw e;
|
|
18
18
|
});
|
|
@@ -5,17 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const io_1 = require("@jbrowse/core/util/io");
|
|
7
7
|
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
8
|
+
const util_1 = require("@jbrowse/core/util");
|
|
8
9
|
const PAFAdapter_1 = __importDefault(require("../PAFAdapter/PAFAdapter"));
|
|
9
|
-
const
|
|
10
|
-
function isGzip(buf) {
|
|
11
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
12
|
-
}
|
|
10
|
+
const util_2 = require("../util");
|
|
13
11
|
class MashMapAdapter extends PAFAdapter_1.default {
|
|
14
12
|
async setupPre(opts) {
|
|
15
13
|
const outLoc = (0, io_1.openLocation)(this.getConf('outLocation'), this.pluginManager);
|
|
16
14
|
const buffer = (await outLoc.readFile(opts));
|
|
17
|
-
const buf = isGzip(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
18
|
-
return (0,
|
|
15
|
+
const buf = (0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
16
|
+
return (0, util_2.parseLineByLine)(buf, parseMashMapLine);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
exports.default = MashMapAdapter;
|
|
@@ -23,14 +21,14 @@ function parseMashMapLine(line) {
|
|
|
23
21
|
const fields = line.split(' ');
|
|
24
22
|
if (fields.length < 9) {
|
|
25
23
|
// xref https://github.com/marbl/MashMap/issues/38
|
|
26
|
-
throw new Error(
|
|
24
|
+
throw new Error(`improperly formatted line: ${line}`);
|
|
27
25
|
}
|
|
28
26
|
const [qname, , qstart, qend, strand, tname, , tstart, tend, mq] = fields;
|
|
29
27
|
return {
|
|
30
|
-
tname,
|
|
28
|
+
tname: tname,
|
|
31
29
|
tstart: +tstart,
|
|
32
30
|
tend: +tend,
|
|
33
|
-
qname,
|
|
31
|
+
qname: qname,
|
|
34
32
|
qstart: +qstart,
|
|
35
33
|
qend: +qend,
|
|
36
34
|
strand: strand === '-' ? -1 : 1,
|
|
@@ -7,18 +7,19 @@ const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
|
7
7
|
const range_1 = require("@jbrowse/core/util/range");
|
|
8
8
|
const io_1 = require("@jbrowse/core/util/io");
|
|
9
9
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
10
|
+
const util_1 = require("@jbrowse/core/util");
|
|
10
11
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
11
12
|
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
12
13
|
const plugin_alignments_1 = require("@jbrowse/plugin-alignments");
|
|
13
14
|
// locals
|
|
14
15
|
const SyntenyFeature_1 = __importDefault(require("../SyntenyFeature"));
|
|
15
|
-
const
|
|
16
|
-
const
|
|
16
|
+
const util_2 = require("../util");
|
|
17
|
+
const util_3 = require("./util");
|
|
17
18
|
const { parseCigar } = plugin_alignments_1.MismatchParser;
|
|
18
19
|
class PAFAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
19
20
|
async setup(opts) {
|
|
20
21
|
if (!this.setupP) {
|
|
21
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
22
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
22
23
|
this.setupP = undefined;
|
|
23
24
|
throw e;
|
|
24
25
|
});
|
|
@@ -30,7 +31,7 @@ class PAFAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
30
31
|
const pafLocation = (0, io_1.openLocation)(this.getConf('pafLocation'), pm);
|
|
31
32
|
const buffer = (await pafLocation.readFile(opts));
|
|
32
33
|
const buf = (0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer;
|
|
33
|
-
return (0,
|
|
34
|
+
return (0, util_2.parseLineByLine)(buf, util_2.parsePAFLine);
|
|
34
35
|
}
|
|
35
36
|
async hasDataForRefName() {
|
|
36
37
|
// determining this properly is basically a call to getFeatures
|
|
@@ -70,7 +71,7 @@ class PAFAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
70
71
|
// note: this is not the adapter config, it is responding to a display
|
|
71
72
|
// setting passed in via the opts parameter
|
|
72
73
|
if (config && (0, configuration_1.readConfObject)(config, 'colorBy') === 'meanQueryIdentity') {
|
|
73
|
-
pafRecords = (0,
|
|
74
|
+
pafRecords = (0, util_3.getWeightedMeans)(pafRecords);
|
|
74
75
|
}
|
|
75
76
|
const assemblyNames = this.getAssemblyNames();
|
|
76
77
|
// The index of the assembly name in the query list corresponds to the
|
|
@@ -114,10 +115,10 @@ class PAFAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
114
115
|
let CIGAR = extra.cg;
|
|
115
116
|
if (extra.cg) {
|
|
116
117
|
if (flip && strand === -1) {
|
|
117
|
-
CIGAR = (0,
|
|
118
|
+
CIGAR = (0, util_2.flipCigar)(parseCigar(extra.cg)).join('');
|
|
118
119
|
}
|
|
119
120
|
else if (flip) {
|
|
120
|
-
CIGAR = (0,
|
|
121
|
+
CIGAR = (0, util_2.swapIndelCigar)(extra.cg);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
observer.next(new SyntenyFeature_1.default({
|
package/dist/PAFAdapter/util.js
CHANGED
|
@@ -41,7 +41,7 @@ function getWeightedMeans(ret) {
|
|
|
41
41
|
for (const entry of ret) {
|
|
42
42
|
const query = entry.qname;
|
|
43
43
|
const target = entry.tname;
|
|
44
|
-
const key = query
|
|
44
|
+
const key = `${query}-${target}`;
|
|
45
45
|
if (!scoreMap[key]) {
|
|
46
46
|
scoreMap[key] = { quals: [], len: [] };
|
|
47
47
|
}
|
|
@@ -55,7 +55,7 @@ function getWeightedMeans(ret) {
|
|
|
55
55
|
for (const entry of ret) {
|
|
56
56
|
const query = entry.qname;
|
|
57
57
|
const target = entry.tname;
|
|
58
|
-
const key = query
|
|
58
|
+
const key = `${query}-${target}`;
|
|
59
59
|
entry.extra.meanScore = meanScoreMap[key];
|
|
60
60
|
}
|
|
61
61
|
let min = 10000;
|
|
@@ -72,7 +72,6 @@ function getWeightedMeans(ret) {
|
|
|
72
72
|
}
|
|
73
73
|
// https://gist.github.com/stekhn/a12ed417e91f90ecec14bcfa4c2ae16a
|
|
74
74
|
function weightedMean(tuples) {
|
|
75
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
76
75
|
const [valueSum, weightSum] = tuples.reduce(([valueSum, weightSum], [value, weight]) => [
|
|
77
76
|
valueSum + value * weight,
|
|
78
77
|
weightSum + weight,
|
|
@@ -41,8 +41,8 @@ class PAFAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
43
|
async getRefNames(opts = {}) {
|
|
44
|
-
var _a;
|
|
45
|
-
const r1 = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0].assemblyName;
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const r1 = (_b = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.assemblyName;
|
|
46
46
|
if (!r1) {
|
|
47
47
|
throw new Error('no assembly name provided');
|
|
48
48
|
}
|
|
@@ -54,7 +54,9 @@ class PAFAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
54
54
|
else if (idx === 1) {
|
|
55
55
|
return names.filter(n => n.startsWith('t')).map(n => n.slice(1));
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
else {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
61
|
getFeatures(query, opts = {}) {
|
|
60
62
|
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
@@ -5,7 +5,6 @@ const plugin_alignments_1 = require("@jbrowse/plugin-alignments");
|
|
|
5
5
|
// locals
|
|
6
6
|
const { getMismatches } = plugin_alignments_1.MismatchParser;
|
|
7
7
|
class SyntenyFeature extends util_1.SimpleFeature {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
8
|
get(arg) {
|
|
10
9
|
if (arg === 'mismatches') {
|
|
11
10
|
return getMismatches(this.get('CIGAR'));
|
package/dist/util.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
2
|
import { GenericFilehandle } from 'generic-filehandle';
|
|
3
3
|
import { PAFRecord } from './PAFAdapter/util';
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
refName: string;
|
|
4
|
+
export declare function parseBed(text: string): Map<string | undefined, {
|
|
5
|
+
refName: string | undefined;
|
|
7
6
|
start: number;
|
|
8
7
|
end: number;
|
|
9
8
|
score: number;
|
|
10
|
-
name: string;
|
|
9
|
+
name: string | undefined;
|
|
11
10
|
strand: number;
|
|
12
11
|
}>;
|
|
13
12
|
export declare function readFile(file: GenericFilehandle, opts?: BaseOptions): Promise<string>;
|
|
14
13
|
export declare function zip(a: number[], b: number[]): [number, number][];
|
|
15
14
|
export declare function parseLineByLine(buffer: Buffer, cb: (line: string) => PAFRecord): PAFRecord[];
|
|
16
15
|
export declare function parsePAFLine(line: string): PAFRecord;
|
|
17
|
-
export declare function flipCigar(cigar: string[]): string[];
|
|
16
|
+
export declare function flipCigar(cigar: string[]): (string | undefined)[];
|
|
18
17
|
export declare function swapIndelCigar(cigar: string): string;
|
package/dist/util.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isGzip = isGzip;
|
|
4
3
|
exports.parseBed = parseBed;
|
|
5
4
|
exports.readFile = readFile;
|
|
6
5
|
exports.zip = zip;
|
|
@@ -9,9 +8,7 @@ exports.parsePAFLine = parsePAFLine;
|
|
|
9
8
|
exports.flipCigar = flipCigar;
|
|
10
9
|
exports.swapIndelCigar = swapIndelCigar;
|
|
11
10
|
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
12
|
-
|
|
13
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
14
|
-
}
|
|
11
|
+
const util_1 = require("@jbrowse/core/util");
|
|
15
12
|
function parseBed(text) {
|
|
16
13
|
return new Map(text
|
|
17
14
|
.split(/\n|\r\n|\r/)
|
|
@@ -33,7 +30,7 @@ function parseBed(text) {
|
|
|
33
30
|
}
|
|
34
31
|
async function readFile(file, opts) {
|
|
35
32
|
const buffer = (await file.readFile(opts));
|
|
36
|
-
return new TextDecoder('utf8', { fatal: true }).decode(isGzip(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer);
|
|
33
|
+
return new TextDecoder('utf8', { fatal: true }).decode((0, util_1.isGzip)(buffer) ? await (0, bgzf_filehandle_1.unzip)(buffer) : buffer);
|
|
37
34
|
}
|
|
38
35
|
function zip(a, b) {
|
|
39
36
|
return a.map((e, i) => [e, b[i]]);
|
|
@@ -47,7 +44,7 @@ function parseLineByLine(buffer, cb) {
|
|
|
47
44
|
if (n === -1) {
|
|
48
45
|
break;
|
|
49
46
|
}
|
|
50
|
-
const b = buffer.
|
|
47
|
+
const b = buffer.subarray(blockStart, n);
|
|
51
48
|
const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
|
|
52
49
|
if (line) {
|
|
53
50
|
entries.push(cb(line));
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
2
|
+
import { isGzip } from '@jbrowse/core/util';
|
|
2
3
|
import { unzip } from '@gmod/bgzf-filehandle';
|
|
3
4
|
import PAFAdapter from '../PAFAdapter/PAFAdapter';
|
|
4
5
|
import { paf_chain2paf } from './util';
|
|
5
|
-
function isGzip(buf) {
|
|
6
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
7
|
-
}
|
|
8
6
|
export default class ChainAdapter extends PAFAdapter {
|
|
9
7
|
async setupPre(opts) {
|
|
10
8
|
const loc = openLocation(this.getConf('chainLocation'), this.pluginManager);
|
package/esm/ChainAdapter/util.js
CHANGED
|
@@ -58,7 +58,7 @@ export function paf_chain2paf(buffer) {
|
|
|
58
58
|
if (n === -1) {
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
|
-
const b = buffer.
|
|
61
|
+
const b = buffer.subarray(blockStart, n);
|
|
62
62
|
const l = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
|
|
63
63
|
blockStart = n + 1;
|
|
64
64
|
const l_tab = l.replaceAll(' ', '\t'); // There are CHAIN files with space-separated fields
|
|
@@ -111,13 +111,13 @@ export function paf_chain2paf(buffer) {
|
|
|
111
111
|
const diff_in_query = l_vec.length > 2 ? +l_vec[2] : 0;
|
|
112
112
|
if (size_ungapped_alignment !== 0) {
|
|
113
113
|
num_matches += +size_ungapped_alignment;
|
|
114
|
-
cigar += size_ungapped_alignment
|
|
114
|
+
cigar += `${size_ungapped_alignment}M`;
|
|
115
115
|
}
|
|
116
116
|
if (diff_in_query !== 0) {
|
|
117
|
-
cigar += diff_in_query
|
|
117
|
+
cigar += `${diff_in_query}I`;
|
|
118
118
|
}
|
|
119
119
|
if (diff_in_target !== 0) {
|
|
120
|
-
cigar += diff_in_target
|
|
120
|
+
cigar += `${diff_in_target}D`;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -2,9 +2,7 @@ import { openLocation } from '@jbrowse/core/util/io';
|
|
|
2
2
|
import { unzip } from '@gmod/bgzf-filehandle';
|
|
3
3
|
import PAFAdapter from '../PAFAdapter/PAFAdapter';
|
|
4
4
|
import { paf_delta2paf } from './util';
|
|
5
|
-
|
|
6
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
7
|
-
}
|
|
5
|
+
import { isGzip } from '@jbrowse/core/util';
|
|
8
6
|
export default class DeltaAdapter extends PAFAdapter {
|
|
9
7
|
async setupPre(opts) {
|
|
10
8
|
const loc = openLocation(this.getConf('deltaLocation'), this.pluginManager);
|
package/esm/DeltaAdapter/util.js
CHANGED
|
@@ -48,7 +48,7 @@ export function paf_delta2paf(buffer) {
|
|
|
48
48
|
if (n === -1) {
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
|
-
const b = buffer.
|
|
51
|
+
const b = buffer.subarray(blockStart, n);
|
|
52
52
|
const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
|
|
53
53
|
blockStart = n + 1;
|
|
54
54
|
i++;
|
|
@@ -117,7 +117,6 @@ export function paf_delta2paf(buffer) {
|
|
|
117
117
|
if (l > 0) {
|
|
118
118
|
cigar.push(l << 4);
|
|
119
119
|
}
|
|
120
|
-
// eslint-disable-next-line unicorn/prefer-at
|
|
121
120
|
if (cigar.length > 0 && (cigar[cigar.length - 1] & 0xf) === 2) {
|
|
122
121
|
cigar[cigar.length - 1] += 1 << 4;
|
|
123
122
|
}
|
|
@@ -132,7 +131,6 @@ export function paf_delta2paf(buffer) {
|
|
|
132
131
|
if (l > 0) {
|
|
133
132
|
cigar.push(l << 4);
|
|
134
133
|
}
|
|
135
|
-
// eslint-disable-next-line unicorn/prefer-at
|
|
136
134
|
if (cigar.length > 0 && (cigar[cigar.length - 1] & 0xf) === 1) {
|
|
137
135
|
cigar[cigar.length - 1] += 1 << 4;
|
|
138
136
|
}
|
|
@@ -6,7 +6,7 @@ import { readFile, parseBed } from '../util';
|
|
|
6
6
|
class MCScanAnchorsAdapter extends BaseFeatureDataAdapter {
|
|
7
7
|
async setup(opts) {
|
|
8
8
|
if (!this.setupP) {
|
|
9
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
9
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
10
10
|
this.setupP = undefined;
|
|
11
11
|
throw e;
|
|
12
12
|
});
|
|
@@ -7,7 +7,7 @@ import { readFile, parseBed } from '../util';
|
|
|
7
7
|
class MCScanAnchorsAdapter extends BaseFeatureDataAdapter {
|
|
8
8
|
async setup(opts) {
|
|
9
9
|
if (!this.setupP) {
|
|
10
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
10
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
11
11
|
this.setupP = undefined;
|
|
12
12
|
throw e;
|
|
13
13
|
});
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
2
2
|
import { unzip } from '@gmod/bgzf-filehandle';
|
|
3
|
+
import { isGzip } from '@jbrowse/core/util';
|
|
3
4
|
import PAFAdapter from '../PAFAdapter/PAFAdapter';
|
|
4
5
|
import { parseLineByLine } from '../util';
|
|
5
|
-
function isGzip(buf) {
|
|
6
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
7
|
-
}
|
|
8
6
|
export default class MashMapAdapter extends PAFAdapter {
|
|
9
7
|
async setupPre(opts) {
|
|
10
8
|
const outLoc = openLocation(this.getConf('outLocation'), this.pluginManager);
|
|
@@ -17,14 +15,14 @@ function parseMashMapLine(line) {
|
|
|
17
15
|
const fields = line.split(' ');
|
|
18
16
|
if (fields.length < 9) {
|
|
19
17
|
// xref https://github.com/marbl/MashMap/issues/38
|
|
20
|
-
throw new Error(
|
|
18
|
+
throw new Error(`improperly formatted line: ${line}`);
|
|
21
19
|
}
|
|
22
20
|
const [qname, , qstart, qend, strand, tname, , tstart, tend, mq] = fields;
|
|
23
21
|
return {
|
|
24
|
-
tname,
|
|
22
|
+
tname: tname,
|
|
25
23
|
tstart: +tstart,
|
|
26
24
|
tend: +tend,
|
|
27
|
-
qname,
|
|
25
|
+
qname: qname,
|
|
28
26
|
qstart: +qstart,
|
|
29
27
|
qend: +qend,
|
|
30
28
|
strand: strand === '-' ? -1 : 1,
|
|
@@ -2,18 +2,19 @@ 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 { isGzip } from '@jbrowse/core/util';
|
|
5
6
|
import { readConfObject, } from '@jbrowse/core/configuration';
|
|
6
7
|
import { unzip } from '@gmod/bgzf-filehandle';
|
|
7
8
|
import { MismatchParser } from '@jbrowse/plugin-alignments';
|
|
8
9
|
// locals
|
|
9
10
|
import SyntenyFeature from '../SyntenyFeature';
|
|
10
|
-
import { flipCigar, swapIndelCigar, parsePAFLine,
|
|
11
|
+
import { flipCigar, swapIndelCigar, parsePAFLine, parseLineByLine, } from '../util';
|
|
11
12
|
import { getWeightedMeans } from './util';
|
|
12
13
|
const { parseCigar } = MismatchParser;
|
|
13
14
|
class PAFAdapter extends BaseFeatureDataAdapter {
|
|
14
15
|
async setup(opts) {
|
|
15
16
|
if (!this.setupP) {
|
|
16
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
17
|
+
this.setupP = this.setupPre(opts).catch((e) => {
|
|
17
18
|
this.setupP = undefined;
|
|
18
19
|
throw e;
|
|
19
20
|
});
|
package/esm/PAFAdapter/util.js
CHANGED
|
@@ -38,7 +38,7 @@ export function getWeightedMeans(ret) {
|
|
|
38
38
|
for (const entry of ret) {
|
|
39
39
|
const query = entry.qname;
|
|
40
40
|
const target = entry.tname;
|
|
41
|
-
const key = query
|
|
41
|
+
const key = `${query}-${target}`;
|
|
42
42
|
if (!scoreMap[key]) {
|
|
43
43
|
scoreMap[key] = { quals: [], len: [] };
|
|
44
44
|
}
|
|
@@ -52,7 +52,7 @@ export function getWeightedMeans(ret) {
|
|
|
52
52
|
for (const entry of ret) {
|
|
53
53
|
const query = entry.qname;
|
|
54
54
|
const target = entry.tname;
|
|
55
|
-
const key = query
|
|
55
|
+
const key = `${query}-${target}`;
|
|
56
56
|
entry.extra.meanScore = meanScoreMap[key];
|
|
57
57
|
}
|
|
58
58
|
let min = 10000;
|
|
@@ -69,7 +69,6 @@ export function getWeightedMeans(ret) {
|
|
|
69
69
|
}
|
|
70
70
|
// https://gist.github.com/stekhn/a12ed417e91f90ecec14bcfa4c2ae16a
|
|
71
71
|
function weightedMean(tuples) {
|
|
72
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
73
72
|
const [valueSum, weightSum] = tuples.reduce(([valueSum, weightSum], [value, weight]) => [
|
|
74
73
|
valueSum + value * weight,
|
|
75
74
|
weightSum + weight,
|
|
@@ -36,8 +36,8 @@ class PAFAdapter extends BaseFeatureDataAdapter {
|
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
async getRefNames(opts = {}) {
|
|
39
|
-
var _a;
|
|
40
|
-
const r1 = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0].assemblyName;
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const r1 = (_b = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.assemblyName;
|
|
41
41
|
if (!r1) {
|
|
42
42
|
throw new Error('no assembly name provided');
|
|
43
43
|
}
|
|
@@ -49,7 +49,9 @@ class PAFAdapter extends BaseFeatureDataAdapter {
|
|
|
49
49
|
else if (idx === 1) {
|
|
50
50
|
return names.filter(n => n.startsWith('t')).map(n => n.slice(1));
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
else {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
getFeatures(query, opts = {}) {
|
|
55
57
|
return ObservableCreate(async (observer) => {
|
|
@@ -3,7 +3,6 @@ import { MismatchParser } from '@jbrowse/plugin-alignments';
|
|
|
3
3
|
// locals
|
|
4
4
|
const { getMismatches } = MismatchParser;
|
|
5
5
|
export default class SyntenyFeature extends SimpleFeature {
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
6
|
get(arg) {
|
|
8
7
|
if (arg === 'mismatches') {
|
|
9
8
|
return getMismatches(this.get('CIGAR'));
|
package/esm/util.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
2
|
import { GenericFilehandle } from 'generic-filehandle';
|
|
3
3
|
import { PAFRecord } from './PAFAdapter/util';
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
refName: string;
|
|
4
|
+
export declare function parseBed(text: string): Map<string | undefined, {
|
|
5
|
+
refName: string | undefined;
|
|
7
6
|
start: number;
|
|
8
7
|
end: number;
|
|
9
8
|
score: number;
|
|
10
|
-
name: string;
|
|
9
|
+
name: string | undefined;
|
|
11
10
|
strand: number;
|
|
12
11
|
}>;
|
|
13
12
|
export declare function readFile(file: GenericFilehandle, opts?: BaseOptions): Promise<string>;
|
|
14
13
|
export declare function zip(a: number[], b: number[]): [number, number][];
|
|
15
14
|
export declare function parseLineByLine(buffer: Buffer, cb: (line: string) => PAFRecord): PAFRecord[];
|
|
16
15
|
export declare function parsePAFLine(line: string): PAFRecord;
|
|
17
|
-
export declare function flipCigar(cigar: string[]): string[];
|
|
16
|
+
export declare function flipCigar(cigar: string[]): (string | undefined)[];
|
|
18
17
|
export declare function swapIndelCigar(cigar: string): string;
|
package/esm/util.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { unzip } from '@gmod/bgzf-filehandle';
|
|
2
|
-
|
|
3
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
4
|
-
}
|
|
2
|
+
import { isGzip } from '@jbrowse/core/util';
|
|
5
3
|
export function parseBed(text) {
|
|
6
4
|
return new Map(text
|
|
7
5
|
.split(/\n|\r\n|\r/)
|
|
@@ -37,7 +35,7 @@ export function parseLineByLine(buffer, cb) {
|
|
|
37
35
|
if (n === -1) {
|
|
38
36
|
break;
|
|
39
37
|
}
|
|
40
|
-
const b = buffer.
|
|
38
|
+
const b = buffer.subarray(blockStart, n);
|
|
41
39
|
const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
|
|
42
40
|
if (line) {
|
|
43
41
|
entries.push(cb(line));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-comparative-adapters",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "JBrowse 2 comparative adapters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "npm-run-all build:*",
|
|
27
|
-
"test": "cd ../..; jest plugins/comparative-adapters",
|
|
27
|
+
"test": "cd ../..; jest --passWithNoTests plugins/comparative-adapters",
|
|
28
28
|
"prepublishOnly": "yarn test",
|
|
29
29
|
"prepack": "yarn build && yarn useDist",
|
|
30
30
|
"postpack": "yarn useSrc",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@jbrowse/core": "^2.0.0",
|
|
45
45
|
"@jbrowse/plugin-alignments": "^2.0.0",
|
|
46
46
|
"@jbrowse/plugin-linear-genome-view": "^2.0.0",
|
|
47
|
-
"@mui/material": "^
|
|
47
|
+
"@mui/material": "^6.0.0",
|
|
48
48
|
"mobx": "^6.0.0",
|
|
49
49
|
"mobx-react": "^9.0.0",
|
|
50
50
|
"mobx-state-tree": "^5.0.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "87eeb1fbf8311dbf88d5e75b5a265f03beffdda8"
|
|
62
62
|
}
|