@abi-software/flatmapvuer 0.3.6 → 0.3.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/flatmapvuer",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "main": "./dist/flatmapvuer.common.js",
5
5
  "files": [
6
6
  "dist/*",
@@ -10,13 +10,14 @@
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",
16
17
  "lint": "vue-cli-service lint"
17
18
  },
18
19
  "dependencies": {
19
- "@abi-software/flatmap-viewer": "^2.2.0-beta.16",
20
+ "@abi-software/flatmap-viewer": "^2.2.2-beta.4",
20
21
  "@abi-software/svg-sprite": "^0.1.14",
21
22
  "core-js": "^3.3.2",
22
23
  "css-element-queries": "^1.2.2",
@@ -124,6 +124,7 @@
124
124
  v-if="pathways.length > 0 && pathControls"
125
125
  v-popover:checkBoxPopover
126
126
  >
127
+ <svg-legends class= "svg-legends-container"/>
127
128
  <el-popover
128
129
  content="Find these markers for data"
129
130
  placement="right"
@@ -250,6 +251,7 @@
250
251
  import Vue from "vue";
251
252
  import Tooltip from "./Tooltip";
252
253
  import { MapSvgIcon, MapSvgSpriteColor } from "@abi-software/svg-sprite";
254
+ import SvgLegends from "./legends/Legends";
253
255
  import {
254
256
  Checkbox,
255
257
  CheckboxGroup,
@@ -284,7 +286,8 @@ export default {
284
286
  components: {
285
287
  MapSvgIcon,
286
288
  MapSvgSpriteColor,
287
- Tooltip
289
+ Tooltip,
290
+ SvgLegends
288
291
  },
289
292
  beforeCreate: function() {
290
293
  this.mapManager = undefined;
@@ -650,7 +653,15 @@ export default {
650
653
  }
651
654
  }
652
655
  return false;
653
- }
656
+ },
657
+ /**
658
+ * Get the list of suggested terms
659
+ */
660
+ searchSuggestions: function(term) {
661
+ if (this.mapImp)
662
+ return this.mapImp.search(term);
663
+ return [];
664
+ },
654
665
  },
