@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.
Files changed (129) hide show
  1. package/dist/ChainAdapter/ChainAdapter.js +0 -1
  2. package/dist/ChainAdapter/configSchema.js +0 -1
  3. package/dist/ChainAdapter/index.js +0 -1
  4. package/dist/ChainAdapter/util.js +0 -1
  5. package/dist/DeltaAdapter/DeltaAdapter.js +0 -1
  6. package/dist/DeltaAdapter/configSchema.js +0 -1
  7. package/dist/DeltaAdapter/index.js +0 -1
  8. package/dist/DeltaAdapter/util.js +0 -1
  9. package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +0 -1
  10. package/dist/MCScanAnchorsAdapter/configSchema.js +0 -1
  11. package/dist/MCScanAnchorsAdapter/index.js +0 -1
  12. package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +0 -1
  13. package/dist/MCScanSimpleAnchorsAdapter/configSchema.js +0 -1
  14. package/dist/MCScanSimpleAnchorsAdapter/index.js +0 -1
  15. package/dist/MashMapAdapter/MashMapAdapter.js +0 -1
  16. package/dist/MashMapAdapter/configSchema.js +0 -1
  17. package/dist/MashMapAdapter/index.js +0 -1
  18. package/dist/PAFAdapter/PAFAdapter.js +0 -1
  19. package/dist/PAFAdapter/SyntenyFeature.js +0 -1
  20. package/dist/PAFAdapter/configSchema.js +0 -1
  21. package/dist/PAFAdapter/index.js +0 -1
  22. package/dist/PAFAdapter/util.js +0 -1
  23. package/dist/index.js +0 -1
  24. package/dist/util.js +0 -1
  25. package/esm/ChainAdapter/ChainAdapter.js +0 -1
  26. package/esm/ChainAdapter/configSchema.js +0 -1
  27. package/esm/ChainAdapter/index.js +0 -1
  28. package/esm/ChainAdapter/util.js +0 -1
  29. package/esm/DeltaAdapter/DeltaAdapter.js +0 -1
  30. package/esm/DeltaAdapter/configSchema.js +0 -1
  31. package/esm/DeltaAdapter/index.js +0 -1
  32. package/esm/DeltaAdapter/util.js +0 -1
  33. package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +0 -1
  34. package/esm/MCScanAnchorsAdapter/configSchema.js +0 -1
  35. package/esm/MCScanAnchorsAdapter/index.js +0 -1
  36. package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +0 -1
  37. package/esm/MCScanSimpleAnchorsAdapter/configSchema.js +0 -1
  38. package/esm/MCScanSimpleAnchorsAdapter/index.js +0 -1
  39. package/esm/MashMapAdapter/MashMapAdapter.js +0 -1
  40. package/esm/MashMapAdapter/configSchema.js +0 -1
  41. package/esm/MashMapAdapter/index.js +0 -1
  42. package/esm/PAFAdapter/PAFAdapter.js +0 -1
  43. package/esm/PAFAdapter/SyntenyFeature.js +0 -1
  44. package/esm/PAFAdapter/configSchema.js +0 -1
  45. package/esm/PAFAdapter/index.js +0 -1
  46. package/esm/PAFAdapter/util.js +0 -1
  47. package/esm/index.js +0 -1
  48. package/esm/util.js +0 -1
  49. package/package.json +3 -4
  50. package/dist/ChainAdapter/ChainAdapter.js.map +0 -1
  51. package/dist/ChainAdapter/configSchema.js.map +0 -1
  52. package/dist/ChainAdapter/index.js.map +0 -1
  53. package/dist/ChainAdapter/util.js.map +0 -1
  54. package/dist/DeltaAdapter/DeltaAdapter.js.map +0 -1
  55. package/dist/DeltaAdapter/configSchema.js.map +0 -1
  56. package/dist/DeltaAdapter/index.js.map +0 -1
  57. package/dist/DeltaAdapter/util.js.map +0 -1
  58. package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js.map +0 -1
  59. package/dist/MCScanAnchorsAdapter/configSchema.js.map +0 -1
  60. package/dist/MCScanAnchorsAdapter/index.js.map +0 -1
  61. package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js.map +0 -1
  62. package/dist/MCScanSimpleAnchorsAdapter/configSchema.js.map +0 -1
  63. package/dist/MCScanSimpleAnchorsAdapter/index.js.map +0 -1
  64. package/dist/MashMapAdapter/MashMapAdapter.js.map +0 -1
  65. package/dist/MashMapAdapter/configSchema.js.map +0 -1
  66. package/dist/MashMapAdapter/index.js.map +0 -1
  67. package/dist/PAFAdapter/PAFAdapter.js.map +0 -1
  68. package/dist/PAFAdapter/SyntenyFeature.js.map +0 -1
  69. package/dist/PAFAdapter/configSchema.js.map +0 -1
  70. package/dist/PAFAdapter/index.js.map +0 -1
  71. package/dist/PAFAdapter/util.js.map +0 -1
  72. package/dist/index.js.map +0 -1
  73. package/dist/util.js.map +0 -1
  74. package/esm/ChainAdapter/ChainAdapter.js.map +0 -1
  75. package/esm/ChainAdapter/configSchema.js.map +0 -1
  76. package/esm/ChainAdapter/index.js.map +0 -1
  77. package/esm/ChainAdapter/util.js.map +0 -1
  78. package/esm/DeltaAdapter/DeltaAdapter.js.map +0 -1
  79. package/esm/DeltaAdapter/configSchema.js.map +0 -1
  80. package/esm/DeltaAdapter/index.js.map +0 -1
  81. package/esm/DeltaAdapter/util.js.map +0 -1
  82. package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js.map +0 -1
  83. package/esm/MCScanAnchorsAdapter/configSchema.js.map +0 -1
  84. package/esm/MCScanAnchorsAdapter/index.js.map +0 -1
  85. package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js.map +0 -1
  86. package/esm/MCScanSimpleAnchorsAdapter/configSchema.js.map +0 -1
  87. package/esm/MCScanSimpleAnchorsAdapter/index.js.map +0 -1
  88. package/esm/MashMapAdapter/MashMapAdapter.js.map +0 -1
  89. package/esm/MashMapAdapter/configSchema.js.map +0 -1
  90. package/esm/MashMapAdapter/index.js.map +0 -1
  91. package/esm/PAFAdapter/PAFAdapter.js.map +0 -1
  92. package/esm/PAFAdapter/SyntenyFeature.js.map +0 -1
  93. package/esm/PAFAdapter/configSchema.js.map +0 -1
  94. package/esm/PAFAdapter/index.js.map +0 -1
  95. package/esm/PAFAdapter/util.js.map +0 -1
  96. package/esm/index.js.map +0 -1
  97. package/esm/util.js.map +0 -1
  98. package/src/ChainAdapter/ChainAdapter.ts +0 -18
  99. package/src/ChainAdapter/configSchema.ts +0 -50
  100. package/src/ChainAdapter/index.ts +0 -18
  101. package/src/ChainAdapter/util.ts +0 -170
  102. package/src/DeltaAdapter/DeltaAdapter.ts +0 -18
  103. package/src/DeltaAdapter/configSchema.ts +0 -50
  104. package/src/DeltaAdapter/index.ts +0 -18
  105. package/src/DeltaAdapter/util.ts +0 -149
  106. package/src/MCScanAnchorsAdapter/MCScanAnchorsAdapter.test.ts +0 -45
  107. package/src/MCScanAnchorsAdapter/MCScanAnchorsAdapter.ts +0 -134
  108. package/src/MCScanAnchorsAdapter/configSchema.ts +0 -52
  109. package/src/MCScanAnchorsAdapter/index.ts +0 -20
  110. package/src/MCScanAnchorsAdapter/test_data/grape.bed.gz +0 -0
  111. package/src/MCScanAnchorsAdapter/test_data/grape.peach.anchors.gz +0 -0
  112. package/src/MCScanAnchorsAdapter/test_data/peach.bed.gz +0 -0
  113. package/src/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.ts +0 -157
  114. package/src/MCScanSimpleAnchorsAdapter/configSchema.ts +0 -52
  115. package/src/MCScanSimpleAnchorsAdapter/index.ts +0 -19
  116. package/src/MashMapAdapter/MashMapAdapter.ts +0 -40
  117. package/src/MashMapAdapter/configSchema.ts +0 -51
  118. package/src/MashMapAdapter/index.ts +0 -18
  119. package/src/PAFAdapter/PAFAdapter.test.ts +0 -37
  120. package/src/PAFAdapter/PAFAdapter.ts +0 -181
  121. package/src/PAFAdapter/SyntenyFeature.ts +0 -15
  122. package/src/PAFAdapter/configSchema.ts +0 -50
  123. package/src/PAFAdapter/index.ts +0 -18
  124. package/src/PAFAdapter/test_data/grape.peach.anchors +0 -14966
  125. package/src/PAFAdapter/test_data/peach_grape.paf +0 -30
  126. package/src/PAFAdapter/util.test.ts +0 -7
  127. package/src/PAFAdapter/util.ts +0 -176
  128. package/src/index.ts +0 -62
  129. package/src/util.ts +0 -66
