@jbrowse/plugin-variants 2.3.2 → 2.3.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/VcfTabixAdapter/VcfTabixAdapter.d.ts +2 -19
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +0 -34
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js.map +1 -1
- package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +2 -19
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js +0 -34
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js.map +1 -1
- package/package.json +3 -3
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.tsx +42 -0
- package/src/VariantFeatureWidget/__snapshots__/{VariantFeatureWidget.test.js.snap → VariantFeatureWidget.test.tsx.snap} +1 -1
- package/src/VcfAdapter/VcfAdapter.test.ts +4 -3
- package/src/VcfTabixAdapter/VcfTabixAdapter.test.ts +9 -10
- package/src/VcfTabixAdapter/VcfTabixAdapter.ts +2 -50
- package/src/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
- package/src/{index.test.js → index.test.ts} +0 -1
- package/src/LinearVariantDisplay/configSchema.test.js +0 -55
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.js +0 -41
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { NoAssemblyRegion
|
|
3
|
-
import { Feature } from '@jbrowse/core/util
|
|
2
|
+
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
+
import { Feature } from '@jbrowse/core/util';
|
|
4
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
5
5
|
import VcfParser from '@gmod/vcf';
|
|
6
|
-
import { GenericFilehandle } from 'generic-filehandle';
|
|
7
6
|
export default class extends BaseFeatureDataAdapter {
|
|
8
7
|
private configured?;
|
|
9
8
|
private configurePre;
|
|
10
9
|
protected configure(): Promise<{
|
|
11
|
-
filehandle: GenericFilehandle;
|
|
12
10
|
vcf: TabixIndexedFile;
|
|
13
11
|
parser: VcfParser;
|
|
14
12
|
}>;
|
|
@@ -16,20 +14,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
16
14
|
getHeader(): Promise<string>;
|
|
17
15
|
getMetadata(): Promise<any>;
|
|
18
16
|
getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the data source has data for the given reference sequence,
|
|
21
|
-
* and then gets the features in the region if it does
|
|
22
|
-
*
|
|
23
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
24
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
25
|
-
* implement a more efficient custom version of this method.
|
|
26
|
-
*
|
|
27
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
28
|
-
* of a VCF
|
|
29
|
-
* @param regions - Regions
|
|
30
|
-
* @param opts - Feature adapter options
|
|
31
|
-
* @returns Observable of Feature objects in the regions
|
|
32
|
-
*/
|
|
33
|
-
getFeaturesInMultipleRegions(regions: Region[], opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
34
17
|
freeResources(): void;
|
|
35
18
|
}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
7
7
|
const io_1 = require("@jbrowse/core/util/io");
|
|
8
|
-
const util_1 = require("@jbrowse/core/util");
|
|
9
8
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
10
9
|
const tabix_1 = require("@gmod/tabix");
|
|
11
10
|
const vcf_1 = __importDefault(require("@gmod/vcf"));
|
|
@@ -28,7 +27,6 @@ class default_1 extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
28
27
|
});
|
|
29
28
|
const header = await vcf.getHeader();
|
|
30
29
|
return {
|
|
31
|
-
filehandle,
|
|
32
30
|
vcf,
|
|
33
31
|
parser: new vcf_1.default({ header }),
|
|
34
32
|
};
|
|
@@ -71,38 +69,6 @@ class default_1 extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
71
69
|
observer.complete();
|
|
72
70
|
}, opts.signal);
|
|
73
71
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Checks if the data source has data for the given reference sequence,
|
|
76
|
-
* and then gets the features in the region if it does
|
|
77
|
-
*
|
|
78
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
79
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
80
|
-
* implement a more efficient custom version of this method.
|
|
81
|
-
*
|
|
82
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
83
|
-
* of a VCF
|
|
84
|
-
* @param regions - Regions
|
|
85
|
-
* @param opts - Feature adapter options
|
|
86
|
-
* @returns Observable of Feature objects in the regions
|
|
87
|
-
*/
|
|
88
|
-
getFeaturesInMultipleRegions(regions, opts = {}) {
|
|
89
|
-
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
90
|
-
const { vcf } = await this.configure();
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
const bytes = await (0, util_1.bytesForRegions)(regions, vcf.index);
|
|
93
|
-
const { filehandle } = await this.configure();
|
|
94
|
-
const stat = await filehandle.stat();
|
|
95
|
-
let pct = Math.round((bytes / stat.size) * 100);
|
|
96
|
-
if (pct > 100) {
|
|
97
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
98
|
-
pct = 100;
|
|
99
|
-
}
|
|
100
|
-
if (pct > 60) {
|
|
101
|
-
console.warn(`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`);
|
|
102
|
-
}
|
|
103
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
72
|
freeResources( /* { region } */) { }
|
|
107
73
|
}
|
|
108
74
|
exports.default = default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":";;;;;AAAA,yEAGgD;
|
|
1
|
+
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":";;;;;AAAA,yEAGgD;AAEhD,8CAAoD;AACpD,kDAA0D;AAE1D,uCAA8C;AAC9C,oDAAiC;AAEjC,QAAQ;AACR,+DAAsC;AAEtC,eAAqB,SAAQ,oCAAsB;IAMzC,KAAK,CAAC,YAAY;QACxB,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAA;QAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAA;QAEtD,MAAM,UAAU,GAAG,IAAA,iBAAY,EAAC,aAA6B,EAAE,EAAE,CAAC,CAAA;QAClE,MAAM,KAAK,GAAG,SAAS,KAAK,KAAK,CAAA;QACjC,MAAM,GAAG,GAAG,IAAI,wBAAgB,CAAC;YAC/B,UAAU;YACV,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,IAAA,iBAAY,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;YAC7D,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,iBAAY,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;YAC9D,cAAc,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE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AI,CAAC,SAAS,EAAE,CAAA;YAC9C,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;gBACtC,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;oBACjC,QAAQ,CAAC,IAAI,CACX,IAAI,oBAAU,CAAC;wBACb,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC/B,MAAM;wBACN,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,UAAU,EAAE;qBACnC,CAAC,CACH,CAAA;gBACH,CAAC;gBACD,GAAG,IAAI;aACR,CAAC,CAAA;YACF,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;IAEM,aAAa,EAAC,gBAAgB,IAAS,CAAC;CAChD;AA3ED,4BA2EC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { NoAssemblyRegion
|
|
3
|
-
import { Feature } from '@jbrowse/core/util
|
|
2
|
+
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
+
import { Feature } from '@jbrowse/core/util';
|
|
4
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
5
5
|
import VcfParser from '@gmod/vcf';
|
|
6
|
-
import { GenericFilehandle } from 'generic-filehandle';
|
|
7
6
|
export default class extends BaseFeatureDataAdapter {
|
|
8
7
|
private configured?;
|
|
9
8
|
private configurePre;
|
|
10
9
|
protected configure(): Promise<{
|
|
11
|
-
filehandle: GenericFilehandle;
|
|
12
10
|
vcf: TabixIndexedFile;
|
|
13
11
|
parser: VcfParser;
|
|
14
12
|
}>;
|
|
@@ -16,20 +14,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
16
14
|
getHeader(): Promise<string>;
|
|
17
15
|
getMetadata(): Promise<any>;
|
|
18
16
|
getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the data source has data for the given reference sequence,
|
|
21
|
-
* and then gets the features in the region if it does
|
|
22
|
-
*
|
|
23
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
24
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
25
|
-
* implement a more efficient custom version of this method.
|
|
26
|
-
*
|
|
27
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
28
|
-
* of a VCF
|
|
29
|
-
* @param regions - Regions
|
|
30
|
-
* @param opts - Feature adapter options
|
|
31
|
-
* @returns Observable of Feature objects in the regions
|
|
32
|
-
*/
|
|
33
|
-
getFeaturesInMultipleRegions(regions: Region[], opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
34
17
|
freeResources(): void;
|
|
35
18
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
2
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
|
-
import { bytesForRegions } from '@jbrowse/core/util';
|
|
4
3
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
5
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
6
5
|
import VcfParser from '@gmod/vcf';
|
|
@@ -23,7 +22,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
23
22
|
});
|
|
24
23
|
const header = await vcf.getHeader();
|
|
25
24
|
return {
|
|
26
|
-
filehandle,
|
|
27
25
|
vcf,
|
|
28
26
|
parser: new VcfParser({ header }),
|
|
29
27
|
};
|
|
@@ -66,38 +64,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
66
64
|
observer.complete();
|
|
67
65
|
}, opts.signal);
|
|
68
66
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if the data source has data for the given reference sequence,
|
|
71
|
-
* and then gets the features in the region if it does
|
|
72
|
-
*
|
|
73
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
74
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
75
|
-
* implement a more efficient custom version of this method.
|
|
76
|
-
*
|
|
77
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
78
|
-
* of a VCF
|
|
79
|
-
* @param regions - Regions
|
|
80
|
-
* @param opts - Feature adapter options
|
|
81
|
-
* @returns Observable of Feature objects in the regions
|
|
82
|
-
*/
|
|
83
|
-
getFeaturesInMultipleRegions(regions, opts = {}) {
|
|
84
|
-
return ObservableCreate(async (observer) => {
|
|
85
|
-
const { vcf } = await this.configure();
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
const bytes = await bytesForRegions(regions, vcf.index);
|
|
88
|
-
const { filehandle } = await this.configure();
|
|
89
|
-
const stat = await filehandle.stat();
|
|
90
|
-
let pct = Math.round((bytes / stat.size) * 100);
|
|
91
|
-
if (pct > 100) {
|
|
92
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
93
|
-
pct = 100;
|
|
94
|
-
}
|
|
95
|
-
if (pct > 60) {
|
|
96
|
-
console.warn(`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`);
|
|
97
|
-
}
|
|
98
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
67
|
freeResources( /* { region } */) { }
|
|
102
68
|
}
|
|
103
69
|
//# sourceMappingURL=VcfTabixAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAEvB,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.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,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;oBACjC,QAAQ,CAAC,IAAI,CACX,IAAI,UAAU,CAAC;wBACb,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC/B,MAAM;wBACN,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,UAAU,EAAE;qBACnC,CAAC,CACH,CAAA;gBACH,CAAC;gBACD,GAAG,IAAI;aACR,CAAC,CAAA;YACF,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;IAEM,aAAa,EAAC,gBAAgB,IAAS,CAAC;CAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"mobx-react": "^7.0.0",
|
|
56
56
|
"mobx-state-tree": "^5.0.0",
|
|
57
57
|
"react": ">=16.8.0",
|
|
58
|
-
"rxjs": "^
|
|
58
|
+
"rxjs": "^7.0.0",
|
|
59
59
|
"tss-react": "^4.0.0"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"distModule": "esm/index.js",
|
|
65
65
|
"srcModule": "src/index.ts",
|
|
66
66
|
"module": "esm/index.js",
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "283e0387ccd5acc9f092cf00804d1fcac212e68d"
|
|
68
68
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { types } from 'mobx-state-tree'
|
|
4
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
5
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
6
|
+
|
|
7
|
+
// locals
|
|
8
|
+
import { stateModelFactory } from '.'
|
|
9
|
+
import VariantFeatureDetails from './VariantFeatureWidget'
|
|
10
|
+
|
|
11
|
+
test('renders with just the required model elements', () => {
|
|
12
|
+
const pluginManager = new PluginManager([])
|
|
13
|
+
const Session = types.model({
|
|
14
|
+
rpcManager: types.optional(types.frozen(), {}),
|
|
15
|
+
configuration: ConfigurationSchema('test', {}),
|
|
16
|
+
widget: stateModelFactory(pluginManager),
|
|
17
|
+
})
|
|
18
|
+
const model = Session.create(
|
|
19
|
+
{
|
|
20
|
+
widget: {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
type: 'VariantFeatureWidget',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{ pluginManager },
|
|
26
|
+
)
|
|
27
|
+
model.widget.setFeatureData({
|
|
28
|
+
refName: 'ctgA',
|
|
29
|
+
start: 176,
|
|
30
|
+
end: 177,
|
|
31
|
+
name: 'rs123',
|
|
32
|
+
REF: 'A',
|
|
33
|
+
ALT: ['<TRA>'],
|
|
34
|
+
QUAL: 10.4,
|
|
35
|
+
INFO: {
|
|
36
|
+
MQ: 5,
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const { container } = render(<VariantFeatureDetails model={model.widget} />)
|
|
41
|
+
expect(container.firstChild).toMatchSnapshot()
|
|
42
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`renders with just the required model elements 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 css-1ps6pg7-MuiPaper-root"
|
|
6
6
|
data-testid="variant-side-drawer"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toArray } from 'rxjs/operators'
|
|
2
|
+
import { firstValueFrom } from 'rxjs'
|
|
2
3
|
import Adapter from './VcfAdapter'
|
|
3
4
|
import configSchema from './configSchema'
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ test('adapter can fetch variants from volvox.vcf', async () => {
|
|
|
12
13
|
}),
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const feat = adapter.getFeatures({
|
|
16
17
|
assemblyName: 'volvox',
|
|
17
18
|
refName: 'ctgA',
|
|
18
19
|
start: 0,
|
|
@@ -22,6 +23,6 @@ test('adapter can fetch variants from volvox.vcf', async () => {
|
|
|
22
23
|
const names = await adapter.getRefNames()
|
|
23
24
|
expect(names).toMatchSnapshot()
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
-
expect(
|
|
26
|
+
const featArray = await firstValueFrom(feat.pipe(toArray()))
|
|
27
|
+
expect(featArray.slice(0, 5)).toMatchSnapshot()
|
|
27
28
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toArray } from 'rxjs/operators'
|
|
2
|
+
import { firstValueFrom } from 'rxjs'
|
|
2
3
|
import Adapter from './VcfTabixAdapter'
|
|
3
4
|
import configSchema from './configSchema'
|
|
4
5
|
|
|
@@ -46,25 +47,23 @@ test('adapter can fetch variants from volvox.vcf.gz', async () => {
|
|
|
46
47
|
expect(names).toEqual(csiNames)
|
|
47
48
|
expect(names).toMatchSnapshot()
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
+
const feat = adapter.getFeatures({
|
|
50
51
|
refName: 'ctgA',
|
|
51
52
|
start: 0,
|
|
52
53
|
end: 20000,
|
|
53
54
|
})
|
|
54
55
|
|
|
55
|
-
const
|
|
56
|
-
const csiFeaturesArray = await csiFeatures.pipe(toArray())
|
|
57
|
-
expect(
|
|
58
|
-
expect(csiFeaturesArray.slice(0, 5)).toEqual(
|
|
56
|
+
const featArray = await firstValueFrom(feat.pipe(toArray()))
|
|
57
|
+
const csiFeaturesArray = await firstValueFrom(csiFeatures.pipe(toArray()))
|
|
58
|
+
expect(featArray.slice(0, 5)).toMatchSnapshot()
|
|
59
|
+
expect(csiFeaturesArray.slice(0, 5)).toEqual(featArray.slice(0, 5))
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const featNonExist = adapter.getFeatures({
|
|
61
62
|
refName: 'ctgC',
|
|
62
63
|
start: 0,
|
|
63
64
|
end: 20000,
|
|
64
65
|
})
|
|
65
66
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
.toPromise()
|
|
69
|
-
expect(featuresArrayNonExist).toEqual([])
|
|
67
|
+
const featArrayNonExist = await firstValueFrom(featNonExist.pipe(toArray()))
|
|
68
|
+
expect(featArrayNonExist).toEqual([])
|
|
70
69
|
})
|
|
@@ -2,26 +2,18 @@ import {
|
|
|
2
2
|
BaseFeatureDataAdapter,
|
|
3
3
|
BaseOptions,
|
|
4
4
|
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import {
|
|
6
|
-
FileLocation,
|
|
7
|
-
NoAssemblyRegion,
|
|
8
|
-
Region,
|
|
9
|
-
} from '@jbrowse/core/util/types'
|
|
5
|
+
import { FileLocation, NoAssemblyRegion } from '@jbrowse/core/util/types'
|
|
10
6
|
import { openLocation } from '@jbrowse/core/util/io'
|
|
11
|
-
import { bytesForRegions } from '@jbrowse/core/util'
|
|
12
7
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
13
|
-
import { Feature } from '@jbrowse/core/util
|
|
8
|
+
import { Feature } from '@jbrowse/core/util'
|
|
14
9
|
import { TabixIndexedFile } from '@gmod/tabix'
|
|
15
10
|
import VcfParser from '@gmod/vcf'
|
|
16
|
-
import { Observer } from 'rxjs'
|
|
17
|
-
import { GenericFilehandle } from 'generic-filehandle'
|
|
18
11
|
|
|
19
12
|
// local
|
|
20
13
|
import VcfFeature from '../VcfFeature'
|
|
21
14
|
|
|
22
15
|
export default class extends BaseFeatureDataAdapter {
|
|
23
16
|
private configured?: Promise<{
|
|
24
|
-
filehandle: GenericFilehandle
|
|
25
17
|
vcf: TabixIndexedFile
|
|
26
18
|
parser: VcfParser
|
|
27
19
|
}>
|
|
@@ -44,7 +36,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
44
36
|
|
|
45
37
|
const header = await vcf.getHeader()
|
|
46
38
|
return {
|
|
47
|
-
filehandle,
|
|
48
39
|
vcf,
|
|
49
40
|
parser: new VcfParser({ header }),
|
|
50
41
|
}
|
|
@@ -95,44 +86,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
95
86
|
}, opts.signal)
|
|
96
87
|
}
|
|
97
88
|
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the data source has data for the given reference sequence,
|
|
100
|
-
* and then gets the features in the region if it does
|
|
101
|
-
*
|
|
102
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
103
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
104
|
-
* implement a more efficient custom version of this method.
|
|
105
|
-
*
|
|
106
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
107
|
-
* of a VCF
|
|
108
|
-
* @param regions - Regions
|
|
109
|
-
* @param opts - Feature adapter options
|
|
110
|
-
* @returns Observable of Feature objects in the regions
|
|
111
|
-
*/
|
|
112
|
-
public getFeaturesInMultipleRegions(
|
|
113
|
-
regions: Region[],
|
|
114
|
-
opts: BaseOptions = {},
|
|
115
|
-
) {
|
|
116
|
-
return ObservableCreate<Feature>(async (observer: Observer<Feature>) => {
|
|
117
|
-
const { vcf } = await this.configure()
|
|
118
|
-
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
const bytes = await bytesForRegions(regions, vcf.index)
|
|
121
|
-
const { filehandle } = await this.configure()
|
|
122
|
-
const stat = await filehandle.stat()
|
|
123
|
-
let pct = Math.round((bytes / stat.size) * 100)
|
|
124
|
-
if (pct > 100) {
|
|
125
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
126
|
-
pct = 100
|
|
127
|
-
}
|
|
128
|
-
if (pct > 60) {
|
|
129
|
-
console.warn(
|
|
130
|
-
`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`,
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer)
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
89
|
public freeResources(/* { region } */): void {}
|
|
138
90
|
}
|
|
File without changes
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import BoxRendererType from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType'
|
|
2
|
-
import Plugin from '@jbrowse/core/Plugin'
|
|
3
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
4
|
-
import PileupRenderer from '@jbrowse/plugin-alignments/src/PileupRenderer'
|
|
5
|
-
import {
|
|
6
|
-
configSchema as svgFeatureRendererConfigSchema,
|
|
7
|
-
ReactComponent as SvgFeatureRendererReactComponent,
|
|
8
|
-
} from '@jbrowse/plugin-svg/src/SvgFeatureRenderer'
|
|
9
|
-
import configSchemaFactory from './configSchema'
|
|
10
|
-
|
|
11
|
-
// mock warnings to avoid unnecessary outputs
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
console.warn.mockRestore()
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
class PileupRendererPlugin extends Plugin {
|
|
21
|
-
install(pluginManager) {
|
|
22
|
-
PileupRenderer(pluginManager)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
class SvgFeatureRendererPlugin extends Plugin {
|
|
27
|
-
install(pluginManager) {
|
|
28
|
-
pluginManager.addRendererType(
|
|
29
|
-
() =>
|
|
30
|
-
new BoxRendererType({
|
|
31
|
-
name: 'SvgFeatureRenderer',
|
|
32
|
-
ReactComponent: SvgFeatureRendererReactComponent,
|
|
33
|
-
configSchema: svgFeatureRendererConfigSchema,
|
|
34
|
-
pluginManager,
|
|
35
|
-
}),
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
test('has a viewType attr', () => {
|
|
41
|
-
const configSchema = configSchemaFactory(
|
|
42
|
-
new PluginManager([
|
|
43
|
-
new PileupRendererPlugin(),
|
|
44
|
-
new SvgFeatureRendererPlugin(),
|
|
45
|
-
])
|
|
46
|
-
.createPluggableElements()
|
|
47
|
-
.configure(),
|
|
48
|
-
)
|
|
49
|
-
const config = configSchema.create({
|
|
50
|
-
type: 'LinearVariantDisplay',
|
|
51
|
-
displayId: 'displayId0',
|
|
52
|
-
name: 'Zonker Display',
|
|
53
|
-
})
|
|
54
|
-
expect(config.type).toEqual('LinearVariantDisplay')
|
|
55
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react'
|
|
3
|
-
import { types } from 'mobx-state-tree'
|
|
4
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
5
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
6
|
-
import { stateModelFactory } from '.'
|
|
7
|
-
|
|
8
|
-
import VariantFeatureDetails from './VariantFeatureWidget'
|
|
9
|
-
|
|
10
|
-
describe('VariantTrack widget', () => {
|
|
11
|
-
it('renders with just the required model elements', () => {
|
|
12
|
-
console.warn = jest.fn()
|
|
13
|
-
const pluginManager = new PluginManager([])
|
|
14
|
-
const Session = types.model({
|
|
15
|
-
rpcManager: types.optional(types.frozen(), {}),
|
|
16
|
-
configuration: ConfigurationSchema('test', {}),
|
|
17
|
-
widget: stateModelFactory(pluginManager),
|
|
18
|
-
})
|
|
19
|
-
const model = Session.create(
|
|
20
|
-
{
|
|
21
|
-
widget: { type: 'VariantFeatureWidget' },
|
|
22
|
-
},
|
|
23
|
-
{ pluginManager },
|
|
24
|
-
)
|
|
25
|
-
model.widget.setFeatureData({
|
|
26
|
-
refName: 'ctgA',
|
|
27
|
-
start: 176,
|
|
28
|
-
end: 177,
|
|
29
|
-
name: 'rs123',
|
|
30
|
-
REF: 'A',
|
|
31
|
-
ALT: ['<TRA>'],
|
|
32
|
-
QUAL: 10.4,
|
|
33
|
-
INFO: {
|
|
34
|
-
MQ: 5,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const { container } = render(<VariantFeatureDetails model={model.widget} />)
|
|
39
|
-
expect(container.firstChild).toMatchSnapshot()
|
|
40
|
-
})
|
|
41
|
-
})
|