@jbrowse/plugin-comparative-adapters 2.6.1 → 2.6.3
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 +0 -1
- package/dist/ChainAdapter/configSchema.js +0 -1
- package/dist/ChainAdapter/index.js +0 -1
- package/dist/ChainAdapter/util.js +0 -1
- package/dist/DeltaAdapter/DeltaAdapter.js +0 -1
- package/dist/DeltaAdapter/configSchema.js +0 -1
- package/dist/DeltaAdapter/index.js +0 -1
- package/dist/DeltaAdapter/util.js +0 -1
- package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +0 -1
- package/dist/MCScanAnchorsAdapter/configSchema.js +0 -1
- package/dist/MCScanAnchorsAdapter/index.js +0 -1
- package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +0 -1
- package/dist/MCScanSimpleAnchorsAdapter/configSchema.js +0 -1
- package/dist/MCScanSimpleAnchorsAdapter/index.js +0 -1
- package/dist/MashMapAdapter/MashMapAdapter.js +0 -1
- package/dist/MashMapAdapter/configSchema.js +0 -1
- package/dist/MashMapAdapter/index.js +0 -1
- package/dist/PAFAdapter/PAFAdapter.js +0 -1
- package/dist/PAFAdapter/SyntenyFeature.js +0 -1
- package/dist/PAFAdapter/configSchema.js +0 -1
- package/dist/PAFAdapter/index.js +0 -1
- package/dist/PAFAdapter/util.js +0 -1
- package/dist/index.js +0 -1
- package/dist/util.js +0 -1
- package/esm/ChainAdapter/ChainAdapter.js +0 -1
- package/esm/ChainAdapter/configSchema.js +0 -1
- package/esm/ChainAdapter/index.js +0 -1
- package/esm/ChainAdapter/util.js +0 -1
- package/esm/DeltaAdapter/DeltaAdapter.js +0 -1
- package/esm/DeltaAdapter/configSchema.js +0 -1
- package/esm/DeltaAdapter/index.js +0 -1
- package/esm/DeltaAdapter/util.js +0 -1
- package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +0 -1
- package/esm/MCScanAnchorsAdapter/configSchema.js +0 -1
- package/esm/MCScanAnchorsAdapter/index.js +0 -1
- package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +0 -1
- package/esm/MCScanSimpleAnchorsAdapter/configSchema.js +0 -1
- package/esm/MCScanSimpleAnchorsAdapter/index.js +0 -1
- package/esm/MashMapAdapter/MashMapAdapter.js +0 -1
- package/esm/MashMapAdapter/configSchema.js +0 -1
- package/esm/MashMapAdapter/index.js +0 -1
- package/esm/PAFAdapter/PAFAdapter.js +0 -1
- package/esm/PAFAdapter/SyntenyFeature.js +0 -1
- package/esm/PAFAdapter/configSchema.js +0 -1
- package/esm/PAFAdapter/index.js +0 -1
- package/esm/PAFAdapter/util.js +0 -1
- package/esm/index.js +0 -1
- package/esm/util.js +0 -1
- package/package.json +3 -4
- package/dist/ChainAdapter/ChainAdapter.js.map +0 -1
- package/dist/ChainAdapter/configSchema.js.map +0 -1
- package/dist/ChainAdapter/index.js.map +0 -1
- package/dist/ChainAdapter/util.js.map +0 -1
- package/dist/DeltaAdapter/DeltaAdapter.js.map +0 -1
- package/dist/DeltaAdapter/configSchema.js.map +0 -1
- package/dist/DeltaAdapter/index.js.map +0 -1
- package/dist/DeltaAdapter/util.js.map +0 -1
- package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js.map +0 -1
- package/dist/MCScanAnchorsAdapter/configSchema.js.map +0 -1
- package/dist/MCScanAnchorsAdapter/index.js.map +0 -1
- package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js.map +0 -1
- package/dist/MCScanSimpleAnchorsAdapter/configSchema.js.map +0 -1
- package/dist/MCScanSimpleAnchorsAdapter/index.js.map +0 -1
- package/dist/MashMapAdapter/MashMapAdapter.js.map +0 -1
- package/dist/MashMapAdapter/configSchema.js.map +0 -1
- package/dist/MashMapAdapter/index.js.map +0 -1
- package/dist/PAFAdapter/PAFAdapter.js.map +0 -1
- package/dist/PAFAdapter/SyntenyFeature.js.map +0 -1
- package/dist/PAFAdapter/configSchema.js.map +0 -1
- package/dist/PAFAdapter/index.js.map +0 -1
- package/dist/PAFAdapter/util.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/util.js.map +0 -1
- package/esm/ChainAdapter/ChainAdapter.js.map +0 -1
- package/esm/ChainAdapter/configSchema.js.map +0 -1
- package/esm/ChainAdapter/index.js.map +0 -1
- package/esm/ChainAdapter/util.js.map +0 -1
- package/esm/DeltaAdapter/DeltaAdapter.js.map +0 -1
- package/esm/DeltaAdapter/configSchema.js.map +0 -1
- package/esm/DeltaAdapter/index.js.map +0 -1
- package/esm/DeltaAdapter/util.js.map +0 -1
- package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js.map +0 -1
- package/esm/MCScanAnchorsAdapter/configSchema.js.map +0 -1
- package/esm/MCScanAnchorsAdapter/index.js.map +0 -1
- package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js.map +0 -1
- package/esm/MCScanSimpleAnchorsAdapter/configSchema.js.map +0 -1
- package/esm/MCScanSimpleAnchorsAdapter/index.js.map +0 -1
- package/esm/MashMapAdapter/MashMapAdapter.js.map +0 -1
- package/esm/MashMapAdapter/configSchema.js.map +0 -1
- package/esm/MashMapAdapter/index.js.map +0 -1
- package/esm/PAFAdapter/PAFAdapter.js.map +0 -1
- package/esm/PAFAdapter/SyntenyFeature.js.map +0 -1
- package/esm/PAFAdapter/configSchema.js.map +0 -1
- package/esm/PAFAdapter/index.js.map +0 -1
- package/esm/PAFAdapter/util.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/util.js.map +0 -1
- package/src/ChainAdapter/ChainAdapter.ts +0 -18
- package/src/ChainAdapter/configSchema.ts +0 -50
- package/src/ChainAdapter/index.ts +0 -18
- package/src/ChainAdapter/util.ts +0 -170
- package/src/DeltaAdapter/DeltaAdapter.ts +0 -18
- package/src/DeltaAdapter/configSchema.ts +0 -50
- package/src/DeltaAdapter/index.ts +0 -18
- package/src/DeltaAdapter/util.ts +0 -149
- package/src/MCScanAnchorsAdapter/MCScanAnchorsAdapter.test.ts +0 -45
- package/src/MCScanAnchorsAdapter/MCScanAnchorsAdapter.ts +0 -134
- package/src/MCScanAnchorsAdapter/configSchema.ts +0 -52
- package/src/MCScanAnchorsAdapter/index.ts +0 -20
- package/src/MCScanAnchorsAdapter/test_data/grape.bed.gz +0 -0
- package/src/MCScanAnchorsAdapter/test_data/grape.peach.anchors.gz +0 -0
- package/src/MCScanAnchorsAdapter/test_data/peach.bed.gz +0 -0
- package/src/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.ts +0 -157
- package/src/MCScanSimpleAnchorsAdapter/configSchema.ts +0 -52
- package/src/MCScanSimpleAnchorsAdapter/index.ts +0 -19
- package/src/MashMapAdapter/MashMapAdapter.ts +0 -40
- package/src/MashMapAdapter/configSchema.ts +0 -51
- package/src/MashMapAdapter/index.ts +0 -18
- package/src/PAFAdapter/PAFAdapter.test.ts +0 -37
- package/src/PAFAdapter/PAFAdapter.ts +0 -181
- package/src/PAFAdapter/SyntenyFeature.ts +0 -15
- package/src/PAFAdapter/configSchema.ts +0 -50
- package/src/PAFAdapter/index.ts +0 -18
- package/src/PAFAdapter/test_data/grape.peach.anchors +0 -14966
- package/src/PAFAdapter/test_data/peach_grape.paf +0 -30
- package/src/PAFAdapter/util.test.ts +0 -7
- package/src/PAFAdapter/util.ts +0 -176
- package/src/index.ts +0 -62
- package/src/util.ts +0 -66
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Pp01 47851208 29082916 29084251 - chr1 23037639 33358 34714 133 1384 28 tp:A:P cm:i:11 s1:i:118 s2:i:0 dv:f:0.2085 rl:i:921840
|
|
2
|
-
Pp01 47851208 28948232 28948605 - chr1 23037639 93405 93770 64 373 8 tp:A:P cm:i:6 s1:i:62 s2:i:0 dv:f:0.1609 rl:i:921840
|
|
3
|
-
Pp01 47851208 28945891 28946469 - chr1 23037639 97669 98259 52 590 3 tp:A:P cm:i:4 s1:i:50 s2:i:0 dv:f:0.2227 rl:i:921840
|
|
4
|
-
Pp05 18496696 16629254 16629762 - chr1 23037639 175180 175679 54 508 4 tp:A:P cm:i:6 s1:i:52 s2:i:0 dv:f:0.1841 rl:i:342905
|
|
5
|
-
Pp01 47851208 42403393 42405783 - chr1 23037639 187350 189723 52 2390 1 tp:A:P cm:i:5 s1:i:48 s2:i:45 dv:f:0.3006 rl:i:921840
|
|
6
|
-
Pp01 47851208 28921887 28922054 - chr1 23037639 206059 206226 53 167 4 tp:A:P cm:i:5 s1:i:53 s2:i:0 dv:f:0.1149 rl:i:921840
|
|
7
|
-
Pp08 22573980 13883074 13883131 - chr1 23037639 214168 214225 57 57 1 tp:A:P cm:i:10 s1:i:57 s2:i:54 dv:f:0.0122 rl:i:412904
|
|
8
|
-
Pp01 47851208 28915197 28916072 - chr1 23037639 221178 222026 60 881 4 tp:A:P cm:i:4 s1:i:53 s2:i:0 dv:f:0.2468 rl:i:921840
|
|
9
|
-
Pp01 47851208 28859196 28861497 + chr1 23037639 259252 261582 209 2393 32 tp:A:P cm:i:17 s1:i:180 s2:i:56 dv:f:0.2144 rl:i:921840
|
|
10
|
-
Pp01 47851208 28870442 28871466 + chr1 23037639 259252 260320 228 1116 36 tp:A:P cm:i:22 s1:i:203 s2:i:50 dv:f:0.1427 rl:i:921840
|
|
11
|
-
Pp01 47851208 49027 49442 - chr8 22385789 8155257 8155673 74 416 13 tp:A:P cm:i:7 s1:i:74 s2:i:0 dv:f:0.1632 rl:i:921840
|
|
12
|
-
Pp01 47851208 50074 50181 - chr8 22385789 8141660 8141767 45 107 1 tp:A:P cm:i:3 s1:i:45 s2:i:0 dv:f:0.1297 rl:i:921840
|
|
13
|
-
Pp01 47851208 53642 54893 + chr8 22385789 8654487 8655674 62 1252 2 tp:A:P cm:i:5 s1:i:51 s2:i:45 dv:f:0.2511 rl:i:921840
|
|
14
|
-
Pp01 47851208 73614 73741 - chr9 23006712 13774809 13774936 85 127 18 tp:A:P cm:i:11 s1:i:85 s2:i:0 dv:f:0.0462 rl:i:921840
|
|
15
|
-
Pp01 47851208 80728 82019 - chr9 23006712 13695413 13696666 103 1291 23 tp:A:P cm:i:10 s1:i:96 s2:i:0 dv:f:0.2146 rl:i:921840
|
|
16
|
-
Pp01 47851208 106247 106925 + chr18 29360087 13357403 13358082 40 679 0 tp:A:P cm:i:5 s1:i:40 s2:i:0 dv:f:0.2167 rl:i:921840
|
|
17
|
-
Pp01 47851208 152234 155151 + chr9 23006712 13559728 13562671 66 2943 7 tp:A:P cm:i:8 s1:i:61 s2:i:0 dv:f:0.2801 rl:i:921840
|
|
18
|
-
Pp01 47851208 155693 157683 + chr9 23006712 13564184 13566283 144 2114 28 tp:A:P cm:i:18 s1:i:120 s2:i:0 dv:f:0.2021 rl:i:921840
|
|
19
|
-
Pp01 47851208 182398 183170 - chr9 23006712 13416305 13417077 95 772 22 tp:A:P cm:i:11 s1:i:95 s2:i:0 dv:f:0.1728 rl:i:921840
|
|
20
|
-
Pp01 47851208 190128 190583 + chr11 19818926 13484635 13485088 52 455 4 tp:A:P cm:i:6 s1:i:52 s2:i:0 dv:f:0.1735 rl:i:921840
|
|
21
|
-
Pp01 47851208 198416 198881 + chr11 19818926 13484635 13485088 67 465 9 tp:A:P cm:i:7 s1:i:65 s2:i:0 dv:f:0.1664 rl:i:921840
|
|
22
|
-
Pp01 47851208 200192 200573 - chr9 23006712 13414133 13414502 69 381 10 tp:A:P cm:i:5 s1:i:67 s2:i:0 dv:f:0.1750 rl:i:921840
|
|
23
|
-
Pp01 47851208 226325 227449 - chr11 19818926 13696059 13697131 53 1124 1 tp:A:P cm:i:4 s1:i:44 s2:i:0 dv:f:0.2672 rl:i:921840
|
|
24
|
-
Pp01 47851208 271401 271610 + chr11 19818926 12455072 12455276 43 209 0 tp:A:P cm:i:4 s1:i:42 s2:i:0 dv:f:0.1483 rl:i:921840
|
|
25
|
-
Pp01 47851208 293468 294021 - chr5 25021643 13433981 13434596 101 616 20 tp:A:P cm:i:8 s1:i:90 s2:i:0 dv:f:0.1704 rl:i:921840
|
|
26
|
-
Pp01 47851208 295962 296255 - chr5 25021643 13417867 13418160 47 293 2 tp:A:P cm:i:4 s1:i:47 s2:i:0 dv:f:0.1723 rl:i:921840
|
|
27
|
-
Pp01 47851208 297240 297553 - chr5 25021643 13409896 13410221 63 325 7 tp:A:P cm:i:5 s1:i:61 s2:i:0 dv:f:0.1668 rl:i:921840
|
|
28
|
-
Pp01 47851208 308074 310236 + chr5 25021643 13571677 13573799 275 2162 43 tp:A:P cm:i:27 s1:i:268 s2:i:0 dv:f:0.1797 rl:i:921840
|
|
29
|
-
Pp01 47851208 336437 336584 - chr13 24396255 11913987 11914116 44 147 0 tp:A:P cm:i:5 s1:i:40 s2:i:0 dv:f:0.1149 rl:i:921840
|
|
30
|
-
Pp01 47851208 337661 338528 + chr5 25021643 11914299 11915296 111 998 19 tp:A:P cm:i:9 s1:i:87 s2:i:0 dv:f:0.1947 rl:i:921840
|
package/src/PAFAdapter/util.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { zip } from '../util'
|
|
2
|
-
|
|
3
|
-
export interface PAFRecord {
|
|
4
|
-
qname: string
|
|
5
|
-
qstart: number
|
|
6
|
-
qend: number
|
|
7
|
-
tname: string
|
|
8
|
-
tstart: number
|
|
9
|
-
tend: number
|
|
10
|
-
strand: number
|
|
11
|
-
extra: {
|
|
12
|
-
cg?: string
|
|
13
|
-
blockLen?: number
|
|
14
|
-
mappingQual: number
|
|
15
|
-
numMatches?: number
|
|
16
|
-
meanScore?: number
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// based on "weighted mean" method from https://github.com/tpoorten/dotPlotly
|
|
20
|
-
// License reproduced here
|
|
21
|
-
//
|
|
22
|
-
// MIT License
|
|
23
|
-
|
|
24
|
-
// Copyright (c) 2017 Tom Poorten
|
|
25
|
-
|
|
26
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
27
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
28
|
-
// in the Software without restriction, including without limitation the rights
|
|
29
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
30
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
31
|
-
// furnished to do so, subject to the following conditions:
|
|
32
|
-
|
|
33
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
34
|
-
// copies or substantial portions of the Software.
|
|
35
|
-
|
|
36
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
37
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
38
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
39
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
40
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
41
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
42
|
-
// SOFTWARE.
|
|
43
|
-
//
|
|
44
|
-
// Notes: in the weighted mean longer alignments factor in more heavily of all
|
|
45
|
-
// the fragments of a query vs the reference that it mapped to
|
|
46
|
-
//
|
|
47
|
-
// this uses a combined key query+'-'+ref to iteratively map all the alignments
|
|
48
|
-
// that match a particular ref from a particular query (so 1d array of what
|
|
49
|
-
// could be a 2d map)
|
|
50
|
-
//
|
|
51
|
-
// the result is a single number that says e.g. chr5 from human mapped to chr5
|
|
52
|
-
// on mouse with 0.8 quality, and that0.8 is then attached to all the pieces of
|
|
53
|
-
// chr5 on human that mapped to chr5 on mouse. if chr5 on human also more
|
|
54
|
-
// weakly mapped to chr6 on mouse, then it would have another value e.g. 0.6.
|
|
55
|
-
// this can show strong and weak levels of synteny, especially in polyploidy
|
|
56
|
-
// situations
|
|
57
|
-
|
|
58
|
-
export function getWeightedMeans(ret: PAFRecord[]) {
|
|
59
|
-
const scoreMap: { [key: string]: { quals: number[]; len: number[] } } = {}
|
|
60
|
-
for (let i = 0; i < ret.length; i++) {
|
|
61
|
-
const entry = ret[i]
|
|
62
|
-
const query = entry.qname
|
|
63
|
-
const target = entry.tname
|
|
64
|
-
const key = query + '-' + target
|
|
65
|
-
if (!scoreMap[key]) {
|
|
66
|
-
scoreMap[key] = { quals: [], len: [] }
|
|
67
|
-
}
|
|
68
|
-
scoreMap[key].quals.push(entry.extra.mappingQual)
|
|
69
|
-
scoreMap[key].len.push(entry.extra.blockLen || 1)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const meanScoreMap = Object.fromEntries(
|
|
73
|
-
Object.entries(scoreMap).map(([key, val]) => {
|
|
74
|
-
const vals = zip(val.quals, val.len)
|
|
75
|
-
return [key, weightedMean(vals)]
|
|
76
|
-
}),
|
|
77
|
-
)
|
|
78
|
-
for (let i = 0; i < ret.length; i++) {
|
|
79
|
-
const entry = ret[i]
|
|
80
|
-
const query = entry.qname
|
|
81
|
-
const target = entry.tname
|
|
82
|
-
const key = query + '-' + target
|
|
83
|
-
entry.extra.meanScore = meanScoreMap[key]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let min = 10000
|
|
87
|
-
let max = 0
|
|
88
|
-
for (let i = 0; i < ret.length; i++) {
|
|
89
|
-
const entry = ret[i]
|
|
90
|
-
min = Math.min(entry.extra.meanScore || 0, min)
|
|
91
|
-
max = Math.max(entry.extra.meanScore || 0, max)
|
|
92
|
-
}
|
|
93
|
-
for (let i = 0; i < ret.length; i++) {
|
|
94
|
-
const entry = ret[i]
|
|
95
|
-
const b = entry.extra.meanScore || 0
|
|
96
|
-
entry.extra.meanScore = (b - min) / (max - min)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return ret
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// https://gist.github.com/stekhn/a12ed417e91f90ecec14bcfa4c2ae16a
|
|
103
|
-
function weightedMean(tuples: [number, number][]) {
|
|
104
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
105
|
-
const [valueSum, weightSum] = tuples.reduce(
|
|
106
|
-
([valueSum, weightSum], [value, weight]) => [
|
|
107
|
-
valueSum + value * weight,
|
|
108
|
-
weightSum + weight,
|
|
109
|
-
],
|
|
110
|
-
[0, 0],
|
|
111
|
-
)
|
|
112
|
-
return valueSum / weightSum
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function parsePAFLine(line: string) {
|
|
116
|
-
const [
|
|
117
|
-
qname,
|
|
118
|
-
,
|
|
119
|
-
qstart,
|
|
120
|
-
qend,
|
|
121
|
-
strand,
|
|
122
|
-
tname,
|
|
123
|
-
,
|
|
124
|
-
tstart,
|
|
125
|
-
tend,
|
|
126
|
-
numMatches,
|
|
127
|
-
blockLen,
|
|
128
|
-
mappingQual,
|
|
129
|
-
...fields
|
|
130
|
-
] = line.split('\t')
|
|
131
|
-
|
|
132
|
-
const rest = Object.fromEntries(
|
|
133
|
-
fields.map(field => {
|
|
134
|
-
const r = field.indexOf(':')
|
|
135
|
-
const fieldName = field.slice(0, r)
|
|
136
|
-
const fieldValue = field.slice(r + 3)
|
|
137
|
-
return [fieldName, fieldValue]
|
|
138
|
-
}),
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
tname,
|
|
143
|
-
tstart: +tstart,
|
|
144
|
-
tend: +tend,
|
|
145
|
-
qname,
|
|
146
|
-
qstart: +qstart,
|
|
147
|
-
qend: +qend,
|
|
148
|
-
strand: strand === '-' ? -1 : 1,
|
|
149
|
-
extra: {
|
|
150
|
-
numMatches: +numMatches,
|
|
151
|
-
blockLen: +blockLen,
|
|
152
|
-
mappingQual: +mappingQual,
|
|
153
|
-
...rest,
|
|
154
|
-
},
|
|
155
|
-
} as PAFRecord
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function flipCigar(cigar: string[]) {
|
|
159
|
-
const arr = []
|
|
160
|
-
for (let i = cigar.length - 2; i >= 0; i -= 2) {
|
|
161
|
-
arr.push(cigar[i])
|
|
162
|
-
const op = cigar[i + 1]
|
|
163
|
-
if (op === 'D') {
|
|
164
|
-
arr.push('I')
|
|
165
|
-
} else if (op === 'I') {
|
|
166
|
-
arr.push('D')
|
|
167
|
-
} else {
|
|
168
|
-
arr.push(op)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return arr
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function swapIndelCigar(cigar: string) {
|
|
175
|
-
return cigar.replaceAll('D', 'K').replaceAll('I', 'D').replaceAll('K', 'I')
|
|
176
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import Plugin from '@jbrowse/core/Plugin'
|
|
2
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
3
|
-
import { FileLocation } from '@jbrowse/core/util/types'
|
|
4
|
-
|
|
5
|
-
import PAFAdapterF from './PAFAdapter'
|
|
6
|
-
import MCScanAnchorsAdapterF from './MCScanAnchorsAdapter'
|
|
7
|
-
import MCScanSimpleAnchorsAdapterF from './MCScanSimpleAnchorsAdapter'
|
|
8
|
-
import MashMapAdapterF from './MashMapAdapter'
|
|
9
|
-
import DeltaAdapterF from './DeltaAdapter'
|
|
10
|
-
import ChainAdapterF from './ChainAdapter'
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
getFileName,
|
|
14
|
-
AdapterGuesser,
|
|
15
|
-
TrackTypeGuesser,
|
|
16
|
-
} from '@jbrowse/core/util/tracks'
|
|
17
|
-
|
|
18
|
-
export default class ComparativeAdaptersPlugin extends Plugin {
|
|
19
|
-
name = 'ComparativeAdaptersPlugin'
|
|
20
|
-
|
|
21
|
-
install(pluginManager: PluginManager) {
|
|
22
|
-
PAFAdapterF(pluginManager)
|
|
23
|
-
DeltaAdapterF(pluginManager)
|
|
24
|
-
ChainAdapterF(pluginManager)
|
|
25
|
-
MCScanAnchorsAdapterF(pluginManager)
|
|
26
|
-
MCScanSimpleAnchorsAdapterF(pluginManager)
|
|
27
|
-
MashMapAdapterF(pluginManager)
|
|
28
|
-
|
|
29
|
-
pluginManager.addToExtensionPoint(
|
|
30
|
-
'Core-guessAdapterForLocation',
|
|
31
|
-
(adapterGuesser: AdapterGuesser) => {
|
|
32
|
-
return (
|
|
33
|
-
file: FileLocation,
|
|
34
|
-
index?: FileLocation,
|
|
35
|
-
adapterHint?: string,
|
|
36
|
-
) => {
|
|
37
|
-
const regexGuess = /\.paf/i
|
|
38
|
-
const adapterName = 'PAFAdapter'
|
|
39
|
-
const fileName = getFileName(file)
|
|
40
|
-
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
41
|
-
return {
|
|
42
|
-
type: adapterName,
|
|
43
|
-
pafLocation: file,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return adapterGuesser(file, index, adapterHint)
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
)
|
|
50
|
-
pluginManager.addToExtensionPoint(
|
|
51
|
-
'Core-guessTrackTypeForLocation',
|
|
52
|
-
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
53
|
-
return (adapterName: string) => {
|
|
54
|
-
if (adapterName === 'PAFAdapter') {
|
|
55
|
-
return 'SyntenyTrack'
|
|
56
|
-
}
|
|
57
|
-
return trackTypeGuesser(adapterName)
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
}
|
package/src/util.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
2
|
-
import { GenericFilehandle } from 'generic-filehandle'
|
|
3
|
-
import { unzip } from '@gmod/bgzf-filehandle'
|
|
4
|
-
import { PAFRecord } from './PAFAdapter/util'
|
|
5
|
-
|
|
6
|
-
export function isGzip(buf: Buffer) {
|
|
7
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function parseBed(text: string) {
|
|
11
|
-
return new Map(
|
|
12
|
-
text
|
|
13
|
-
.split(/\n|\r\n|\r/)
|
|
14
|
-
.filter(f => !!f || f.startsWith('#'))
|
|
15
|
-
.map(line => {
|
|
16
|
-
const [refName, start, end, name, score, strand] = line.split('\t')
|
|
17
|
-
return [
|
|
18
|
-
name,
|
|
19
|
-
{
|
|
20
|
-
refName,
|
|
21
|
-
start: +start,
|
|
22
|
-
end: +end,
|
|
23
|
-
score: +score,
|
|
24
|
-
name,
|
|
25
|
-
strand: strand === '-' ? -1 : 1,
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function readFile(file: GenericFilehandle, opts?: BaseOptions) {
|
|
33
|
-
const buffer = (await file.readFile(opts)) as Buffer
|
|
34
|
-
return new TextDecoder('utf8', { fatal: true }).decode(
|
|
35
|
-
isGzip(buffer) ? await unzip(buffer) : buffer,
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function zip(a: number[], b: number[]) {
|
|
40
|
-
return a.map((e, i) => [e, b[i]] as [number, number])
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const decoder =
|
|
44
|
-
typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined
|
|
45
|
-
|
|
46
|
-
export function parseLineByLine(
|
|
47
|
-
buffer: Buffer,
|
|
48
|
-
cb: (line: string) => PAFRecord,
|
|
49
|
-
) {
|
|
50
|
-
let blockStart = 0
|
|
51
|
-
const entries = []
|
|
52
|
-
while (blockStart < buffer.length) {
|
|
53
|
-
const n = buffer.indexOf('\n', blockStart)
|
|
54
|
-
if (n === -1) {
|
|
55
|
-
break
|
|
56
|
-
}
|
|
57
|
-
const b = buffer.slice(blockStart, n)
|
|
58
|
-
const line = (decoder?.decode(b) || b.toString()).trim()
|
|
59
|
-
if (line) {
|
|
60
|
-
entries.push(cb(line))
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
blockStart = n + 1
|
|
64
|
-
}
|
|
65
|
-
return entries
|
|
66
|
-
}
|