@abi-software/map-utilities 1.6.1-beta.3 → 1.6.1-beta.4
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/map-utilities.js +2670 -2674
- package/dist/map-utilities.umd.cjs +53 -53
- package/package.json +1 -1
- package/src/components/CompetencyQueries/CompetencyQueries.js +66 -18
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @private
|
|
2
3
|
* Competency Queries
|
|
3
4
|
*
|
|
4
5
|
* competencyQuery: base function
|
|
@@ -6,8 +7,7 @@
|
|
|
6
7
|
*
|
|
7
8
|
* Note: use named-export for better tree-shaking.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
async function postRequest(API_URL, payload) {
|
|
10
|
+
async function _postRequest(API_URL, payload) {
|
|
11
11
|
try {
|
|
12
12
|
const response = await fetch(API_URL, {
|
|
13
13
|
method: "POST",
|
|
@@ -30,7 +30,7 @@ async function postRequest(API_URL, payload) {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Competency Query
|
|
33
|
-
*
|
|
33
|
+
* @public
|
|
34
34
|
* @param {Object} options - Query options.
|
|
35
35
|
* @param {string} options.flatmapAPI - Base URL of the flatmap server.
|
|
36
36
|
* @param {string} options.knowledgeSource - SCKAN source ID.
|
|
@@ -69,14 +69,23 @@ async function competencyQuery(options) {
|
|
|
69
69
|
payload.order = [orderId];
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
return
|
|
72
|
+
return _postRequest(API_URL, payload);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @public
|
|
77
|
+
* @param {*} flatmapAPI
|
|
78
|
+
* @param {*} knowledgeSource
|
|
79
|
+
* @param {*} featureId
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
75
82
|
// Neuron populations associated with a location [query id => 1] (or)
|
|
76
83
|
// Neuron populations that share at least one edge with another neuron population [query id => 23]
|
|
77
84
|
async function queryAllConnectedPaths(flatmapAPI, knowledgeSource, featureId) {
|
|
78
85
|
const featureIds = Array.isArray(featureId) ? featureId : [featureId];
|
|
79
|
-
const
|
|
86
|
+
const isPath = featureIds[0].startsWith('ilxtr:');
|
|
87
|
+
const queryId = isPath ? 23 : 1;
|
|
88
|
+
const originalPaths = isPath ? featureIds : [];
|
|
80
89
|
const data = await competencyQuery({
|
|
81
90
|
flatmapAPI: flatmapAPI,
|
|
82
91
|
knowledgeSource: knowledgeSource,
|
|
@@ -88,17 +97,25 @@ async function queryAllConnectedPaths(flatmapAPI, knowledgeSource, featureId) {
|
|
|
88
97
|
},
|
|
89
98
|
]
|
|
90
99
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
|
|
101
|
+
// value => [ 'source_id', 'path_id', 'axon_terminal']
|
|
102
|
+
const paths = data?.results?.values?.map(value => value[1]) || [];
|
|
103
|
+
const combined = [...new Set([...originalPaths, ...paths])];
|
|
104
|
+
|
|
105
|
+
// Continue to forward and backward connections
|
|
106
|
+
const additionalPaths = await queryForwardBackwardConnections(flatmapAPI, knowledgeSource, combined);
|
|
107
|
+
const total = [...new Set([...combined, ...additionalPaths])];
|
|
108
|
+
|
|
109
|
+
return total;
|
|
100
110
|
}
|
|
101
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @public
|
|
114
|
+
* @param {*} flatmapAPI
|
|
115
|
+
* @param {*} knowledgeSource
|
|
116
|
+
* @param {*} featureId
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
102
119
|
// Neuron populations beginning at a location
|
|
103
120
|
async function queryPathsByOrigin(flatmapAPI, knowledgeSource, featureId) {
|
|
104
121
|
const data = await competencyQuery({
|
|
@@ -123,6 +140,13 @@ async function queryPathsByOrigin(flatmapAPI, knowledgeSource, featureId) {
|
|
|
123
140
|
return [];
|
|
124
141
|
}
|
|
125
142
|
|
|
143
|
+
/**
|
|
144
|
+
* @public
|
|
145
|
+
* @param {*} flatmapAPI
|
|
146
|
+
* @param {*} knowledgeSource
|
|
147
|
+
* @param {*} featureId
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
126
150
|
// Neuron populations via a location
|
|
127
151
|
async function queryPathsByViaLocation(flatmapAPI, knowledgeSource, featureId) {
|
|
128
152
|
const data = await competencyQuery({
|
|
@@ -147,6 +171,13 @@ async function queryPathsByViaLocation(flatmapAPI, knowledgeSource, featureId) {
|
|
|
147
171
|
return [];
|
|
148
172
|
}
|
|
149
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @public
|
|
176
|
+
* @param {*} flatmapAPI
|
|
177
|
+
* @param {*} knowledgeSource
|
|
178
|
+
* @param {*} featureId
|
|
179
|
+
* @returns
|
|
180
|
+
*/
|
|
150
181
|
// Neuron populations terminating at a location
|
|
151
182
|
async function queryPathsByDestination(flatmapAPI, knowledgeSource, featureId) {
|
|
152
183
|
const data = await competencyQuery({
|
|
@@ -171,7 +202,12 @@ async function queryPathsByDestination(flatmapAPI, knowledgeSource, featureId) {
|
|
|
171
202
|
return [];
|
|
172
203
|
}
|
|
173
204
|
|
|
174
|
-
|
|
205
|
+
/**
|
|
206
|
+
* @private
|
|
207
|
+
* @param {*} inputArray
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
function _extractFeatureIds(inputArray) {
|
|
175
211
|
const result = [];
|
|
176
212
|
|
|
177
213
|
for (const itemString of inputArray) {
|
|
@@ -186,6 +222,13 @@ function extractFeatureIds(inputArray) {
|
|
|
186
222
|
return result;
|
|
187
223
|
}
|
|
188
224
|
|
|
225
|
+
/**
|
|
226
|
+
* @public
|
|
227
|
+
* @param {*} flatmapAPI
|
|
228
|
+
* @param {*} knowledgeSource
|
|
229
|
+
* @param {*} pathIds
|
|
230
|
+
* @returns
|
|
231
|
+
*/
|
|
189
232
|
// Neuron populations as forward or backward connections of a neuron population
|
|
190
233
|
async function queryForwardBackwardConnections(flatmapAPI, knowledgeSource, pathIds) {
|
|
191
234
|
const data = await competencyQuery({
|
|
@@ -211,13 +254,18 @@ async function queryForwardBackwardConnections(flatmapAPI, knowledgeSource, path
|
|
|
211
254
|
return [];
|
|
212
255
|
}
|
|
213
256
|
|
|
257
|
+
/**
|
|
258
|
+
* @public
|
|
259
|
+
* @param {*} options
|
|
260
|
+
* @returns
|
|
261
|
+
*/
|
|
214
262
|
// Neuron populations from origin to destination, via
|
|
215
263
|
// Query 24: Neuron populations that have source, via, and destination nodes
|
|
216
264
|
// Query 25: Neuron populations that have source, via, and destination locations
|
|
217
265
|
async function queryPathsByRoute({ flatmapAPI, knowledgeSource, origins, destinations, vias }) {
|
|
218
|
-
const originFeatureIds =
|
|
219
|
-
const destinationFeatureIds =
|
|
220
|
-
const viaFeatureIds =
|
|
266
|
+
const originFeatureIds = _extractFeatureIds(origins);
|
|
267
|
+
const destinationFeatureIds = _extractFeatureIds(destinations);
|
|
268
|
+
const viaFeatureIds = _extractFeatureIds(vias);
|
|
221
269
|
|
|
222
270
|
const paramsF = [
|
|
223
271
|
{
|