@abi-software/map-utilities 1.6.1-beta.2 → 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 +3584 -3568
- package/dist/map-utilities.umd.cjs +57 -57
- package/package.json +1 -1
- package/src/components/CompetencyQueries/CompetencyQueries.js +97 -19
- package/src/components/index.js +2 -0
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,13 +222,50 @@ 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
|
+
*/
|
|
232
|
+
// Neuron populations as forward or backward connections of a neuron population
|
|
233
|
+
async function queryForwardBackwardConnections(flatmapAPI, knowledgeSource, pathIds) {
|
|
234
|
+
const data = await competencyQuery({
|
|
235
|
+
flatmapAPI,
|
|
236
|
+
knowledgeSource,
|
|
237
|
+
queryId: 26,
|
|
238
|
+
parameters: [
|
|
239
|
+
{
|
|
240
|
+
column: 'path_id',
|
|
241
|
+
value: pathIds
|
|
242
|
+
},
|
|
243
|
+
]
|
|
244
|
+
});
|
|
245
|
+
if (data?.results?.values) {
|
|
246
|
+
const paths = data.results.values.map((value) => {
|
|
247
|
+
// value => ["source_id", "base_path_id", "dest_path_id", "distance"]
|
|
248
|
+
// return dest_path_id
|
|
249
|
+
return value[2];
|
|
250
|
+
});
|
|
251
|
+
// remove duplicates
|
|
252
|
+
return [...new Set(paths)];
|
|
253
|
+
}
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @public
|
|
259
|
+
* @param {*} options
|
|
260
|
+
* @returns
|
|
261
|
+
*/
|
|
189
262
|
// Neuron populations from origin to destination, via
|
|
190
263
|
// Query 24: Neuron populations that have source, via, and destination nodes
|
|
191
264
|
// Query 25: Neuron populations that have source, via, and destination locations
|
|
192
265
|
async function queryPathsByRoute({ flatmapAPI, knowledgeSource, origins, destinations, vias }) {
|
|
193
|
-
const originFeatureIds =
|
|
194
|
-
const destinationFeatureIds =
|
|
195
|
-
const viaFeatureIds =
|
|
266
|
+
const originFeatureIds = _extractFeatureIds(origins);
|
|
267
|
+
const destinationFeatureIds = _extractFeatureIds(destinations);
|
|
268
|
+
const viaFeatureIds = _extractFeatureIds(vias);
|
|
196
269
|
|
|
197
270
|
const paramsF = [
|
|
198
271
|
{
|
|
@@ -269,7 +342,11 @@ async function queryPathsByRoute({ flatmapAPI, knowledgeSource, origins, destina
|
|
|
269
342
|
const paths = data?.results?.values?.map(value => value[1]) || [];
|
|
270
343
|
const combined = [...new Set([...pathsF, ...paths])];
|
|
271
344
|
|
|
272
|
-
|
|
345
|
+
// Continue to forward and backward connections
|
|
346
|
+
const additionalPaths = await queryForwardBackwardConnections(flatmapAPI, knowledgeSource, combined);
|
|
347
|
+
const total = [...new Set([...combined, ...additionalPaths])];
|
|
348
|
+
|
|
349
|
+
return total;
|
|
273
350
|
}
|
|
274
351
|
|
|
275
352
|
export {
|
|
@@ -279,4 +356,5 @@ export {
|
|
|
279
356
|
queryPathsByViaLocation,
|
|
280
357
|
queryPathsByDestination,
|
|
281
358
|
queryPathsByRoute,
|
|
359
|
+
queryForwardBackwardConnections,
|
|
282
360
|
};
|
package/src/components/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
queryPathsByViaLocation,
|
|
16
16
|
queryPathsByDestination,
|
|
17
17
|
queryPathsByRoute,
|
|
18
|
+
queryForwardBackwardConnections,
|
|
18
19
|
} from "./CompetencyQueries/CompetencyQueries.js";
|
|
19
20
|
import {
|
|
20
21
|
filterOrigins,
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
queryPathsByViaLocation,
|
|
48
49
|
queryPathsByDestination,
|
|
49
50
|
queryPathsByRoute,
|
|
51
|
+
queryForwardBackwardConnections,
|
|
50
52
|
filterOrigins,
|
|
51
53
|
filterDestinations,
|
|
52
54
|
filterViaLocations,
|