655
666
  props: {
656
667
  entry: String,
@@ -785,7 +796,7 @@ export default {
785
796
  @import "~element-ui/packages/theme-chalk/src/loading";
786
797
  @import "~element-ui/packages/theme-chalk/src/row";
787
798
 
788
- .beta-popovers{
799
+ .beta-popovers {
789
800
  position: absolute;
790
801
  top: 90px;
791
802
  left: 16px;
@@ -882,6 +893,11 @@ export default {
882
893
  }
883
894
  }
884
895
 
896
+ .svg-legends-container {
897
+ width:70%;
898
+ height:auto;
899
+ }
900
+
885
901
  .pathway-container {
886
902
  float: left;
887
903
  padding-left: 16px;
@@ -890,7 +906,6 @@ export default {
890
906
  text-align: left;
891
907
  overflow: auto;
892
908
  border: 1px solid rgb(220, 223, 230);
893
- padding-top: 7px;
894
909
  padding-bottom: 16px;
895
910
  background: #ffffff;
896
911
  }
@@ -1163,7 +1178,7 @@ export default {
1163
1178
  background-color: black;
1164
1179
  }
1165
1180
  &.lightskyblue {
1166
- background-color: white;
1181
+ background-color: lightskyblue;
1167
1182
  }
1168
1183
  }
1169
1184
 
@@ -1288,7 +1303,7 @@ export default {
1288
1303
  z-index: 8;
1289
1304
  width: 20px;
1290
1305
  height: 40px;
1291
- border: solid 1px #e4e7ed;
1306
+ border: solid 1px $app-primary-color;
1292
1307
  text-align: center;
1293
1308
  vertical-align: middle;
1294
1309
  cursor: pointer;
@@ -1305,21 +1320,22 @@ export default {
1305
1320
  .drawer-button {
1306
1321
  float: left;
1307
1322
  margin-top: calc(50% - 36px);
1308
- border-left: 0;
1309
- background-color: #ffffff;
1323
+ background-color: #F9F2FC;
1324
+
1310
1325
  i {
1326
+ font-weight: 600;
1311
1327
  margin-top: 12px;
1312
1328
  color: $app-primary-color;
1313
1329
  transition-delay: 0.9s;
1314
1330
  }
1315
1331
  &.open {
1316
1332
  i {
1317
- transform: rotate(0deg) scaleY(2.5);
1333
+ transform: rotate(0deg) scaleY(2);
1318
1334
  }
1319
1335
  }
1320
1336
  &.close {
1321
1337
  i {
1322
- transform: rotate(180deg) scaleY(2.5);
1338
+ transform: rotate(180deg) scaleY(2);
1323
1339
  }
1324
1340
  }
1325
1341
  }
@@ -120,14 +120,18 @@ export default {
120
120
  this.loading.response = false
121
121
 
122
122
  // create links for each pubmedId
123
- data.values.forEach(identifier => {
124
- let ids = this.stripPMIDPrefix(identifier[0])
125
- this.titleFromPubmed(ids).then( bib=>{
126
- let [html, link] = this.splitLink(bib)
127
- this.pubmeds.push({identifier: identifier[0] , html: html, url: link})
128
- })
129
- });
130
- this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
123
+ if (data.values.length > 0){
124
+ data.values.forEach(identifier => {
125
+ let ids = this.stripPMIDPrefix(identifier[0])
126
+ this.titleFromPubmed(ids).then( bib=>{
127
+ let [html, link] = this.splitLink(bib)
128
+ this.pubmeds.push({identifier: identifier[0] , html: html, url: link})
129
+ })
130
+ });
131
+ this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
132
+ } else {
133
+ this.$emit('pubmedSearchUrl', '') // Clears the pubmed search button
134
+ }
131
135
  })
132
136
  .catch((error) => {
133
137
  console.error('Error:', error)
@@ -26,8 +26,9 @@
26
26
  </span>
27
27
  </el-popover>
28
28
  </div>
29
- <div v-for="origin in origins" class="attribute-content" :key="origin">
29
+ <div v-for="(origin, i) in origins" class="attribute-content" :key="origin">
30
30
  {{ capitalise(origin) }}
31
+ <div v-if="i != origins.length - 1" class="seperator"></div>
31
32
  </div>
32
33
  <el-button v-show="originsWithDatasets.length > 0" class="button" @click="openDendrites">
33
34
  Explore origin data
@@ -35,8 +36,9 @@
35
36
  </div>
36
37
  <div v-if="this.components" class="block">
37
38
  <div class="attribute-title">Components</div>
38
- <div v-for="component in components" class="attribute-content" :key="component">
39
+ <div v-for="(component, i) in components" class="attribute-content" :key="component">
39
40
  {{ capitalise(component) }}
41
+ <div v-if="i != components.length - 1" class="seperator"></div>
40
42
  </div>
41
43
  </div>
42
44
  <div v-if="this.destinations" class="block">
@@ -54,8 +56,9 @@
54
56
  </span>
55
57
  </el-popover>
56
58
  </div>
57
- <div v-for="destination in destinations" class="attribute-content" :key="destination">
59
+ <div v-for="(destination, i) in destinations" class="attribute-content" :key="destination">
58
60
  {{ capitalise(destination) }}
61
+ <div v-if="i != destinations.length - 1" class="seperator"></div>
59
62
  </div>
60
63
  <el-button v-show="destinationsWithDatasets.length > 0" class="button" @click="openAxons">
61
64
  Explore destination data
@@ -73,7 +76,7 @@
73
76
  <i v-if="action.title === 'Search for datasets' || action.title === 'View Dataset' " class="el-icon-coin"></i>
74
77
  {{action.title}}
75
78
  </el-button> -->
76
- <el-button v-if="pubmedSearchUrl" class="button" icon="el-icon-notebook-2" @click="openUrl(pubmedSearchUrl)">
79
+ <el-button v-if="pubmedSearchUrl != ''" class="button" icon="el-icon-notebook-2" @click="openUrl(pubmedSearchUrl)">
77
80
  Open publications in pubmed
78
81
  </el-button>
79
82
  </div>
@@ -109,6 +112,17 @@ 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
+
121
+ // remove duplicates by stringifying the objects
122
+ const removeDuplicates = function(arrayOfAnything){
123
+ return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(e => JSON.parse(e))
124
+ }
125
+
112
126
  const capitalise = function(str){
113
127
  if (str)
114
128
  return str.charAt(0).toUpperCase() + str.slice(1)
@@ -195,33 +209,53 @@ export default {
195
209
  pubmedSearchUrlUpdate: function (val){
196
210
  this.pubmedSearchUrl = val
197
211
  },
198
- findComponents: function(connectivity){
212
+ findAllIdsFromConnectivity(connectivity){
199
213
  let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
200
214
  let nodes = [...new Set(dnodes)] // remove duplicates
215
+ let found = []
216
+ nodes.forEach(n=>{
217
+ if (Array.isArray(n)){
218
+ found.push(n.flat())
219
+ } else {
220
+ found.push(n)
221
+ }
222
+ })
223
+ return [... new Set(found.flat())]
224
+ },
225
+ flattenConntectivity(connectivity){
226
+ let dnodes = connectivity.flat() // get nodes from edgelist
227
+ let nodes = [...new Set(dnodes)] // remove duplicates
228
+ let found = []
229
+ nodes.forEach(n=>{
230
+ if (Array.isArray(n)){
231
+ found.push(n.flat())
232
+ } else {
233
+ found.push(n)
234
+ }
235
+ })
236
+ return found.flat()
237
+ },
238
+ findComponents: function(connectivity){
239
+ let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
240
+ let nodes = removeDuplicates(dnodes)
201
241
 
202
242
  let found = []
203
243
  let terminal = false
204
244
  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
- }
245
+ terminal = false
246
+ // Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
247
+ if(inArray(connectivity.axons,node)){
248
+ terminal = true
249
+ }
250
+ if(inArray(connectivity.dendrites, node)){
251
+ terminal = true
252
+ }
253
+ if (!terminal){
254
+ found.push(node)
255
+ }
220
256
  })
221
257
 
222
- // remove duplicates
223
- let foundUnique = [...new Set(found.map(n=>n[0]))]
224
- return foundUnique
258
+ return found
225
259
  },
226
260
  getOrganCuries: function(){
227
261
  fetch(`${this.sparcAPI}get-organ-curies/`)
@@ -276,6 +310,29 @@ export default {
276
310
  })
277
311
  })
278
312
  },
313
+ createComponentsLabelList: function(components, lookUp){
314
+ let labelList = []
315
+ components.forEach(n=>{
316
+ labelList.push(this.createLabelFromNeuralNode(n[0]), lookUp)
317
+ if (n.length === 2){
318
+ labelList.push(this.createLabelFromNeuralNode(n[1]), lookUp)
319
+ }
320
+ })
321
+ return labelList
322
+ },
323
+ createLabelFromNeuralNode: function(node, lookUp){
324
+ let label = lookUp[node[0]]
325
+ if (node.length === 2 && node[1].length > 0){
326
+ node[1].forEach(n=>{
327
+ if (lookUp[n] == undefined){
328
+ label += `, ${n}`
329
+ } else {
330
+ label += `, ${lookUp[n]}`
331
+ }
332
+ })
333
+ }
334
+ return label
335
+ },
279
336
  pathwayQuery: function(keastIds){
280
337
  this.destinations = []
281
338
  this.origins = []
@@ -293,20 +350,29 @@ export default {
293
350
  .then(response => response.json())
294
351
  .then(data => {
295
352
  let connectivity = JSON.parse(data.values[0][0])
353
+ // Filter the origin and destinations from components
296
354
  let components = this.findComponents(connectivity)
297
355
 
298
- // Create list of ids to get labels for
299
- let conIds = connectivity.axons.concat(connectivity.dendrites.concat(components))
356
+ // process the nodes for finding datasets
357
+ let componentsFlat = this.flattenConntectivity(components)
358
+ let axons = removeDuplicates(connectivity.axons)
359
+ let dendrites = removeDuplicates(connectivity.dendrites)
360
+ let axonsFlat = this.flattenConntectivity(axons)
361
+ let dendritesFlat = this.flattenConntectivity(dendrites)
362
+
363
+ let conIds = this.findAllIdsFromConnectivity(connectivity) // Create list of ids to get labels for
364
+
365
+ // Create readable labels from the nodes. Setting this to 'this.origins' updates the display
300
366
  this.createLabelLookup(conIds).then(lookUp=>{
301
- this.destinations = connectivity.axons.map(a=>lookUp[a])
302
- this.origins = connectivity.dendrites.map(d=>lookUp[d])
303
- this.components = components.map(c=>lookUp[c])
367
+ this.destinations = axons.map(a=>this.createLabelFromNeuralNode(a,lookUp))
368
+ this.origins = dendrites.map(d=>this.createLabelFromNeuralNode(d,lookUp))
369
+ this.components = components.map(c=>this.createLabelFromNeuralNode(c, lookUp))
304
370
  })
305
371
 
306
372
  // Filter for the anatomy which is annotated on datasets
307
- this.destinationsWithDatasets = this.uberons.filter(ub => connectivity.axons.indexOf(ub.id) !== -1)
308
- this.originsWithDatasets = this.uberons.filter(ub => connectivity.dendrites.indexOf(ub.id) !== -1)
309
- this.componentsWithDatasets = this.uberons.filter(ub => connectivity.dendrites.indexOf(ub.id) !== -1)
373
+ this.destinationsWithDatasets = this.uberons.filter(ub => axonsFlat.indexOf(ub.id) !== -1)
374
+ this.originsWithDatasets = this.uberons.filter(ub => dendritesFlat.indexOf(ub.id) !== -1)
375
+ this.componentsWithDatasets = this.uberons.filter(ub => componentsFlat.indexOf(ub.id) !== -1)
310
376
  this.loading = false
311
377
  })
312
378
  .catch((error) => {
@@ -379,6 +445,12 @@ export default {
379
445
  margin-left: 8px;
380
446
  }
381
447
 
448
+ .seperator {
449
+ width:90%;
450
+ height:0.5px;
451
+ background-color:#bfbec2;
452
+ }
453
+
382
454
  .main {
383
455
  font-size: 14px;
384
456
  text-align: left;
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <div class="legends-container">
3
+ <svg version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xmlns="http://www.w3.org/2000/svg" xmlns:bx="https://boxy-svg.com">
4
+ <defs>
5
+ <bx:grid height="30.447" width="32.516" x="0" y="0"/>
6
+ </defs>
7
+ <path class="st0 st0-translate" d="M61.3,103.8c-15.9,0-28.8-12.3-28.8-27.3c0-15,13-27.3,28.8-27.3s28.8,12.3,28.8,27.3 C90.1,91.5,77.2,103.8,61.3,103.8z"/>
8
+ <path class="st1" d="M40.3,356.1C29.5,345,29.8,328,41.5,317.5c11.7-10.5,29.6-9.9,40.7,1.1c11.1,11,10.5,28.1-1.2,38.5 C69.3,367.4,51.1,366.9,40.3,356.1z"/>
9
+ <path class="st2" d="M61.2,396.9c-5.3,9.3-15.3,15.1-26.1,15.1l-0.4,0.6c5.1,9,5.1,20,0,29l0.4,0.6c10.7,0,20.8,5.8,26.1,15.1 c5.3-9.3,15.3-15.1,26.1-15.1c-5.3-9.3-5.3-20.9,0-30.4C76.6,412.1,66.7,406.3,61.2,396.9z"/>
10
+ <text transform="matrix(0.9908 0 0 1 118.0161 171.7975)" class="st3 st4 st5" style="white-space: pre;">Tissue region</text>
11
+ <path class="st6" d="M40.9,231.1c11.3-10.6,29.5-10.6,40.8,0c11.3,10.6,11.3,27.9,0,38.5c-11.3,10.6-29.5,10.6-40.8,0 C29.7,259,29.7,241.7,40.9,231.1z"/>
12
+ <text transform="matrix(0.9908 0 0 1 118.0161 257.675)" class="st3 st4 st5" style="white-space: pre;">Brain nuclei</text>
13
+ <!-- Hide this unti we can clarify the label
14
+ <path class="st7" d="M34.3,174c-6.2-13.9,0.6-29.9,15.3-35.7c14.7-5.9,31.6,0.6,37.8,14.4c1.5,3.5,2.3,7,2.3,10.6 c0,10.6-6.6,20.8-17.6,25.2C57.5,194.3,40.5,187.9,34.3,174z"/>
15
+ <text transform="matrix(0.9908 0 0 1 117.5474 171.7975)" class="st3 st4 st5" style="white-space: pre;">Specific anatomical structure</text>
16
+ -->
17
+ <text transform="matrix(0.9908 0 0 1 118.0903 345.5266)" class="st3 st4 st5" style="white-space: pre;">Ganglia</text>
18
+ <text transform="matrix(0.9908 0 0 1 118.0903 433.1613)" class="st3 st4 st5" style="white-space: pre;">Nerve plexus</text>
19
+ </svg>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ export default {
25
+ name: 'SvgLegends',
26
+ }
27
+ </script>
28
+
29
+ <style scoped lang="scss">
30
+ .legends-container {
31
+ pointer-events: none;
32
+ transform: translate(0px, -20px);
33
+ }
34
+
35
+ .st0-translate {
36
+ transform: translate(0px, 88px);
37
+ }
38
+ .st0 {
39
+ fill:#FF33CC;
40
+ }
41
+ .st1 {
42
+ fill:#B2F074;
43
+ }
44
+ .st2 {
45
+ opacity:0.64;
46
+ fill:#E4E417;
47
+ enable-background:new;
48
+ }
49
+ .st3 {
50
+ fill:#333333;
51
+ }
52
+ .st4 {
53
+ font-family:Asap, sans-serif;
54
+ }
55
+ .st5 {
56
+ font-size:32px;
57
+ }
58
+ .st6 {
59
+ fill:#F15A24;
60
+ }
61
+ .st7 {
62
+ fill:#66FFFF;
63
+ stroke:#000000;
64
+ stroke-width:3;
65
+ }
66
+ </style>