@abi-software/flatmapvuer 0.3.4 → 0.3.5

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/flatmapvuer",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "main": "./dist/flatmapvuer.common.js",
5
5
  "files": [
6
6
  "dist/*",
@@ -10,6 +10,7 @@
10
10
  "*.js"
11
11
  ],
12
12
  "scripts": {
13
+ "start": "vue-cli-service serve",
13
14
  "serve": "vue-cli-service serve --port 8082",
14
15
  "build": "vue-cli-service build --dest test_html --mode staging",
15
16
  "build-bundle": "vue-cli-service build --target lib --name flatmapvuer ./src/components/index.js",
@@ -28,6 +28,7 @@
28
28
  </div>
29
29
  <div v-for="origin in origins" class="attribute-content" :key="origin">
30
30
  {{ capitalise(origin) }}
31
+ <div class="seperator"></div>
31
32
  </div>
32
33
  <el-button v-show="originsWithDatasets.length > 0" class="button" @click="openDendrites">
33
34
  Explore origin data
@@ -37,6 +38,7 @@
37
38
  <div class="attribute-title">Components</div>
38
39
  <div v-for="component in components" class="attribute-content" :key="component">
39
40
  {{ capitalise(component) }}
41
+ <div class="seperator"></div>
40
42
  </div>
41
43
  </div>
42
44
  <div v-if="this.destinations" class="block">
@@ -56,6 +58,7 @@
56
58
  </div>
57
59
  <div v-for="destination in destinations" class="attribute-content" :key="destination">
58
60
  {{ capitalise(destination) }}
61
+ <div class="seperator"></div>
59
62
  </div>
60
63
  <el-button v-show="destinationsWithDatasets.length > 0" class="button" @click="openAxons">
61
64
  Explore destination data
@@ -109,6 +112,12 @@ const titleCase = (str) => {
109
112
  return str.replace(/\w\S*/g, (t) => { return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase() });
110
113
  }
111
114
 
115
+ const inArray = function(ar1, ar2){
116
+ let as1 = JSON.stringify(ar1)
117
+ let as2 = JSON.stringify(ar2)
118
+ return as1.indexOf(as2) !== -1
119
+ }
120
+
112
121
  const capitalise = function(str){
113
122
  if (str)
114
123
  return str.charAt(0).toUpperCase() + str.slice(1)
@@ -195,6 +204,32 @@ export default {
195
204
  pubmedSearchUrlUpdate: function (val){
196
205
  this.pubmedSearchUrl = val
197
206
  },
207
+ findAllIdsFromConnectivity(connectivity){
208
+ let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
209
+ let nodes = [...new Set(dnodes)] // remove duplicates
210
+ let found = []
211
+ nodes.forEach(n=>{
212
+ if (Array.isArray(n)){
213
+ found.push(n.flat())
214
+ } else {
215
+ found.push(n)
216
+ }
217
+ })
218
+ return [... new Set(found.flat())]
219
+ },
220
+ flattenConntectivity(connectivity){
221
+ let dnodes = connectivity.flat() // get nodes from edgelist
222
+ let nodes = [...new Set(dnodes)] // remove duplicates
223
+ let found = []
224
+ nodes.forEach(n=>{
225
+ if (Array.isArray(n)){
226
+ found.push(n.flat())
227
+ } else {
228
+ found.push(n)
229
+ }
230
+ })
231
+ return found.flat()
232
+ },
198
233
  findComponents: function(connectivity){
199
234
  let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
200
235
  let nodes = [...new Set(dnodes)] // remove duplicates
@@ -202,26 +237,20 @@ export default {
202
237
  let found = []
203
238
  let terminal = false
204
239
  nodes.forEach(node=>{
205
- let n = node.flat() // Find all terms on the node
206
- terminal = false
207
-
208
- // Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
209
- n.forEach(s=>{
210
- if(connectivity.axons.includes(s)){
211
- terminal = true
212
- }
213
- if(connectivity.dendrites.includes(s)){
214
- terminal = true
215
- }
216
- })
217
- if (!terminal){
218
- found.push(node)
219
- }
240
+ terminal = false
241
+ // Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
242
+ if(inArray(connectivity.axons,node)){
243
+ terminal = true
244
+ }
245
+ if(inArray(connectivity.dendrites, node)){
246
+ terminal = true
247
+ }
248
+ if (!terminal){
249
+ found.push(node)
250
+ }
220
251
  })
221
252
 
222
- // remove duplicates
223
- let foundUnique = [...new Set(found.map(n=>n[0]))]
224
- return foundUnique
253
+ return found
225
254
  },
226
255
  getOrganCuries: function(){
227
256
  fetch(`${this.sparcAPI}get-organ-curies/`)
@@ -276,6 +305,29 @@ export default {
276
305
  })
277
306
  })
278
307
  },
308
+ createComponentsLabelList: function(components, lookUp){
309
+ let labelList = []
310
+ components.forEach(n=>{
311
+ labelList.push(this.createLabelFromNeuralNode(n[0]), lookUp)
312
+ if (n.length === 2){
313
+ labelList.push(this.createLabelFromNeuralNode(n[1]), lookUp)
314
+ }
315
+ })
316
+ return labelList
317
+ },
318
+ createLabelFromNeuralNode: function(node, lookUp){
319
+ let label = lookUp[node[0]]
320
+ if (node.length === 2 && node[1].length > 0){
321
+ node[1].forEach(n=>{
322
+ if (lookUp[n] == undefined){
323
+ label += `, ${n}`
324
+ } else {
325
+ label += `, ${lookUp[n]}`
326
+ }
327
+ })
328
+ }
329
+ return label
330
+ },
279
331
  pathwayQuery: function(keastIds){
280
332
  this.destinations = []
281
333
  this.origins = []
@@ -294,24 +346,29 @@ export default {
294
346
  .then(data => {
295
347
  let connectivity = JSON.parse(data.values[0][0])
296
348
 
349
+ // Filter the origin and destinations from components
297
350
  let components = this.findComponents(connectivity)
298
351
 
299
- // Create list of ids to get labels for
300
- window.connectivity = connectivity
301
- let axons = connectivity.axons.map(a=>a[0])
302
- let dendrites = connectivity.dendrites.map(d=>d[0])
303
- let conIds = axons.concat(dendrites.concat(components))
304
- window.conIds = conIds
352
+ // process the nodes for finding datasets
353
+ let componentsFlat = this.flattenConntectivity(components)
354
+ let axons = connectivity.axons
355
+ let dendrites = connectivity.dendrites
356
+ let axonsFlat = this.flattenConntectivity(axons)
357
+ let dendritesFlat = this.flattenConntectivity(dendrites)
358
+
359
+ let conIds = this.findAllIdsFromConnectivity(connectivity) // Create list of ids to get labels for
360
+
361
+ // Create readable labels from the nodes. Setting this to 'this.origins' updates the display
305
362
  this.createLabelLookup(conIds).then(lookUp=>{
306
- this.destinations = axons.map(a=>lookUp[a])
307
- this.origins = dendrites.map(d=>lookUp[d])
308
- this.components = components.map(c=>lookUp[c])
363
+ this.destinations = axons.map(a=>this.createLabelFromNeuralNode(a,lookUp))
364
+ this.origins = dendrites.map(d=>this.createLabelFromNeuralNode(d,lookUp))
365
+ this.components = components.map(c=>this.createLabelFromNeuralNode(c, lookUp))
309
366
  })
310
367
 
311
368
  // Filter for the anatomy which is annotated on datasets
312
- this.destinationsWithDatasets = this.uberons.filter(ub => axons.indexOf(ub.id) !== -1)
313
- this.originsWithDatasets = this.uberons.filter(ub => dendrites.indexOf(ub.id) !== -1)
314
- this.componentsWithDatasets = this.uberons.filter(ub => dendrites.indexOf(ub.id) !== -1)
369
+ this.destinationsWithDatasets = this.uberons.filter(ub => axonsFlat.indexOf(ub.id) !== -1)
370
+ this.originsWithDatasets = this.uberons.filter(ub => dendritesFlat.indexOf(ub.id) !== -1)
371
+ this.componentsWithDatasets = this.uberons.filter(ub => componentsFlat.indexOf(ub.id) !== -1)
315
372
  this.loading = false
316
373
  })
317
374
  .catch((error) => {
@@ -384,6 +441,12 @@ export default {
384
441
  margin-left: 8px;
385
442
  }
386
443
 
444
+ .seperator {
445
+ width:90%;
446
+ height:0.5px;
447
+ background-color:#bfbec2;
448
+ }
449
+
387
450
  .main {
388
451
  font-size: 14px;
389
452
  text-align: left;