@abi-software/map-utilities 1.4.2-beta.0 → 1.4.2

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.4.2-beta.0",
3
+ "version": "1.4.2",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -72,6 +72,7 @@ export class ConnectivityGraph extends EventTarget
72
72
  somas = []
73
73
  labelCache = new Map()
74
74
  graphCanvas = null
75
+ hasPhenotypes = false
75
76
 
76
77
  constructor(labelCache, graphCanvas)
77
78
  {
@@ -83,23 +84,32 @@ export class ConnectivityGraph extends EventTarget
83
84
  async addConnectivity(knowledge)
84
85
  //=====================================================
85
86
  {
86
- const sourceKey = ["ilxtr:hasSomaLocatedIn"]
87
- const destinationKey = ["ilxtr:hasAxonPresynapticElementIn", "ilxtr:hasAxonSensorySubcellularElementIn"]
88
-
89
- const source = []
90
- const destination = []
91
- sourceKey.forEach((key)=>{
92
- source.push(...knowledge["node-phenotypes"][key])
93
- })
94
- destinationKey.forEach((key)=>{
95
- destination.push(...knowledge["node-phenotypes"][key])
96
- })
97
- const via = findComponents(knowledge, source, destination)
98
-
99
- this.dendrites = source.map(node => JSON.stringify(node))
100
- this.axons = destination.map(node => JSON.stringify(node))
101
- if (via?.length) {
102
- this.somas = via.map(node => JSON.stringify(node))
87
+ if (knowledge && knowledge["node-phenotypes"]) {
88
+ const sourceKey = ["ilxtr:hasSomaLocatedIn"]
89
+ const destinationKey = ["ilxtr:hasAxonPresynapticElementIn", "ilxtr:hasAxonSensorySubcellularElementIn"]
90
+
91
+ const source = []
92
+ const destination = []
93
+ sourceKey.forEach((key)=>{
94
+ source.push(...knowledge["node-phenotypes"][key])
95
+ })
96
+ destinationKey.forEach((key)=>{
97
+ destination.push(...knowledge["node-phenotypes"][key])
98
+ })
99
+ const via = findComponents(knowledge, source, destination)
100
+ this.dendrites = source.map(node => JSON.stringify(node))
101
+ this.axons = destination.map(node => JSON.stringify(node))
102
+ if (via?.length) {
103
+ this.somas = via.map(node => JSON.stringify(node))
104
+ }
105
+ this.hasPhenotypes = true
106
+ } else {
107
+ this.axons = knowledge.axons.map(node => JSON.stringify(node))
108
+ this.dendrites = knowledge.dendrites.map(node => JSON.stringify(node))
109
+ if (knowledge.somas?.length) {
110
+ this.somas = knowledge.somas.map(node => JSON.stringify(node))
111
+ }
112
+ this.hasPhenotypes = false
103
113
  }
104
114
  if (knowledge.connectivity.length) {
105
115
  for (const edge of knowledge.connectivity) {
@@ -208,9 +218,17 @@ export class ConnectivityGraph extends EventTarget
208
218
  get roots()
209
219
  //===================
210
220
  {
211
- return [
212
- ...this.dendrites,
213
- ]
221
+ if (this.hasPhenotypes) {
222
+ return [
223
+ ...this.dendrites,
224
+ ]
225
+ } else {
226
+ return [
227
+ ...this.dendrites,
228
+ ...this.somas
229
+ ]
230
+ }
231
+
214
232
  }
215
233
 
216
234
  async graphNode(node)
@@ -229,12 +247,25 @@ export class ConnectivityGraph extends EventTarget
229
247
  id,
230
248
  label: label.join('\n')
231
249
  }
232
- if (this.axons.includes(id)) {
233
- result['axon'] = true
234
- } else if (this.dendrites.includes(id)) {
235
- result['dendrite'] = true
250
+ if (this.hasPhenotypes) {
251
+ if (this.axons.includes(id)) {
252
+ result['axon'] = true
253
+ } else if (this.dendrites.includes(id)) {
254
+ result['dendrite'] = true
255
+ } else {
256
+ result['somas'] = true
257
+ }
236
258
  } else {
237
- result['somas'] = true
259
+ if (this.axons.includes(id)) {
260
+ if (this.dendrites.includes(id) || this.somas.includes(id)) {
261
+ result['somas'] = true
262
+ } else {
263
+ result['axon'] = true
264
+ }
265
+ } else if (this.dendrites.includes(id) || this.somas.includes(id)) {
266
+ result['dendrite'] = true
267
+
268
+ }
238
269
  }
239
270
  return result
240
271
  }