@abi-software/map-utilities 1.7.6 → 1.7.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-utilities",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -83,25 +83,59 @@ async function competencyQuery(options) {
83
83
  // Neuron populations that share at least one edge with another neuron population [query id => 23]
84
84
  async function queryAllConnectedPaths(flatmapAPI, knowledgeSource, featureId) {
85
85
  const featureIds = Array.isArray(featureId) ? featureId : [featureId];
86
- const isPath = featureIds[0].startsWith('ilxtr:');
87
- const queryId = isPath ? 23 : 1;
88
- const columnId = isPath ? 'path_id' : 'feature_id';
89
- const originalPaths = isPath ? featureIds : [];
90
- const data = await competencyQuery({
91
- flatmapAPI: flatmapAPI,
92
- knowledgeSource: knowledgeSource,
93
- queryId: queryId,
94
- parameters: [
95
- {
96
- column: columnId,
97
- value: featureIds
98
- },
99
- ]
86
+ // Split into paths (ilxtr:) and features (non-ilxtr:)
87
+ const pathIds = featureIds.filter(id => id.startsWith('ilxtr:'));
88
+ const locationIds = featureIds.filter(id => !id.startsWith('ilxtr:'));
89
+
90
+ const promises = [];
91
+
92
+ // Query for path IDs (query 23)
93
+ if (pathIds.length > 0) {
94
+ promises.push(
95
+ competencyQuery({
96
+ flatmapAPI: flatmapAPI,
97
+ knowledgeSource: knowledgeSource,
98
+ queryId: 23,
99
+ parameters: [
100
+ {
101
+ column: 'path_id',
102
+ value: pathIds
103
+ },
104
+ ]
105
+ })
106
+ );
107
+ }
108
+
109
+ // Query for feature/location IDs (query 1)
110
+ if (locationIds.length > 0) {
111
+ promises.push(
112
+ competencyQuery({
113
+ flatmapAPI: flatmapAPI,
114
+ knowledgeSource: knowledgeSource,
115
+ queryId: 1,
116
+ parameters: [
117
+ {
118
+ column: 'feature_id',
119
+ value: locationIds
120
+ },
121
+ ]
122
+ })
123
+ );
124
+ }
125
+
126
+ // Execute queries in parallel
127
+ const results = await Promise.all(promises);
128
+
129
+ // Combine all paths from both queries
130
+ let allPaths = [...pathIds]; // Include original path IDs
131
+
132
+ results.forEach((data) => {
133
+ // value => [ 'source_id', 'path_id', 'axon_terminal']
134
+ const paths = data?.results?.values?.map(value => value[1]) || [];
135
+ allPaths.push(...paths);
100
136
  });
101
137
 
102
- // value => [ 'source_id', 'path_id', 'axon_terminal']
103
- const paths = data?.results?.values?.map(value => value[1]) || [];
104
- const combined = [...new Set([...originalPaths, ...paths])];
138
+ const combined = [...new Set(allPaths)];
105
139
 
106
140
  // Continue to forward and backward connections
107
141
  let additionalPaths = [];