@@ -1,181 +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 { doesIntersect2 } from '@jbrowse/core/util/range'
7
- import { openLocation } from '@jbrowse/core/util/io'
8
- import { ObservableCreate } from '@jbrowse/core/util/rxjs'
9
- import { Feature } from '@jbrowse/core/util'
10
- import {
11
- AnyConfigurationModel,
12
- readConfObject,
13
- } from '@jbrowse/core/configuration'
14
- import { unzip } from '@gmod/bgzf-filehandle'
15
- import { MismatchParser } from '@jbrowse/plugin-alignments'
16
-
17
- // locals
18
- import SyntenyFeature from './SyntenyFeature'
19
- import { isGzip, parseLineByLine } from '../util'
20
- import {
21
- getWeightedMeans,
22
- flipCigar,
23
- swapIndelCigar,
24
- parsePAFLine,
25
- PAFRecord,
26
- } from './util'
27
-
28
- const { parseCigar } = MismatchParser
29
-
30
- interface PAFOptions extends BaseOptions {
31
- config?: AnyConfigurationModel
32
- }
33
-
34
- export default class PAFAdapter extends BaseFeatureDataAdapter {
35
- private setupP?: Promise<PAFRecord[]>
36
-
37
- public static capabilities = ['getFeatures', 'getRefNames']
38
-
39
- async setup(opts?: BaseOptions) {
40
- if (!this.setupP) {
41
- this.setupP = this.setupPre(opts).catch(e => {
42
- this.setupP = undefined
43
- throw e
44
- })
45
- }
46
- return this.setupP
47
- }
48
-
49
- async setupPre(opts?: BaseOptions) {
50
- const pm = this.pluginManager
51
- const pafLocation = openLocation(this.getConf('pafLocation'), pm)
52
- const buffer = (await pafLocation.readFile(opts)) as Buffer
53
- const buf = isGzip(buffer) ? await unzip(buffer) : buffer
54
- return parseLineByLine(buf, parsePAFLine)
55
- }
56
-
57
- async hasDataForRefName() {
58
- // determining this properly is basically a call to getFeatures
59
- // so is not really that important, and has to be true or else
60
- // getFeatures is never called (BaseAdapter filters it out)
61
- return true
62
- }
63
-
64
- getAssemblyNames() {
65
- const assemblyNames = this.getConf('assemblyNames') as string[]
66
- if (assemblyNames.length === 0) {
67
- const query = this.getConf('queryAssembly') as string
68
- const target = this.getConf('targetAssembly') as string
69
- return [query, target]
70
- }
71
- return assemblyNames
72
- }
73
-
74
- async getRefNames(opts: BaseOptions = {}) {
75
- // @ts-expect-error
76
- const r1 = opts.regions?.[0].assemblyName
77
- const feats = await this.setup(opts)
78
-
79
- const idx = this.getAssemblyNames().indexOf(r1)
80
- if (idx !== -1) {
81
- const set = new Set<string>()
82
- for (const feat of feats) {
83
- set.add(idx === 0 ? feat.qname : feat.tname)
84
- }
85
- return [...set]
86
- }
87
- console.warn('Unable to do ref renaming on adapter')
88
- return []
89
- }
90
-
91
- getFeatures(query: Region, opts: PAFOptions = {}) {
92
- return ObservableCreate<Feature>(async observer => {
93
- let pafRecords = await this.setup(opts)
94
- const { config } = opts
95
-
96
- // note: this is not the adapter config, it is responding to a display
97
- // setting passed in via the opts parameter
98
- if (config && readConfObject(config, 'colorBy') === 'meanQueryIdentity') {
99
- pafRecords = getWeightedMeans(pafRecords)
100
- }
101
- const assemblyNames = this.getAssemblyNames()
102
-
103
- // The index of the assembly name in the query list corresponds to the
104
- // adapter in the subadapters list
105
- const index = assemblyNames.indexOf(query.assemblyName)
106
- const { start: qstart, end: qend, refName: qref, assemblyName } = query
107
- if (index === -1) {
108
- console.warn(`${assemblyName} not found in this adapter`)
109
- observer.complete()
110
- }
111
-
112
- for (let i = 0; i < pafRecords.length; i++) {
113
- const r = pafRecords[i]
114
- let start = 0
115
- let end = 0
116
- let refName = ''
117
- let mateName = ''
118
- let mateStart = 0
119
- let mateEnd = 0
120
- const flip = index === 0
121
- const assemblyName = assemblyNames[+!flip]
122
- if (index === 0) {
123
- start = r.qstart
124
- end = r.qend
125
- refName = r.qname
126
- mateName = r.tname
127
- mateStart = r.tstart
128
- mateEnd = r.tend
129
- } else {
130
- start = r.tstart
131
- end = r.tend
132
- refName = r.tname
133
- mateName = r.qname
134
- mateStart = r.qstart
135
- mateEnd = r.qend
136
- }
137
- const { extra, strand } = r
138
- if (refName === qref && doesIntersect2(qstart, qend, start, end)) {
139
- const { numMatches = 0, blockLen = 1, cg, ...rest } = extra
140
-
141
- let CIGAR = extra.cg
142
- if (extra.cg) {
143
- if (flip && strand === -1) {
144
- CIGAR = flipCigar(parseCigar(extra.cg)).join('')
145
- } else if (flip) {
146
- CIGAR = swapIndelCigar(extra.cg)
147
- }
148
- }
149
-
150
- observer.next(
151
- new SyntenyFeature({
152
- uniqueId: i + assemblyName,
153
- assemblyName,
154
- start,
155
- end,
156
- type: 'match',
157
- refName,
158
- strand,
159
- ...rest,
160
- CIGAR,
161
- syntenyId: i,
162
- identity: numMatches / blockLen,
163
- numMatches,
164
- blockLen,
165
- mate: {
166
- start: mateStart,
167
- end: mateEnd,
168
- refName: mateName,
169
- assemblyName: assemblyNames[+flip],
170
- },
171
- }),
172
- )
173
- }
174
- }
175
-
176
- observer.complete()
177
- })
178
- }
179
-
180
- freeResources(/* { query } */): void {}
181
- }
@@ -1,15 +0,0 @@
1
- import { SimpleFeature } from '@jbrowse/core/util'
2
- import { MismatchParser } from '@jbrowse/plugin-alignments'
3
-
4
- // locals
5
- const { getMismatches } = MismatchParser
6
-
7
- export default class SyntenyFeature extends SimpleFeature {
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- get(arg: string): any {
10
- if (arg === 'mismatches') {
11
- return getMismatches(this.get('CIGAR'))
12
- }
13
- return super.get(arg)
14
- }
15
- }
@@ -1,50 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
-
3
- /**
4
- * #config PAFAdapter
5
- */
6
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
7
-
8
- const PAFAdapter = ConfigurationSchema(
9
- 'PAFAdapter',
10
- {
11
- /**
12
- * #slot
13
- */
14
- assemblyNames: {
15
- type: 'stringArray',
16
- defaultValue: [],
17
- description:
18
- 'Array of assembly names to use for this file. The target assembly name is the first value in the array, query assembly name is the second',
19
- },
20
- /**
21
- * #slot
22
- */
23
- targetAssembly: {
24
- type: 'string',
25
- defaultValue: '',
26
- description: 'Alternative to assemblyNames: the target assembly name',
27
- },
28
- /**
29
- * #slot
30
- */
31
- queryAssembly: {
32
- type: 'string',
33
- defaultValue: '',
34
- description: 'Alternative to assemblyNames: the query assembly name',
35
- },
36
- /**
37
- * #slot
38
- */
39
- pafLocation: {
40
- type: 'fileLocation',
41
- defaultValue: {
42
- uri: '/path/to/file.paf',
43
- locationType: 'UriLocation',
44
- },
45
- },
46
- },
47
- { explicitlyTyped: true },
48
- )
49
-
50
- export default PAFAdapter
@@ -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: 'PAFAdapter',
10
- displayName: 'PAF adapter',
11
- configSchema,
12
- adapterMetadata: {
13
- hiddenFromGUI: true,
14
- },
15
- getAdapterClass: () => import('./PAFAdapter').then(r => r.default),
16
- }),
17
- )
18
- }