@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,134 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseFeatureDataAdapter,
|
|
3
|
-
BaseOptions,
|
|
4
|
-
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
6
|
-
import {
|
|
7
|
-
doesIntersect2,
|
|
8
|
-
SimpleFeature,
|
|
9
|
-
Feature,
|
|
10
|
-
Region,
|
|
11
|
-
} from '@jbrowse/core/util'
|
|
12
|
-
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
13
|
-
import { readFile, parseBed } from '../util'
|
|
14
|
-
|
|
15
|
-
interface BareFeature {
|
|
16
|
-
strand: number
|
|
17
|
-
refName: string
|
|
18
|
-
start: number
|
|
19
|
-
end: number
|
|
20
|
-
score: number
|
|
21
|
-
name: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type Row = [BareFeature, BareFeature, number, number]
|
|
25
|
-
|
|
26
|
-
export default class MCScanAnchorsAdapter extends BaseFeatureDataAdapter {
|
|
27
|
-
private setupP?: Promise<{
|
|
28
|
-
assemblyNames: string[]
|
|
29
|
-
feats: Row[]
|
|
30
|
-
}>
|
|
31
|
-
|
|
32
|
-
public static capabilities = ['getFeatures', 'getRefNames']
|
|
33
|
-
|
|
34
|
-
async setup(opts: BaseOptions) {
|
|
35
|
-
if (!this.setupP) {
|
|
36
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
37
|
-
this.setupP = undefined
|
|
38
|
-
throw e
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
return this.setupP
|
|
42
|
-
}
|
|
43
|
-
async setupPre(opts: BaseOptions) {
|
|
44
|
-
const assemblyNames = this.getConf('assemblyNames') as string[]
|
|
45
|
-
|
|
46
|
-
const pm = this.pluginManager
|
|
47
|
-
const bed1 = openLocation(this.getConf('bed1Location'), pm)
|
|
48
|
-
const bed2 = openLocation(this.getConf('bed2Location'), pm)
|
|
49
|
-
const mcscan = openLocation(this.getConf('mcscanAnchorsLocation'), pm)
|
|
50
|
-
const [bed1text, bed2text, mcscantext] = await Promise.all(
|
|
51
|
-
[bed1, bed2, mcscan].map(r => readFile(r, opts)),
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
const bed1Map = parseBed(bed1text)
|
|
55
|
-
const bed2Map = parseBed(bed2text)
|
|
56
|
-
const feats = mcscantext
|
|
57
|
-
.split(/\n|\r\n|\r/)
|
|
58
|
-
.filter(f => !!f && f !== '###')
|
|
59
|
-
.map((line, index) => {
|
|
60
|
-
const [name1, name2, score] = line.split('\t')
|
|
61
|
-
const r1 = bed1Map.get(name1)
|
|
62
|
-
const r2 = bed2Map.get(name2)
|
|
63
|
-
if (!r1 || !r2) {
|
|
64
|
-
throw new Error(`feature not found, ${name1} ${name2} ${r1} ${r2}`)
|
|
65
|
-
}
|
|
66
|
-
return [r1, r2, +score, index] as Row
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
assemblyNames,
|
|
71
|
-
feats,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async hasDataForRefName() {
|
|
76
|
-
// determining this properly is basically a call to getFeatures
|
|
77
|
-
// so is not really that important, and has to be true or else
|
|
78
|
-
// getFeatures is never called (BaseFeatureDataAdapter filters it out)
|
|
79
|
-
return true
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async getRefNames() {
|
|
83
|
-
// we cannot determine this accurately
|
|
84
|
-
return []
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
getFeatures(region: Region, opts: BaseOptions = {}) {
|
|
88
|
-
return ObservableCreate<Feature>(async observer => {
|
|
89
|
-
const { assemblyNames, feats } = await this.setup(opts)
|
|
90
|
-
|
|
91
|
-
// The index of the assembly name in the region list corresponds to
|
|
92
|
-
// the adapter in the subadapters list
|
|
93
|
-
const index = assemblyNames.indexOf(region.assemblyName)
|
|
94
|
-
if (index !== -1) {
|
|
95
|
-
const flip = index === 0
|
|
96
|
-
feats.forEach(f => {
|
|
97
|
-
const [r1, r2, score, rowNum] = f
|
|
98
|
-
const [f1, f2] = !flip ? [r2, r1] : [r1, r2]
|
|
99
|
-
if (
|
|
100
|
-
f1.refName === region.refName &&
|
|
101
|
-
doesIntersect2(region.start, region.end, f1.start, f1.end)
|
|
102
|
-
) {
|
|
103
|
-
observer.next(
|
|
104
|
-
new SimpleFeature({
|
|
105
|
-
...f1,
|
|
106
|
-
uniqueId: `${index}-${rowNum}`,
|
|
107
|
-
syntenyId: rowNum,
|
|
108
|
-
|
|
109
|
-
// note: strand would be -1 if the two features are on opposite
|
|
110
|
-
// strands, indicating inverted alignment
|
|
111
|
-
strand: f1.strand * f2.strand,
|
|
112
|
-
assemblyName: assemblyNames[+!flip],
|
|
113
|
-
score,
|
|
114
|
-
mate: {
|
|
115
|
-
...f2,
|
|
116
|
-
assemblyName: assemblyNames[+flip],
|
|
117
|
-
},
|
|
118
|
-
}),
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
observer.complete()
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* called to provide a hint that data tied to a certain region
|
|
130
|
-
* will not be needed for the foreseeable future and can be purged
|
|
131
|
-
* from caches, etc
|
|
132
|
-
*/
|
|
133
|
-
freeResources(/* { region } */): void {}
|
|
134
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* #config MCScanAnchorsAdapter
|
|
5
|
-
*/
|
|
6
|
-
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
-
|
|
8
|
-
const MCScanAnchorsAdapter = ConfigurationSchema(
|
|
9
|
-
'MCScanAnchorsAdapter',
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* #slot
|
|
13
|
-
*/
|
|
14
|
-
mcscanAnchorsLocation: {
|
|
15
|
-
type: 'fileLocation',
|
|
16
|
-
defaultValue: {
|
|
17
|
-
uri: '/path/to/mcscan.anchors',
|
|
18
|
-
locationType: 'UriLocation',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* #slot
|
|
23
|
-
*/
|
|
24
|
-
bed1Location: {
|
|
25
|
-
type: 'fileLocation',
|
|
26
|
-
defaultValue: {
|
|
27
|
-
uri: '/path/to/file.bed',
|
|
28
|
-
locationType: 'UriLocation',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* #slot
|
|
33
|
-
*/
|
|
34
|
-
bed2Location: {
|
|
35
|
-
type: 'fileLocation',
|
|
36
|
-
defaultValue: {
|
|
37
|
-
uri: '/path/to/file.bed',
|
|
38
|
-
locationType: 'UriLocation',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
/**
|
|
42
|
-
* #slot
|
|
43
|
-
*/
|
|
44
|
-
assemblyNames: {
|
|
45
|
-
type: 'stringArray',
|
|
46
|
-
defaultValue: [],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{ explicitlyTyped: true },
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
export default MCScanAnchorsAdapter
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
-
import configSchema from './configSchema'
|
|
4
|
-
|
|
5
|
-
export default (pluginManager: PluginManager) => {
|
|
6
|
-
pluginManager.addAdapterType(
|
|
7
|
-
() =>
|
|
8
|
-
new AdapterType({
|
|
9
|
-
name: 'MCScanAnchorsAdapter',
|
|
10
|
-
displayName: 'MCScan anchors adapter',
|
|
11
|
-
configSchema,
|
|
12
|
-
adapterMetadata: {
|
|
13
|
-
hiddenFromGUI: true,
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
getAdapterClass: () =>
|
|
17
|
-
import('./MCScanAnchorsAdapter').then(r => r.default),
|
|
18
|
-
}),
|
|
19
|
-
)
|
|
20
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseFeatureDataAdapter,
|
|
3
|
-
BaseOptions,
|
|
4
|
-
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import { Region } from '@jbrowse/core/util/types'
|
|
6
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
7
|
-
import { doesIntersect2 } from '@jbrowse/core/util'
|
|
8
|
-
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
9
|
-
import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
10
|
-
import { readFile, parseBed } from '../util'
|
|
11
|
-
|
|
12
|
-
interface BareFeature {
|
|
13
|
-
refName: string
|
|
14
|
-
start: number
|
|
15
|
-
end: number
|
|
16
|
-
score: number
|
|
17
|
-
name: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type Row = [
|
|
21
|
-
BareFeature,
|
|
22
|
-
BareFeature,
|
|
23
|
-
BareFeature,
|
|
24
|
-
BareFeature,
|
|
25
|
-
number,
|
|
26
|
-
number,
|
|
27
|
-
number,
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
export default class MCScanAnchorsAdapter extends BaseFeatureDataAdapter {
|
|
31
|
-
private setupP?: Promise<{
|
|
32
|
-
assemblyNames: string[]
|
|
33
|
-
feats: Row[]
|
|
34
|
-
}>
|
|
35
|
-
|
|
36
|
-
public static capabilities = ['getFeatures', 'getRefNames']
|
|
37
|
-
|
|
38
|
-
async setup(opts: BaseOptions) {
|
|
39
|
-
if (!this.setupP) {
|
|
40
|
-
this.setupP = this.setupPre(opts).catch(e => {
|
|
41
|
-
this.setupP = undefined
|
|
42
|
-
throw e
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
return this.setupP
|
|
46
|
-
}
|
|
47
|
-
async setupPre(opts: BaseOptions) {
|
|
48
|
-
const assemblyNames = this.getConf('assemblyNames') as string[]
|
|
49
|
-
const pm = this.pluginManager
|
|
50
|
-
const bed1 = openLocation(this.getConf('bed1Location'), pm)
|
|
51
|
-
const bed2 = openLocation(this.getConf('bed2Location'), pm)
|
|
52
|
-
const mcscan = openLocation(this.getConf('mcscanSimpleAnchorsLocation'), pm)
|
|
53
|
-
const [bed1text, bed2text, mcscantext] = await Promise.all(
|
|
54
|
-
[bed1, bed2, mcscan].map(r => readFile(r, opts)),
|
|
55
|
-
)
|
|
56
|
-
const bed1Map = parseBed(bed1text)
|
|
57
|
-
const bed2Map = parseBed(bed2text)
|
|
58
|
-
const feats = mcscantext
|
|
59
|
-
.split(/\n|\r\n|\r/)
|
|
60
|
-
.filter(f => !!f && f !== '###')
|
|
61
|
-
.map((line, index) => {
|
|
62
|
-
const [n11, n12, n21, n22, score, strand] = line.split('\t')
|
|
63
|
-
const r11 = bed1Map.get(n11)
|
|
64
|
-
const r12 = bed1Map.get(n12)
|
|
65
|
-
const r21 = bed2Map.get(n21)
|
|
66
|
-
const r22 = bed2Map.get(n22)
|
|
67
|
-
if (!r11 || !r12 || !r21 || !r22) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`feature not found, ${n11} ${n12} ${n21} ${n22} ${r11} ${r12} ${r21} ${r22}`,
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
return [
|
|
73
|
-
r11,
|
|
74
|
-
r12,
|
|
75
|
-
r21,
|
|
76
|
-
r22,
|
|
77
|
-
+score,
|
|
78
|
-
strand === '-' ? -1 : 1,
|
|
79
|
-
index,
|
|
80
|
-
] as Row
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
assemblyNames,
|
|
85
|
-
feats,
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async hasDataForRefName() {
|
|
90
|
-
// determining this properly is basically a call to getFeatures
|
|
91
|
-
// so is not really that important, and has to be true or else
|
|
92
|
-
// getFeatures is never called (BaseFeatureDataAdapter filters it out)
|
|
93
|
-
return true
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async getRefNames() {
|
|
97
|
-
// we cannot determine this accurately
|
|
98
|
-
return []
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getFeatures(region: Region, opts: BaseOptions = {}) {
|
|
102
|
-
return ObservableCreate<Feature>(async observer => {
|
|
103
|
-
const { assemblyNames, feats } = await this.setup(opts)
|
|
104
|
-
|
|
105
|
-
// The index of the assembly name in the region list corresponds to
|
|
106
|
-
// the adapter in the subadapters list
|
|
107
|
-
const index = assemblyNames.indexOf(region.assemblyName)
|
|
108
|
-
if (index !== -1) {
|
|
109
|
-
const flip = index === 0
|
|
110
|
-
feats.forEach(f => {
|
|
111
|
-
const [f11, f12, f21, f22, score, strand, rowNum] = f
|
|
112
|
-
let r1 = {
|
|
113
|
-
refName: f11.refName,
|
|
114
|
-
start: Math.min(f11.start, f12.start),
|
|
115
|
-
end: Math.max(f11.end, f12.end),
|
|
116
|
-
}
|
|
117
|
-
let r2 = {
|
|
118
|
-
refName: f21.refName,
|
|
119
|
-
start: Math.min(f21.start, f22.start),
|
|
120
|
-
end: Math.max(f21.end, f22.end),
|
|
121
|
-
}
|
|
122
|
-
if (!flip) {
|
|
123
|
-
;[r2, r1] = [r1, r2]
|
|
124
|
-
}
|
|
125
|
-
if (
|
|
126
|
-
r1.refName === region.refName &&
|
|
127
|
-
doesIntersect2(r1.start, r1.end, region.start, region.end)
|
|
128
|
-
) {
|
|
129
|
-
observer.next(
|
|
130
|
-
new SimpleFeature({
|
|
131
|
-
...r1,
|
|
132
|
-
uniqueId: `${rowNum}`,
|
|
133
|
-
syntenyId: rowNum,
|
|
134
|
-
assemblyName: assemblyNames[+!flip],
|
|
135
|
-
score,
|
|
136
|
-
strand,
|
|
137
|
-
mate: {
|
|
138
|
-
...r2,
|
|
139
|
-
assemblyName: assemblyNames[+flip],
|
|
140
|
-
},
|
|
141
|
-
}),
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
observer.complete()
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* called to provide a hint that data tied to a certain region
|
|
153
|
-
* will not be needed for the foreseeable future and can be purged
|
|
154
|
-
* from caches, etc
|
|
155
|
-
*/
|
|
156
|
-
freeResources(/* { region } */): void {}
|
|
157
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* #config MCScanSimpleAnchorsAdapter
|
|
5
|
-
*/
|
|
6
|
-
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
-
|
|
8
|
-
const MCScanSimpleAnchorsAdapter = ConfigurationSchema(
|
|
9
|
-
'MCScanSimpleAnchorsAdapter',
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* #slot
|
|
13
|
-
*/
|
|
14
|
-
mcscanSimpleAnchorsLocation: {
|
|
15
|
-
type: 'fileLocation',
|
|
16
|
-
defaultValue: {
|
|
17
|
-
uri: '/path/to/mcscan.anchors.simple',
|
|
18
|
-
locationType: 'UriLocation',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* #slot
|
|
23
|
-
*/
|
|
24
|
-
bed1Location: {
|
|
25
|
-
type: 'fileLocation',
|
|
26
|
-
defaultValue: {
|
|
27
|
-
uri: '/path/to/file.bed',
|
|
28
|
-
locationType: 'UriLocation',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* #slot
|
|
33
|
-
*/
|
|
34
|
-
bed2Location: {
|
|
35
|
-
type: 'fileLocation',
|
|
36
|
-
defaultValue: {
|
|
37
|
-
uri: '/path/to/file.bed',
|
|
38
|
-
locationType: 'UriLocation',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* #slot
|
|
44
|
-
*/
|
|
45
|
-
assemblyNames: {
|
|
46
|
-
type: 'stringArray',
|
|
47
|
-
defaultValue: [],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{ explicitlyTyped: true },
|
|
51
|
-
)
|
|
52
|
-
export default MCScanSimpleAnchorsAdapter
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
-
import configSchema from './configSchema'
|
|
4
|
-
|
|
5
|
-
export default (pluginManager: PluginManager) => {
|
|
6
|
-
pluginManager.addAdapterType(
|
|
7
|
-
() =>
|
|
8
|
-
new AdapterType({
|
|
9
|
-
name: 'MCScanSimpleAnchorsAdapter',
|
|
10
|
-
displayName: 'MCScan anchors.simple adapter',
|
|
11
|
-
configSchema,
|
|
12
|
-
adapterMetadata: {
|
|
13
|
-
hiddenFromGUI: true,
|
|
14
|
-
},
|
|
15
|
-
getAdapterClass: () =>
|
|
16
|
-
import('./MCScanSimpleAnchorsAdapter').then(r => r.default),
|
|
17
|
-
}),
|
|
18
|
-
)
|
|
19
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
2
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
3
|
-
import { unzip } from '@gmod/bgzf-filehandle'
|
|
4
|
-
import PAFAdapter from '../PAFAdapter/PAFAdapter'
|
|
5
|
-
import { parseLineByLine } from '../util'
|
|
6
|
-
|
|
7
|
-
function isGzip(buf: Buffer) {
|
|
8
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default class MashMapAdapter extends PAFAdapter {
|
|
12
|
-
async setupPre(opts?: BaseOptions) {
|
|
13
|
-
const outLoc = openLocation(this.getConf('outLocation'), this.pluginManager)
|
|
14
|
-
const buffer = (await outLoc.readFile(opts)) as Buffer
|
|
15
|
-
const buf = isGzip(buffer) ? await unzip(buffer) : buffer
|
|
16
|
-
return parseLineByLine(buf, parseMashMapLine)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function parseMashMapLine(line: string) {
|
|
21
|
-
const fields = line.split(' ')
|
|
22
|
-
if (fields.length < 9) {
|
|
23
|
-
// xref https://github.com/marbl/MashMap/issues/38
|
|
24
|
-
throw new Error('improperly formatted line: ' + line)
|
|
25
|
-
}
|
|
26
|
-
const [qname, , qstart, qend, strand, tname, , tstart, tend, mq] = fields
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
tname,
|
|
30
|
-
tstart: +tstart,
|
|
31
|
-
tend: +tend,
|
|
32
|
-
qname,
|
|
33
|
-
qstart: +qstart,
|
|
34
|
-
qend: +qend,
|
|
35
|
-
strand: strand === '-' ? -1 : 1,
|
|
36
|
-
extra: {
|
|
37
|
-
mappingQual: +mq,
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* #config MashMapAdapter
|
|
5
|
-
*/
|
|
6
|
-
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
-
|
|
8
|
-
const MashMapAdapter = ConfigurationSchema(
|
|
9
|
-
'MashMapAdapter',
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* #slot
|
|
13
|
-
*/
|
|
14
|
-
assemblyNames: {
|
|
15
|
-
type: 'stringArray',
|
|
16
|
-
defaultValue: [],
|
|
17
|
-
description:
|
|
18
|
-
'Target is the first value in the array, query is the second',
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* #slot
|
|
23
|
-
*/
|
|
24
|
-
targetAssembly: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
defaultValue: '',
|
|
27
|
-
description: 'Alternative to assemblyNames array: the target assembly',
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* #slot
|
|
31
|
-
*/
|
|
32
|
-
queryAssembly: {
|
|
33
|
-
type: 'string',
|
|
34
|
-
defaultValue: '',
|
|
35
|
-
description: 'Alternative to assemblyNames array: the query assembly',
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* #slot
|
|
39
|
-
*/
|
|
40
|
-
outLocation: {
|
|
41
|
-
type: 'fileLocation',
|
|
42
|
-
defaultValue: {
|
|
43
|
-
uri: '/path/to/mashmap.out',
|
|
44
|
-
locationType: 'UriLocation',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
{ explicitlyTyped: true },
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
export default MashMapAdapter
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
-
import configSchema from './configSchema'
|
|
4
|
-
|
|
5
|
-
export default (pluginManager: PluginManager) => {
|
|
6
|
-
pluginManager.addAdapterType(
|
|
7
|
-
() =>
|
|
8
|
-
new AdapterType({
|
|
9
|
-
name: 'MashMapAdapter',
|
|
10
|
-
displayName: 'MashMap adapter',
|
|
11
|
-
configSchema,
|
|
12
|
-
adapterMetadata: {
|
|
13
|
-
hiddenFromGUI: true,
|
|
14
|
-
},
|
|
15
|
-
getAdapterClass: () => import('./MashMapAdapter').then(r => r.default),
|
|
16
|
-
}),
|
|
17
|
-
)
|
|
18
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { toArray } from 'rxjs/operators'
|
|
2
|
-
import { firstValueFrom } from 'rxjs'
|
|
3
|
-
import Adapter from './PAFAdapter'
|
|
4
|
-
import MyConfigSchema from './configSchema'
|
|
5
|
-
|
|
6
|
-
test('adapter can fetch features from peach_grape.paf', async () => {
|
|
7
|
-
const adapter = new Adapter(
|
|
8
|
-
MyConfigSchema.create({
|
|
9
|
-
pafLocation: {
|
|
10
|
-
localPath: require.resolve('./test_data/peach_grape.paf'),
|
|
11
|
-
locationType: 'LocalPathLocation',
|
|
12
|
-
},
|
|
13
|
-
assemblyNames: ['peach', 'grape'],
|
|
14
|
-
}),
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const features1 = adapter.getFeatures({
|
|
18
|
-
refName: 'Pp01',
|
|
19
|
-
start: 0,
|
|
20
|
-
end: 200000,
|
|
21
|
-
assemblyName: 'peach',
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const features2 = adapter.getFeatures({
|
|
25
|
-
refName: 'chr1',
|
|
26
|
-
start: 0,
|
|
27
|
-
end: 200000,
|
|
28
|
-
assemblyName: 'grape',
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const fa1 = await firstValueFrom(features1.pipe(toArray()))
|
|
32
|
-
const fa2 = await firstValueFrom(features2.pipe(toArray()))
|
|
33
|
-
expect(fa1.length).toBe(11)
|
|
34
|
-
expect(fa2.length).toBe(5)
|
|
35
|
-
expect(fa1[0].get('refName')).toBe('Pp01')
|
|
36
|
-
expect(fa2[0].get('refName')).toBe('chr1')
|
|
37
|
-
})
|