@jbrowse/plugin-sequence 2.1.0 → 2.1.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/BgzipFastaAdapter/BgzipFastaAdapter.d.ts +4 -4
- package/dist/BgzipFastaAdapter/BgzipFastaAdapter.js +14 -43
- package/dist/BgzipFastaAdapter/BgzipFastaAdapter.js.map +1 -1
- package/dist/BgzipFastaAdapter/configSchema.js +1 -1
- package/dist/BgzipFastaAdapter/configSchema.js.map +1 -1
- package/dist/BgzipFastaAdapter/index.d.ts +3 -1
- package/dist/BgzipFastaAdapter/index.js +38 -3
- package/dist/BgzipFastaAdapter/index.js.map +1 -1
- package/dist/ChromSizesAdapter/ChromSizesAdapter.js +34 -130
- package/dist/ChromSizesAdapter/ChromSizesAdapter.js.map +1 -1
- package/dist/ChromSizesAdapter/configSchema.js +1 -1
- package/dist/ChromSizesAdapter/configSchema.js.map +1 -1
- package/dist/ChromSizesAdapter/index.d.ts +3 -1
- package/dist/ChromSizesAdapter/index.js +38 -3
- package/dist/ChromSizesAdapter/index.js.map +1 -1
- package/dist/DivSequenceRenderer/components/DivSequenceRendering.js +51 -89
- package/dist/DivSequenceRenderer/components/DivSequenceRendering.js.map +1 -1
- package/dist/DivSequenceRenderer/configSchema.js +1 -1
- package/dist/DivSequenceRenderer/configSchema.js.map +1 -1
- package/dist/DivSequenceRenderer/index.d.ts +3 -2
- package/dist/DivSequenceRenderer/index.js +25 -5
- package/dist/DivSequenceRenderer/index.js.map +1 -1
- package/dist/GCContentAdapter/GCContentAdapter.d.ts +1 -7
- package/dist/GCContentAdapter/GCContentAdapter.js +75 -180
- package/dist/GCContentAdapter/GCContentAdapter.js.map +1 -1
- package/dist/GCContentAdapter/configSchema.js +3 -3
- package/dist/GCContentAdapter/configSchema.js.map +1 -1
- package/dist/GCContentAdapter/index.d.ts +1 -4
- package/dist/GCContentAdapter/index.js +15 -7
- package/dist/GCContentAdapter/index.js.map +1 -1
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +9 -2
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js +83 -172
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js.map +1 -1
- package/dist/IndexedFastaAdapter/configSchema.js +1 -1
- package/dist/IndexedFastaAdapter/configSchema.js.map +1 -1
- package/dist/IndexedFastaAdapter/index.d.ts +3 -1
- package/dist/IndexedFastaAdapter/index.js +38 -3
- package/dist/IndexedFastaAdapter/index.js.map +1 -1
- package/dist/LinearReferenceSequenceDisplay/configSchema.js +6 -3
- package/dist/LinearReferenceSequenceDisplay/configSchema.js.map +1 -1
- package/dist/LinearReferenceSequenceDisplay/index.d.ts +3 -2
- package/dist/LinearReferenceSequenceDisplay/index.js +16 -5
- package/dist/LinearReferenceSequenceDisplay/index.js.map +1 -1
- package/dist/LinearReferenceSequenceDisplay/model.d.ts +1 -1
- package/dist/LinearReferenceSequenceDisplay/model.js +29 -33
- package/dist/LinearReferenceSequenceDisplay/model.js.map +1 -1
- package/dist/{referenceSeqTrackConfig.d.ts → ReferenceSequenceTrack/configSchema.d.ts} +0 -0
- package/dist/{referenceSeqTrackConfig.js → ReferenceSequenceTrack/configSchema.js} +19 -30
- package/dist/ReferenceSequenceTrack/configSchema.js.map +1 -0
- package/dist/ReferenceSequenceTrack/index.d.ts +3 -0
- package/dist/ReferenceSequenceTrack/index.js +19 -0
- package/dist/ReferenceSequenceTrack/index.js.map +1 -0
- package/dist/SequenceSearchAdapter/SequenceSearchAdapter.d.ts +8 -0
- package/dist/SequenceSearchAdapter/SequenceSearchAdapter.js +84 -0
- package/dist/SequenceSearchAdapter/SequenceSearchAdapter.js.map +1 -0
- package/dist/SequenceSearchAdapter/configSchema.d.ts +2 -0
- package/dist/SequenceSearchAdapter/configSchema.js +28 -0
- package/dist/SequenceSearchAdapter/configSchema.js.map +1 -0
- package/dist/SequenceSearchAdapter/index.d.ts +3 -0
- package/dist/SequenceSearchAdapter/index.js +44 -0
- package/dist/SequenceSearchAdapter/index.js.map +1 -0
- package/dist/TwoBitAdapter/TwoBitAdapter.js +66 -174
- package/dist/TwoBitAdapter/TwoBitAdapter.js.map +1 -1
- package/dist/TwoBitAdapter/configSchema.js +1 -1
- package/dist/TwoBitAdapter/configSchema.js.map +1 -1
- package/dist/TwoBitAdapter/index.d.ts +3 -1
- package/dist/TwoBitAdapter/index.js +38 -3
- package/dist/TwoBitAdapter/index.js.map +1 -1
- package/dist/createExtensionPoints.d.ts +3 -0
- package/dist/createExtensionPoints.js +86 -0
- package/dist/createExtensionPoints.js.map +1 -0
- package/dist/index.js +27 -261
- package/dist/index.js.map +1 -1
- package/esm/BgzipFastaAdapter/BgzipFastaAdapter.d.ts +4 -4
- package/esm/BgzipFastaAdapter/BgzipFastaAdapter.js +5 -16
- package/esm/BgzipFastaAdapter/BgzipFastaAdapter.js.map +1 -1
- package/esm/BgzipFastaAdapter/index.d.ts +3 -1
- package/esm/BgzipFastaAdapter/index.js +15 -1
- package/esm/BgzipFastaAdapter/index.js.map +1 -1
- package/esm/ChromSizesAdapter/index.d.ts +3 -1
- package/esm/ChromSizesAdapter/index.js +15 -1
- package/esm/ChromSizesAdapter/index.js.map +1 -1
- package/esm/DivSequenceRenderer/index.d.ts +3 -2
- package/esm/DivSequenceRenderer/index.js +25 -2
- package/esm/DivSequenceRenderer/index.js.map +1 -1
- package/esm/GCContentAdapter/GCContentAdapter.d.ts +1 -7
- package/esm/GCContentAdapter/GCContentAdapter.js +7 -18
- package/esm/GCContentAdapter/GCContentAdapter.js.map +1 -1
- package/esm/GCContentAdapter/index.d.ts +1 -4
- package/esm/GCContentAdapter/index.js +11 -3
- package/esm/GCContentAdapter/index.js.map +1 -1
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +9 -2
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js +33 -28
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js.map +1 -1
- package/esm/IndexedFastaAdapter/index.d.ts +3 -1
- package/esm/IndexedFastaAdapter/index.js +15 -1
- package/esm/IndexedFastaAdapter/index.js.map +1 -1
- package/esm/LinearReferenceSequenceDisplay/configSchema.js +1 -1
- package/esm/LinearReferenceSequenceDisplay/configSchema.js.map +1 -1
- package/esm/LinearReferenceSequenceDisplay/index.d.ts +3 -2
- package/esm/LinearReferenceSequenceDisplay/index.js +16 -2
- package/esm/LinearReferenceSequenceDisplay/index.js.map +1 -1
- package/esm/LinearReferenceSequenceDisplay/model.d.ts +1 -1
- package/esm/{referenceSeqTrackConfig.d.ts → ReferenceSequenceTrack/configSchema.d.ts} +0 -0
- package/esm/{referenceSeqTrackConfig.js → ReferenceSequenceTrack/configSchema.js} +1 -1
- package/esm/ReferenceSequenceTrack/configSchema.js.map +1 -0
- package/esm/ReferenceSequenceTrack/index.d.ts +3 -0
- package/esm/ReferenceSequenceTrack/index.js +14 -0
- package/esm/ReferenceSequenceTrack/index.js.map +1 -0
- package/esm/SequenceSearchAdapter/SequenceSearchAdapter.d.ts +8 -0
- package/esm/SequenceSearchAdapter/SequenceSearchAdapter.js +81 -0
- package/esm/SequenceSearchAdapter/SequenceSearchAdapter.js.map +1 -0
- package/esm/SequenceSearchAdapter/configSchema.d.ts +2 -0
- package/esm/SequenceSearchAdapter/configSchema.js +26 -0
- package/esm/SequenceSearchAdapter/configSchema.js.map +1 -0
- package/esm/SequenceSearchAdapter/index.d.ts +3 -0
- package/esm/SequenceSearchAdapter/index.js +16 -0
- package/esm/SequenceSearchAdapter/index.js.map +1 -0
- package/esm/TwoBitAdapter/index.d.ts +3 -1
- package/esm/TwoBitAdapter/index.js +15 -1
- package/esm/TwoBitAdapter/index.js.map +1 -1
- package/esm/createExtensionPoints.d.ts +3 -0
- package/esm/createExtensionPoints.js +84 -0
- package/esm/createExtensionPoints.js.map +1 -0
- package/esm/index.js +19 -186
- package/esm/index.js.map +1 -1
- package/package.json +2 -3
- package/src/BgzipFastaAdapter/BgzipFastaAdapter.ts +5 -23
- package/src/BgzipFastaAdapter/index.ts +22 -1
- package/src/ChromSizesAdapter/index.ts +22 -1
- package/src/DivSequenceRenderer/index.ts +31 -2
- package/src/GCContentAdapter/GCContentAdapter.ts +15 -25
- package/src/GCContentAdapter/index.ts +17 -4
- package/src/IndexedFastaAdapter/IndexedFastaAdapter.ts +41 -38
- package/src/IndexedFastaAdapter/index.ts +22 -1
- package/src/LinearReferenceSequenceDisplay/configSchema.ts +1 -1
- package/src/LinearReferenceSequenceDisplay/index.ts +19 -2
- package/src/{referenceSeqTrackConfig.ts → ReferenceSequenceTrack/configSchema.ts} +0 -0
- package/src/ReferenceSequenceTrack/index.ts +21 -0
- package/src/SequenceSearchAdapter/SequenceSearchAdapter.ts +103 -0
- package/src/SequenceSearchAdapter/configSchema.ts +31 -0
- package/src/SequenceSearchAdapter/index.ts +22 -0
- package/src/TwoBitAdapter/index.ts +21 -1
- package/src/createExtensionPoints.ts +122 -0
- package/src/index.ts +20 -268
- package/dist/referenceSeqTrackConfig.js.map +0 -1
- package/esm/referenceSeqTrackConfig.js.map +0 -1
- package/src/declare.d.ts +0 -1
|
@@ -9,23 +9,20 @@ import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
|
9
9
|
import { SimpleFeature, Feature } from '@jbrowse/core/util'
|
|
10
10
|
import { AnyConfigurationModel } from '@jbrowse/core/configuration'
|
|
11
11
|
import AbortablePromiseCache from 'abortable-promise-cache'
|
|
12
|
-
import
|
|
12
|
+
import QuickLRU from '@jbrowse/core/util/QuickLRU'
|
|
13
13
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
14
14
|
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
protected fasta: IndexedFasta
|
|
16
|
+
type T = { refName: string; start: number; end: number; fasta: IndexedFasta }
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
export default class extends BaseSequenceAdapter {
|
|
19
|
+
protected setupP?: Promise<{ fasta: IndexedFasta }>
|
|
20
20
|
|
|
21
|
-
private seqCache = new AbortablePromiseCache({
|
|
22
|
-
cache: new
|
|
23
|
-
fill: async (
|
|
24
|
-
|
|
25
|
-
signal
|
|
26
|
-
) => {
|
|
27
|
-
const { refName, start, end } = args
|
|
28
|
-
return this.fasta.getSequence(refName, start, end, { ...args, signal })
|
|
21
|
+
private seqCache = new AbortablePromiseCache<T, string | undefined>({
|
|
22
|
+
cache: new QuickLRU({ maxSize: 200 }),
|
|
23
|
+
fill: async (args: T, signal?: AbortSignal) => {
|
|
24
|
+
const { refName, start, end, fasta } = args
|
|
25
|
+
return fasta.getSequence(refName, start, end, { ...args, signal })
|
|
29
26
|
},
|
|
30
27
|
})
|
|
31
28
|
|
|
@@ -35,22 +32,16 @@ export default class extends BaseSequenceAdapter {
|
|
|
35
32
|
pluginManager?: PluginManager,
|
|
36
33
|
) {
|
|
37
34
|
super(config, getSubAdapter, pluginManager)
|
|
38
|
-
const fastaLocation = this.getConf('fastaLocation')
|
|
39
|
-
const faiLocation = this.getConf('faiLocation')
|
|
40
|
-
const fastaOpts = {
|
|
41
|
-
fasta: openLocation(fastaLocation as FileLocation, this.pluginManager),
|
|
42
|
-
fai: openLocation(faiLocation as FileLocation, this.pluginManager),
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.fasta = new IndexedFasta(fastaOpts)
|
|
46
35
|
}
|
|
47
36
|
|
|
48
|
-
public getRefNames(opts?: BaseOptions) {
|
|
49
|
-
|
|
37
|
+
public async getRefNames(opts?: BaseOptions) {
|
|
38
|
+
const { fasta } = await this.setup()
|
|
39
|
+
return fasta.getSequenceNames(opts)
|
|
50
40
|
}
|
|
51
41
|
|
|
52
42
|
public async getRegions(opts?: BaseOptions) {
|
|
53
|
-
const
|
|
43
|
+
const { fasta } = await this.setup()
|
|
44
|
+
const seqSizes = await fasta.getSequenceSizes(opts)
|
|
54
45
|
return Object.keys(seqSizes).map(refName => ({
|
|
55
46
|
refName,
|
|
56
47
|
start: 0,
|
|
@@ -58,30 +49,40 @@ export default class extends BaseSequenceAdapter {
|
|
|
58
49
|
}))
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
public async
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
const loc = this.getConf('metadataLocation')
|
|
52
|
+
public async setupPre() {
|
|
53
|
+
const fastaLocation = this.getConf('fastaLocation') as FileLocation
|
|
54
|
+
const faiLocation = this.getConf('faiLocation') as FileLocation
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
return {
|
|
57
|
+
fasta: new IndexedFasta({
|
|
58
|
+
fasta: openLocation(fastaLocation, this.pluginManager),
|
|
59
|
+
fai: openLocation(faiLocation, this.pluginManager),
|
|
60
|
+
}),
|
|
69
61
|
}
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
public async getHeader() {
|
|
65
|
+
const loc = this.getConf('metadataLocation')
|
|
66
|
+
return loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml'
|
|
67
|
+
? null
|
|
68
|
+
: openLocation(loc).readFile('utf8')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public async setup() {
|
|
72
|
+
if (!this.setupP) {
|
|
73
|
+
this.setupP = this.setupPre().catch(e => {
|
|
74
|
+
this.setupP = undefined
|
|
75
75
|
throw e
|
|
76
76
|
})
|
|
77
|
-
|
|
78
|
-
return this.
|
|
77
|
+
}
|
|
78
|
+
return this.setupP
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
public getFeatures(region: NoAssemblyRegion, opts?: BaseOptions) {
|
|
82
82
|
const { refName, start, end } = region
|
|
83
83
|
return ObservableCreate<Feature>(async observer => {
|
|
84
|
-
const
|
|
84
|
+
const { fasta } = await this.setup()
|
|
85
|
+
const size = await fasta.getSequenceSize(refName, opts)
|
|
85
86
|
const regionEnd = size !== undefined ? Math.min(size, end) : end
|
|
86
87
|
const chunks = []
|
|
87
88
|
const chunkSize = 128000
|
|
@@ -94,7 +95,9 @@ export default class extends BaseSequenceAdapter {
|
|
|
94
95
|
start: chunkStart,
|
|
95
96
|
end: chunkStart + chunkSize,
|
|
96
97
|
}
|
|
97
|
-
chunks.push(
|
|
98
|
+
chunks.push(
|
|
99
|
+
this.seqCache.get(JSON.stringify(r), { ...r, fasta }, opts?.signal),
|
|
100
|
+
)
|
|
98
101
|
}
|
|
99
102
|
const seq = (await Promise.all(chunks))
|
|
100
103
|
.join('')
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
+
|
|
4
|
+
import configSchema from './configSchema'
|
|
5
|
+
|
|
6
|
+
export default (pluginManager: PluginManager) => {
|
|
7
|
+
pluginManager.addAdapterType(
|
|
8
|
+
() =>
|
|
9
|
+
new AdapterType({
|
|
10
|
+
name: 'IndexedFastaAdapter',
|
|
11
|
+
configSchema,
|
|
12
|
+
adapterMetadata: {
|
|
13
|
+
category: null,
|
|
14
|
+
hiddenFromGUI: true,
|
|
15
|
+
displayName: null,
|
|
16
|
+
description: null,
|
|
17
|
+
},
|
|
18
|
+
getAdapterClass: () =>
|
|
19
|
+
import('./IndexedFastaAdapter').then(r => r.default),
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
-
import {
|
|
2
|
+
import { default as divSequenceRendererConfigSchema } from '../DivSequenceRenderer/configSchema'
|
|
3
3
|
|
|
4
4
|
export const configSchema = ConfigurationSchema(
|
|
5
5
|
'LinearReferenceSequenceDisplay',
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import { BaseLinearDisplayComponent } from '@jbrowse/plugin-linear-genome-view'
|
|
3
|
+
|
|
4
|
+
import { configSchema } from './configSchema'
|
|
5
|
+
import { modelFactory } from './model'
|
|
6
|
+
|
|
7
|
+
export default (pluginManager: PluginManager) => {
|
|
8
|
+
pluginManager.addDisplayType(() => {
|
|
9
|
+
const stateModel = modelFactory(configSchema)
|
|
10
|
+
return {
|
|
11
|
+
name: 'LinearReferenceSequenceDisplay',
|
|
12
|
+
configSchema,
|
|
13
|
+
stateModel,
|
|
14
|
+
trackType: 'ReferenceSequenceTrack',
|
|
15
|
+
viewType: 'LinearGenomeView',
|
|
16
|
+
ReactComponent: BaseLinearDisplayComponent,
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
|
|
3
|
+
import TrackType from '@jbrowse/core/pluggableElementTypes/TrackType'
|
|
4
|
+
import { createBaseTrackModel } from '@jbrowse/core/pluggableElementTypes/models'
|
|
5
|
+
import { createReferenceSeqTrackConfig } from './configSchema'
|
|
6
|
+
|
|
7
|
+
export default (pluginManager: PluginManager) => {
|
|
8
|
+
pluginManager.addTrackType(() => {
|
|
9
|
+
const configSchema = createReferenceSeqTrackConfig(pluginManager)
|
|
10
|
+
|
|
11
|
+
return new TrackType({
|
|
12
|
+
name: 'ReferenceSequenceTrack',
|
|
13
|
+
configSchema,
|
|
14
|
+
stateModel: createBaseTrackModel(
|
|
15
|
+
pluginManager,
|
|
16
|
+
'ReferenceSequenceTrack',
|
|
17
|
+
configSchema,
|
|
18
|
+
),
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseFeatureDataAdapter,
|
|
3
|
+
BaseOptions,
|
|
4
|
+
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
+
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
6
|
+
import {
|
|
7
|
+
SimpleFeature,
|
|
8
|
+
Feature,
|
|
9
|
+
Region,
|
|
10
|
+
revcom,
|
|
11
|
+
doesIntersect2,
|
|
12
|
+
} from '@jbrowse/core/util'
|
|
13
|
+
import { toArray } from 'rxjs/operators'
|
|
14
|
+
|
|
15
|
+
export default class extends BaseFeatureDataAdapter {
|
|
16
|
+
public async configure() {
|
|
17
|
+
const adapter = await this.getSubAdapter?.(this.getConf('sequenceAdapter'))
|
|
18
|
+
if (!adapter) {
|
|
19
|
+
throw new Error('Error getting subadapter')
|
|
20
|
+
}
|
|
21
|
+
return adapter.dataAdapter as BaseFeatureDataAdapter
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async getRefNames() {
|
|
25
|
+
const adapter = await this.configure()
|
|
26
|
+
return adapter.getRefNames()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public getFeatures(query: Region, opts: BaseOptions) {
|
|
30
|
+
return ObservableCreate<Feature>(async observer => {
|
|
31
|
+
const sequenceAdapter = await this.configure()
|
|
32
|
+
const hw = 1000
|
|
33
|
+
let { start: queryStart, end: queryEnd } = query
|
|
34
|
+
queryStart = Math.max(0, queryStart - hw)
|
|
35
|
+
queryEnd += hw
|
|
36
|
+
|
|
37
|
+
if (queryEnd < 0 || queryStart > queryEnd) {
|
|
38
|
+
observer.complete()
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ret = sequenceAdapter.getFeatures(
|
|
43
|
+
{
|
|
44
|
+
...query,
|
|
45
|
+
start: queryStart,
|
|
46
|
+
end: queryEnd,
|
|
47
|
+
},
|
|
48
|
+
opts,
|
|
49
|
+
)
|
|
50
|
+
const feats = await ret.pipe(toArray()).toPromise()
|
|
51
|
+
const residues: string = feats[0]?.get('seq') || ''
|
|
52
|
+
const search = this.getConf('search')
|
|
53
|
+
const searchFoward = this.getConf('searchForward')
|
|
54
|
+
const searchReverse = this.getConf('searchReverse')
|
|
55
|
+
const caseInsensitive = this.getConf('caseInsensitive')
|
|
56
|
+
const re = new RegExp(search, 'g' + (caseInsensitive ? 'i' : ''))
|
|
57
|
+
|
|
58
|
+
if (search) {
|
|
59
|
+
if (searchFoward) {
|
|
60
|
+
const matches = residues.matchAll(re)
|
|
61
|
+
for (const match of matches) {
|
|
62
|
+
const s = queryStart + (match.index || 0)
|
|
63
|
+
|
|
64
|
+
if (doesIntersect2(s, s + search.length, query.start, query.end)) {
|
|
65
|
+
observer.next(
|
|
66
|
+
new SimpleFeature({
|
|
67
|
+
uniqueId: `${this.id}-match-${s}-p`,
|
|
68
|
+
refName: query.refName,
|
|
69
|
+
start: s,
|
|
70
|
+
end: s + match[0].length,
|
|
71
|
+
name: match[0],
|
|
72
|
+
strand: 1,
|
|
73
|
+
}),
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (searchReverse) {
|
|
79
|
+
const matches = revcom(residues).matchAll(re)
|
|
80
|
+
for (const match of matches) {
|
|
81
|
+
const s = queryEnd - (match.index || 0)
|
|
82
|
+
if (doesIntersect2(s, s + search.length, query.start, query.end)) {
|
|
83
|
+
observer.next(
|
|
84
|
+
new SimpleFeature({
|
|
85
|
+
uniqueId: `${this.id}-match-${s}-n`,
|
|
86
|
+
refName: query.refName,
|
|
87
|
+
start: s - match[0].length,
|
|
88
|
+
name: match[0],
|
|
89
|
+
end: s,
|
|
90
|
+
strand: -1,
|
|
91
|
+
}),
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
observer.complete()
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public freeResources() {}
|
|
103
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
+
|
|
3
|
+
const configSchema = ConfigurationSchema(
|
|
4
|
+
'SequenceSearchAdapter',
|
|
5
|
+
{
|
|
6
|
+
search: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
defaultValue: '',
|
|
9
|
+
description: 'Search string or regex to search for',
|
|
10
|
+
},
|
|
11
|
+
sequenceAdapter: {
|
|
12
|
+
type: 'frozen',
|
|
13
|
+
defaultValue: null,
|
|
14
|
+
},
|
|
15
|
+
searchForward: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
defaultValue: true,
|
|
18
|
+
},
|
|
19
|
+
searchReverse: {
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
defaultValue: true,
|
|
22
|
+
},
|
|
23
|
+
caseInsensitive: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
defaultValue: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{ explicitlyTyped: true },
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
export default configSchema
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
+
|
|
4
|
+
import configSchema from './configSchema'
|
|
5
|
+
|
|
6
|
+
export default (pluginManager: PluginManager) => {
|
|
7
|
+
pluginManager.addAdapterType(
|
|
8
|
+
() =>
|
|
9
|
+
new AdapterType({
|
|
10
|
+
name: 'SequenceSearchAdapter',
|
|
11
|
+
adapterMetadata: {
|
|
12
|
+
category: null,
|
|
13
|
+
hiddenFromGUI: true,
|
|
14
|
+
displayName: null,
|
|
15
|
+
description: null,
|
|
16
|
+
},
|
|
17
|
+
configSchema,
|
|
18
|
+
getAdapterClass: () =>
|
|
19
|
+
import('./SequenceSearchAdapter').then(r => r.default),
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
+
|
|
4
|
+
import configSchema from './configSchema'
|
|
5
|
+
|
|
6
|
+
export default (pluginManager: PluginManager) => {
|
|
7
|
+
pluginManager.addAdapterType(
|
|
8
|
+
() =>
|
|
9
|
+
new AdapterType({
|
|
10
|
+
name: 'TwoBitAdapter',
|
|
11
|
+
configSchema,
|
|
12
|
+
adapterMetadata: {
|
|
13
|
+
category: null,
|
|
14
|
+
hiddenFromGUI: true,
|
|
15
|
+
displayName: null,
|
|
16
|
+
description: null,
|
|
17
|
+
},
|
|
18
|
+
getAdapterClass: () => import('./TwoBitAdapter').then(r => r.default),
|
|
19
|
+
}),
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import { FileLocation } from '@jbrowse/core/util/types'
|
|
3
|
+
import {
|
|
4
|
+
makeIndex,
|
|
5
|
+
getFileName,
|
|
6
|
+
AdapterGuesser,
|
|
7
|
+
TrackTypeGuesser,
|
|
8
|
+
} from '@jbrowse/core/util/tracks'
|
|
9
|
+
|
|
10
|
+
export default (pluginManager: PluginManager) => {
|
|
11
|
+
pluginManager.addToExtensionPoint(
|
|
12
|
+
'Core-guessAdapterForLocation',
|
|
13
|
+
(adapterGuesser: AdapterGuesser) => {
|
|
14
|
+
return (
|
|
15
|
+
file: FileLocation,
|
|
16
|
+
index?: FileLocation,
|
|
17
|
+
adapterHint?: string,
|
|
18
|
+
) => {
|
|
19
|
+
const regexGuess = /\.2bit$/i
|
|
20
|
+
const adapterName = 'TwoBitAdapter'
|
|
21
|
+
const fileName = getFileName(file)
|
|
22
|
+
const obj = {
|
|
23
|
+
type: adapterName,
|
|
24
|
+
twoBitLocation: file,
|
|
25
|
+
}
|
|
26
|
+
if (regexGuess.test(fileName) && !adapterHint) {
|
|
27
|
+
return obj
|
|
28
|
+
} else if (adapterHint === adapterName) {
|
|
29
|
+
return obj
|
|
30
|
+
}
|
|
31
|
+
return adapterGuesser(file, index, adapterHint)
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
pluginManager.addToExtensionPoint(
|
|
36
|
+
'Core-guessTrackTypeForLocation',
|
|
37
|
+
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
38
|
+
return (adapterName: string) => {
|
|
39
|
+
if (adapterName === 'TwoBitAdapter') {
|
|
40
|
+
return 'ReferenceSequenceTrack'
|
|
41
|
+
}
|
|
42
|
+
return trackTypeGuesser(adapterName)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
pluginManager.addToExtensionPoint(
|
|
48
|
+
'Core-guessAdapterForLocation',
|
|
49
|
+
(adapterGuesser: AdapterGuesser) => {
|
|
50
|
+
return (
|
|
51
|
+
file: FileLocation,
|
|
52
|
+
index?: FileLocation,
|
|
53
|
+
adapterHint?: string,
|
|
54
|
+
) => {
|
|
55
|
+
const regexGuess = /\.(fa|fasta|fas|fna|mfa)$/i
|
|
56
|
+
const adapterName = 'IndexedFastaAdapter'
|
|
57
|
+
const fileName = getFileName(file)
|
|
58
|
+
const obj = {
|
|
59
|
+
type: adapterName,
|
|
60
|
+
fastaLocation: file,
|
|
61
|
+
faiLocation: index || makeIndex(file, '.fai'),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (regexGuess.test(fileName) && !adapterHint) {
|
|
65
|
+
return obj
|
|
66
|
+
} else if (adapterHint === adapterName) {
|
|
67
|
+
return obj
|
|
68
|
+
}
|
|
69
|
+
return adapterGuesser(file, index, adapterHint)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
pluginManager.addToExtensionPoint(
|
|
74
|
+
'Core-guessTrackTypeForLocation',
|
|
75
|
+
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
76
|
+
return (adapterName: string) => {
|
|
77
|
+
if (adapterName === 'IndexedFastaAdapter') {
|
|
78
|
+
return 'ReferenceSequenceTrack'
|
|
79
|
+
}
|
|
80
|
+
return trackTypeGuesser(adapterName)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
pluginManager.addToExtensionPoint(
|
|
86
|
+
'Core-guessAdapterForLocation',
|
|
87
|
+
(adapterGuesser: AdapterGuesser) => {
|
|
88
|
+
return (
|
|
89
|
+
file: FileLocation,
|
|
90
|
+
index?: FileLocation,
|
|
91
|
+
adapterHint?: string,
|
|
92
|
+
) => {
|
|
93
|
+
const regexGuess = /\.(fa|fasta|fas|fna|mfa)\.b?gz$/i
|
|
94
|
+
const adapterName = 'BgzipFastaAdapter'
|
|
95
|
+
const fileName = getFileName(file)
|
|
96
|
+
const obj = {
|
|
97
|
+
type: adapterName,
|
|
98
|
+
faiLocation: makeIndex(file, '.fai'),
|
|
99
|
+
gziLocation: makeIndex(file, '.gzi'),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (regexGuess.test(fileName) && !adapterHint) {
|
|
103
|
+
return obj
|
|
104
|
+
} else if (adapterHint === adapterName) {
|
|
105
|
+
return obj
|
|
106
|
+
}
|
|
107
|
+
return adapterGuesser(file, index, adapterHint)
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
)
|
|
111
|
+
pluginManager.addToExtensionPoint(
|
|
112
|
+
'Core-guessTrackTypeForLocation',
|
|
113
|
+
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
114
|
+
return (adapterName: string) => {
|
|
115
|
+
if (adapterName === 'BgzipFastaAdapter') {
|
|
116
|
+
return 'ReferenceSequenceTrack'
|
|
117
|
+
}
|
|
118
|
+
return trackTypeGuesser(adapterName)
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
)
|
|
122
|
+
}
|