@jbrowse/plugin-rdf 2.17.0 → 2.18.0
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/SPARQLAdapter/SPARQLAdapter.d.ts +7 -6
- package/dist/SPARQLAdapter/SPARQLAdapter.js +13 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/esm/SPARQLAdapter/SPARQLAdapter.d.ts +7 -6
- package/esm/SPARQLAdapter/SPARQLAdapter.js +14 -13
- package/esm/index.d.ts +1 -1
- package/esm/index.js +2 -2
- package/package.json +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BaseFeatureDataAdapter
|
|
2
|
-
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
-
import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
4
|
-
import { Instance } from 'mobx-state-tree';
|
|
5
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
6
|
-
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
1
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
7
2
|
import type MyConfigSchema from './configSchema';
|
|
3
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
5
|
+
import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
6
|
+
import type { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
7
|
+
import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
8
|
+
import type { Instance } from 'mobx-state-tree';
|
|
8
9
|
export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
9
10
|
private endpoint;
|
|
10
11
|
private queryTemplate;
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
6
7
|
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
7
8
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
8
9
|
const simpleFeature_1 = __importDefault(require("@jbrowse/core/util/simpleFeature"));
|
|
9
10
|
const string_template_1 = __importDefault(require("string-template"));
|
|
10
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
11
11
|
class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
12
12
|
constructor(config, getSubAdapter, pluginManager) {
|
|
13
13
|
super(config, getSubAdapter, pluginManager);
|
|
@@ -17,7 +17,7 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
17
17
|
this.refNamesQueryTemplate = (0, configuration_1.readConfObject)(config, 'refNamesQueryTemplate');
|
|
18
18
|
this.configRefNames = (0, configuration_1.readConfObject)(config, 'refNames');
|
|
19
19
|
}
|
|
20
|
-
async getRefNames(opts
|
|
20
|
+
async getRefNames(opts) {
|
|
21
21
|
if (this.refNames) {
|
|
22
22
|
return this.refNames;
|
|
23
23
|
}
|
|
@@ -36,21 +36,23 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
36
36
|
const filledTemplate = encodeURIComponent((0, string_template_1.default)(this.queryTemplate, query));
|
|
37
37
|
const { refName } = query;
|
|
38
38
|
const results = await this.querySparql(filledTemplate, opts);
|
|
39
|
-
this.resultsToFeatures(results, refName)
|
|
39
|
+
const features = this.resultsToFeatures(results, refName);
|
|
40
|
+
for (const feature of features) {
|
|
40
41
|
observer.next(feature);
|
|
41
|
-
}
|
|
42
|
+
}
|
|
42
43
|
observer.complete();
|
|
43
|
-
}, opts.
|
|
44
|
+
}, opts.stopToken);
|
|
44
45
|
}
|
|
45
|
-
async querySparql(query,
|
|
46
|
+
async querySparql(query, _opts) {
|
|
46
47
|
let additionalQueryParams = '';
|
|
47
48
|
if (this.additionalQueryParams.length) {
|
|
48
49
|
additionalQueryParams = `&${this.additionalQueryParams.join('&')}`;
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
-
const response = await fetch(
|
|
52
|
-
headers: {
|
|
53
|
-
|
|
51
|
+
const url = `${this.endpoint}?query=${query}${additionalQueryParams}`;
|
|
52
|
+
const response = await fetch(url, {
|
|
53
|
+
headers: {
|
|
54
|
+
accept: 'application/json,application/sparql-results+json',
|
|
55
|
+
},
|
|
54
56
|
});
|
|
55
57
|
return response.json();
|
|
56
58
|
}
|
|
@@ -105,7 +107,6 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
105
107
|
};
|
|
106
108
|
});
|
|
107
109
|
});
|
|
108
|
-
// resolve subfeatures, keeping only top-level features in seenFeatures
|
|
109
110
|
for (const [uniqueId, f] of Object.entries(seenFeatures)) {
|
|
110
111
|
const pid = f.data.parentUniqueId;
|
|
111
112
|
f.data.parentUniqueId = undefined;
|
|
@@ -163,6 +164,6 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
163
164
|
}
|
|
164
165
|
return true;
|
|
165
166
|
}
|
|
166
|
-
freeResources(
|
|
167
|
+
freeResources() { }
|
|
167
168
|
}
|
|
168
169
|
exports.default = SPARQLAdapter;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
export default class RdfPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
install(pluginManager: PluginManager): void;
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
|
|
7
6
|
const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
|
|
8
|
-
const
|
|
7
|
+
const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
|
|
9
8
|
const tracks_1 = require("@jbrowse/core/util/tracks");
|
|
9
|
+
const SPARQLAdapter_1 = require("./SPARQLAdapter");
|
|
10
10
|
class RdfPlugin extends Plugin_1.default {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BaseFeatureDataAdapter
|
|
2
|
-
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
-
import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
4
|
-
import { Instance } from 'mobx-state-tree';
|
|
5
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
6
|
-
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
1
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
7
2
|
import type MyConfigSchema from './configSchema';
|
|
3
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
5
|
+
import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
6
|
+
import type { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
7
|
+
import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
8
|
+
import type { Instance } from 'mobx-state-tree';
|
|
8
9
|
export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
9
10
|
private endpoint;
|
|
10
11
|
private queryTemplate;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readConfObject } from '@jbrowse/core/configuration';
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
3
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
3
4
|
import SimpleFeature from '@jbrowse/core/util/simpleFeature';
|
|
4
5
|
import format from 'string-template';
|
|
5
|
-
import { readConfObject } from '@jbrowse/core/configuration';
|
|
6
6
|
export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
7
7
|
constructor(config, getSubAdapter, pluginManager) {
|
|
8
8
|
super(config, getSubAdapter, pluginManager);
|
|
@@ -12,7 +12,7 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
|
12
12
|
this.refNamesQueryTemplate = readConfObject(config, 'refNamesQueryTemplate');
|
|
13
13
|
this.configRefNames = readConfObject(config, 'refNames');
|
|
14
14
|
}
|
|
15
|
-
async getRefNames(opts
|
|
15
|
+
async getRefNames(opts) {
|
|
16
16
|
if (this.refNames) {
|
|
17
17
|
return this.refNames;
|
|
18
18
|
}
|
|
@@ -31,21 +31,23 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
|
31
31
|
const filledTemplate = encodeURIComponent(format(this.queryTemplate, query));
|
|
32
32
|
const { refName } = query;
|
|
33
33
|
const results = await this.querySparql(filledTemplate, opts);
|
|
34
|
-
this.resultsToFeatures(results, refName)
|
|
34
|
+
const features = this.resultsToFeatures(results, refName);
|
|
35
|
+
for (const feature of features) {
|
|
35
36
|
observer.next(feature);
|
|
36
|
-
}
|
|
37
|
+
}
|
|
37
38
|
observer.complete();
|
|
38
|
-
}, opts.
|
|
39
|
+
}, opts.stopToken);
|
|
39
40
|
}
|
|
40
|
-
async querySparql(query,
|
|
41
|
+
async querySparql(query, _opts) {
|
|
41
42
|
let additionalQueryParams = '';
|
|
42
43
|
if (this.additionalQueryParams.length) {
|
|
43
44
|
additionalQueryParams = `&${this.additionalQueryParams.join('&')}`;
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
-
const response = await fetch(
|
|
47
|
-
headers: {
|
|
48
|
-
|
|
46
|
+
const url = `${this.endpoint}?query=${query}${additionalQueryParams}`;
|
|
47
|
+
const response = await fetch(url, {
|
|
48
|
+
headers: {
|
|
49
|
+
accept: 'application/json,application/sparql-results+json',
|
|
50
|
+
},
|
|
49
51
|
});
|
|
50
52
|
return response.json();
|
|
51
53
|
}
|
|
@@ -100,7 +102,6 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
|
100
102
|
};
|
|
101
103
|
});
|
|
102
104
|
});
|
|
103
|
-
// resolve subfeatures, keeping only top-level features in seenFeatures
|
|
104
105
|
for (const [uniqueId, f] of Object.entries(seenFeatures)) {
|
|
105
106
|
const pid = f.data.parentUniqueId;
|
|
106
107
|
f.data.parentUniqueId = undefined;
|
|
@@ -158,5 +159,5 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
|
|
|
158
159
|
}
|
|
159
160
|
return true;
|
|
160
161
|
}
|
|
161
|
-
freeResources(
|
|
162
|
+
freeResources() { }
|
|
162
163
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
export default class RdfPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
install(pluginManager: PluginManager): void;
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
3
|
-
import
|
|
2
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
4
3
|
import { getFileName } from '@jbrowse/core/util/tracks';
|
|
4
|
+
import { AdapterClass as SPARQLAdapterClass, configSchema as sparqlAdapterConfigSchema, } from './SPARQLAdapter';
|
|
5
5
|
export default class RdfPlugin extends Plugin {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-rdf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "JBrowse 2 RDF resources",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c344ea60099cb7e460b77f15808946b24a7eee74"
|
|
55
55
|
}
|