@abi-software/flatmapvuer 0.4.1-beta.1 → 0.4.1-beta.3
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/flatmapvuer.common.js +2913 -3332
- package/dist/flatmapvuer.common.js.map +1 -1
- package/dist/flatmapvuer.css +1 -1
- package/dist/flatmapvuer.umd.js +2913 -3332
- package/dist/flatmapvuer.umd.js.map +1 -1
- package/dist/flatmapvuer.umd.min.js +2 -3
- package/dist/flatmapvuer.umd.min.js.map +1 -1
- package/package-lock.json +22 -4
- package/package.json +2 -2
- package/src/App.vue +1 -1
- package/src/components/FlatmapVuer.vue +15 -8
- package/src/components/SelectionsGroup.vue +2 -2
- package/src/services/flatmapQueries.js +174 -122
package/package-lock.json
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "0.4.1-beta.
|
|
3
|
+
"version": "0.4.1-beta.3",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@abi-software/flatmap-viewer": {
|
|
8
|
-
"version": "2.2
|
|
9
|
-
"resolved": "https://registry.npmjs.org/@abi-software/flatmap-viewer/-/flatmap-viewer-2.2
|
|
10
|
-
"integrity": "sha512-
|
|
8
|
+
"version": "2.3.2-b.4",
|
|
9
|
+
"resolved": "https://registry.npmjs.org/@abi-software/flatmap-viewer/-/flatmap-viewer-2.3.2-b.4.tgz",
|
|
10
|
+
"integrity": "sha512-2CNV160FBZZ0ERcaBwEJJERG1L4ZsWHnJuSkfeZDYbmX3HgeYBC9NaNwaYCVte2hyxUtlyzBAegRyTUUSZc5sA==",
|
|
11
11
|
"requires": {
|
|
12
12
|
"@babel/runtime": "^7.10.4",
|
|
13
|
+
"@fortawesome/fontawesome-free": "^6.4.0",
|
|
13
14
|
"@turf/area": "^6.0.1",
|
|
14
15
|
"@turf/bbox": "^6.0.1",
|
|
15
16
|
"@turf/helpers": "^6.1.4",
|
|
16
17
|
"@turf/projection": "^6.5.0",
|
|
17
18
|
"bezier-js": "^6.1.0",
|
|
19
|
+
"html-es6cape": "^2.0.2",
|
|
20
|
+
"jspanel4": "^4.16.1",
|
|
18
21
|
"maplibre-gl": ">=2.4.0",
|
|
19
22
|
"minisearch": "^2.2.1",
|
|
20
23
|
"polylabel": "^1.1.0"
|
|
@@ -1200,6 +1203,11 @@
|
|
|
1200
1203
|
"to-fast-properties": "^2.0.0"
|
|
1201
1204
|
}
|
|
1202
1205
|
},
|
|
1206
|
+
"@fortawesome/fontawesome-free": {
|
|
1207
|
+
"version": "6.4.0",
|
|
1208
|
+
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz",
|
|
1209
|
+
"integrity": "sha512-0NyytTlPJwB/BF5LtRV8rrABDbe3TdTXqNB3PdZ+UUUZAEIrdOJdmABqKjt4AXwIoJNaRVVZEXxpNrqvE1GAYQ=="
|
|
1210
|
+
},
|
|
1203
1211
|
"@hapi/address": {
|
|
1204
1212
|
"version": "2.1.4",
|
|
1205
1213
|
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
|
|
@@ -6710,6 +6718,11 @@
|
|
|
6710
6718
|
"integrity": "sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA==",
|
|
6711
6719
|
"dev": true
|
|
6712
6720
|
},
|
|
6721
|
+
"html-es6cape": {
|
|
6722
|
+
"version": "2.0.2",
|
|
6723
|
+
"resolved": "https://registry.npmjs.org/html-es6cape/-/html-es6cape-2.0.2.tgz",
|
|
6724
|
+
"integrity": "sha512-utzhH8rq2VABdW1LsPdv5tmxeMNOtP83If0jKCa79xPBgLWfcMvdf9K+EZoxJ5P7KioCxTs6WBnSDWLQHJ2lWA=="
|
|
6725
|
+
},
|
|
6713
6726
|
"html-minifier": {
|
|
6714
6727
|
"version": "3.5.21",
|
|
6715
6728
|
"resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.21.tgz",
|
|
@@ -7793,6 +7806,11 @@
|
|
|
7793
7806
|
"graceful-fs": "^4.1.6"
|
|
7794
7807
|
}
|
|
7795
7808
|
},
|
|
7809
|
+
"jspanel4": {
|
|
7810
|
+
"version": "4.16.1",
|
|
7811
|
+
"resolved": "https://registry.npmjs.org/jspanel4/-/jspanel4-4.16.1.tgz",
|
|
7812
|
+
"integrity": "sha512-j6Vb565tSK9pOXBN0NgORjhOKKAzsO/1VbGyz1jv7anb9gtdSwUIX6IKXTtyRd/gU9kQv3TFhYRfto5yLvGLbA=="
|
|
7813
|
+
},
|
|
7796
7814
|
"jsprim": {
|
|
7797
7815
|
"version": "1.4.2",
|
|
7798
7816
|
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "0.4.1-beta.
|
|
3
|
+
"version": "0.4.1-beta.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/flatmapvuer.common.js",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"lint": "vue-cli-service lint"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@abi-software/flatmap-viewer": "^2.2
|
|
25
|
+
"@abi-software/flatmap-viewer": "^2.3.2-b.4",
|
|
26
26
|
"@abi-software/svg-sprite": "^0.1.14",
|
|
27
27
|
"core-js": "^3.3.2",
|
|
28
28
|
"css-element-queries": "^1.2.2",
|
package/src/App.vue
CHANGED
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
v-if="isFC && systems && systems.length > 0"
|
|
156
156
|
title="Systems"
|
|
157
157
|
labelKey="name"
|
|
158
|
-
identifierKey="
|
|
158
|
+
identifierKey="id"
|
|
159
159
|
:selections="systems"
|
|
160
160
|
colourStyle="background"
|
|
161
161
|
@changed="systemSelected"
|
|
@@ -173,6 +173,7 @@
|
|
|
173
173
|
ref="centrelinesSelection"
|
|
174
174
|
key="centrelinesSelection"
|
|
175
175
|
/>
|
|
176
|
+
<!--
|
|
176
177
|
<selections-group
|
|
177
178
|
v-if="isFC && sckanDisplay && sckanDisplay.length > 0"
|
|
178
179
|
title="SCKAN"
|
|
@@ -195,6 +196,7 @@
|
|
|
195
196
|
ref="layersSelection"
|
|
196
197
|
key="layersSelection"
|
|
197
198
|
/>
|
|
199
|
+
-->
|
|
198
200
|
<selections-group
|
|
199
201
|
v-if="pathways && pathways.length > 0"
|
|
200
202
|
title="Pathways"
|
|
@@ -296,7 +298,7 @@ import {
|
|
|
296
298
|
import lang from "element-ui/lib/locale/lang/en";
|
|
297
299
|
import locale from "element-ui/lib/locale";
|
|
298
300
|
import flatmapMarker from "../icons/flatmap-marker";
|
|
299
|
-
import {FlatmapQueries} from "../services/flatmapQueries";
|
|
301
|
+
import {FlatmapQueries} from "../services/flatmapQueries.js";
|
|
300
302
|
|
|
301
303
|
locale.use(lang);
|
|
302
304
|
Vue.use(Col);
|
|
@@ -491,9 +493,9 @@ export default {
|
|
|
491
493
|
// checkNeuronClicked shows a neuron path pop up if a path was recently clicked
|
|
492
494
|
checkAndCreatePopups: async function(data) {
|
|
493
495
|
// Call flatmap database to get the connection data
|
|
494
|
-
let
|
|
495
|
-
if(!
|
|
496
|
-
if(data.feature.hyperlinks){
|
|
496
|
+
let results = await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(data)
|
|
497
|
+
if(!results){
|
|
498
|
+
if(data.feature.hyperlinks && data.feature.hyperlinks.length > 0){
|
|
497
499
|
this.resourceForTooltip = data.resource[0];
|
|
498
500
|
this.createTooltipFromNeuronCuration(data);
|
|
499
501
|
}
|
|
@@ -773,7 +775,8 @@ export default {
|
|
|
773
775
|
this.backgroundChangeCallback(this.currentBackground);
|
|
774
776
|
this.pathways = this.mapImp.pathTypes();
|
|
775
777
|
this.mapImp.enableCentrelines(false);
|
|
776
|
-
|
|
778
|
+
//Disable layers for now
|
|
779
|
+
//this.layers = this.mapImp.getLayers();
|
|
777
780
|
this.systems = this.mapImp.getSystems();
|
|
778
781
|
this.addResizeButtonToMinimap();
|
|
779
782
|
this.loading = false;
|
|
@@ -929,7 +932,8 @@ export default {
|
|
|
929
932
|
centreLines: [
|
|
930
933
|
{
|
|
931
934
|
label: "Display Nerves",
|
|
932
|
-
key: "centrelines"
|
|
935
|
+
key: "centrelines",
|
|
936
|
+
enabled: false
|
|
933
937
|
}
|
|
934
938
|
],
|
|
935
939
|
systems: [],
|
|
@@ -979,7 +983,8 @@ export default {
|
|
|
979
983
|
const flatmap = require("@abi-software/flatmap-viewer");
|
|
980
984
|
this.mapManager = new flatmap.MapManager(this.flatmapAPI);
|
|
981
985
|
if (this.renderAtMounted) this.createFlatmap();
|
|
982
|
-
this.flatmapQueries = new FlatmapQueries(
|
|
986
|
+
this.flatmapQueries = new FlatmapQueries();
|
|
987
|
+
this.flatmapQueries.initialise(this.sparcAPI, this.flatmapAPI);
|
|
983
988
|
}
|
|
984
989
|
};
|
|
985
990
|
</script>
|
|
@@ -1068,6 +1073,8 @@ export default {
|
|
|
1068
1073
|
border: 1px solid rgb(220, 223, 230);
|
|
1069
1074
|
padding-bottom: 16px;
|
|
1070
1075
|
background: #ffffff;
|
|
1076
|
+
overflow-x: hidden;
|
|
1077
|
+
scrollbar-width: thin;
|
|
1071
1078
|
|
|
1072
1079
|
&::-webkit-scrollbar {
|
|
1073
1080
|
width: 4px;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
class="my-checkbox"
|
|
28
28
|
:label="item[identifierKey]"
|
|
29
29
|
@change="visibilityToggle(item[identifierKey], $event)"
|
|
30
|
-
:checked="!(
|
|
30
|
+
:checked="!('enabled' in item) || (item.enabled === true)">
|
|
31
31
|
<el-row class="checkbox-row">
|
|
32
32
|
<el-col :span="4">
|
|
33
33
|
<div class="path-visual" :style="getLineStyles(item)"></div>
|
|
@@ -76,7 +76,7 @@ export default {
|
|
|
76
76
|
this.checkAll = true;
|
|
77
77
|
this.checkedItems = [];
|
|
78
78
|
this.selections.forEach(item => {
|
|
79
|
-
if (!(
|
|
79
|
+
if (!('enabled' in item) || item.enabled === true) {
|
|
80
80
|
this.checkedItems.push(item[this.identifierKey]);
|
|
81
81
|
} else {
|
|
82
82
|
this.checkAll = false;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
2
|
// remove duplicates by stringifying the objects
|
|
3
|
-
const removeDuplicates = function
|
|
4
|
-
return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(e => JSON.parse(e))
|
|
3
|
+
const removeDuplicates = function(arrayOfAnything){
|
|
4
|
+
return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(e => JSON.parse(e))
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
const inArray = function
|
|
7
|
+
const inArray = function(ar1, ar2){
|
|
8
8
|
let as1 = JSON.stringify(ar1)
|
|
9
9
|
let as2 = JSON.stringify(ar2)
|
|
10
10
|
return as1.indexOf(as2) !== -1
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
let FlatmapQueries = function(){
|
|
14
|
+
|
|
15
|
+
this.initialise = function(sparcApi, flatmapApi){
|
|
16
|
+
this.sparcApi = sparcApi
|
|
17
|
+
this.flatmapApi = flatmapApi
|
|
18
|
+
this.destinations = []
|
|
19
|
+
this.origins = []
|
|
20
|
+
this.components = []
|
|
21
|
+
this.uberons = []
|
|
22
|
+
this.urls = []
|
|
23
|
+
this.controller = undefined
|
|
24
|
+
this.getOrganCuries().then(uberons=>{
|
|
25
|
+
this.uberons = uberons
|
|
26
|
+
this.createLabelLookup(uberons).then(lookUp=>{
|
|
27
|
+
this.lookUp = lookUp
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.createTooltipData = function (eventData) {
|
|
24
33
|
let tooltipData = {
|
|
25
|
-
destinations: this.destinations,
|
|
34
|
+
destinations: this.destinations,
|
|
26
35
|
origins: this.origins,
|
|
27
36
|
components: this.components,
|
|
28
37
|
destinationsWithDatasets: this.destinationsWithDatasets,
|
|
@@ -30,32 +39,43 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
30
39
|
componentsWithDatasets: this.componentsWithDatasets,
|
|
31
40
|
title: eventData.label,
|
|
32
41
|
featureId: eventData.resource,
|
|
33
|
-
hyperlinks: eventData.feature.hyperlinks ? eventData.feature.hyperlinks : this.urls.map(url
|
|
42
|
+
hyperlinks: eventData.feature.hyperlinks ? eventData.feature.hyperlinks : this.urls.map(url=>({url: url, id: "pubmed"})),
|
|
34
43
|
}
|
|
35
44
|
return tooltipData
|
|
36
45
|
}
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
return new Promise(resolve
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
this.getOrganCuries = function(){
|
|
48
|
+
return new Promise(resolve=> {
|
|
49
|
+
fetch(`${this.sparcAPI}get-organ-curies/`)
|
|
50
|
+
.then(response=>response.json())
|
|
51
|
+
.then(data=>{
|
|
52
|
+
resolve(data.uberon.array)
|
|
53
|
+
})
|
|
45
54
|
})
|
|
46
55
|
}
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
this.createComponentsLabelList = function(components, lookUp){
|
|
58
|
+
let labelList = []
|
|
59
|
+
components.forEach(n=>{
|
|
60
|
+
labelList.push(this.createLabelFromNeuralNode(n[0]), lookUp)
|
|
61
|
+
if (n.length === 2){
|
|
62
|
+
labelList.push(this.createLabelFromNeuralNode(n[1]), lookUp)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
return labelList
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.createLabelLookup = function(uberons) {
|
|
69
|
+
return new Promise(resolve=> {
|
|
50
70
|
let uberonMap = {}
|
|
51
|
-
const data = { sql: buildLabelSqlStatement(uberons)
|
|
71
|
+
const data = { sql: this.buildLabelSqlStatement(uberons)}
|
|
52
72
|
fetch(`${this.flatmapApi}knowledge/query/`, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify(data),
|
|
78
|
+
})
|
|
59
79
|
.then(response => response.json())
|
|
60
80
|
.then(payload => {
|
|
61
81
|
const entity = payload.keys.indexOf("entity");
|
|
@@ -65,20 +85,12 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
65
85
|
uberonMap[pair[entity]] = pair[label];
|
|
66
86
|
});
|
|
67
87
|
}
|
|
68
|
-
|
|
88
|
+
resolve(uberonMap)
|
|
69
89
|
})
|
|
70
90
|
})
|
|
71
91
|
}
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
getOrganCuries().then(uberons => {
|
|
75
|
-
this.uberons = uberons
|
|
76
|
-
createLabelLookup(uberons).then(lookUp => {
|
|
77
|
-
this.lookUp = lookUp
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const buildConnectivitySqlStatement = (keastIds) =>{
|
|
93
|
+
this.buildConnectivitySqlStatement = function (keastIds) {
|
|
82
94
|
let sql = 'select knowledge from knowledge where entity in ('
|
|
83
95
|
if (keastIds.length === 1) {
|
|
84
96
|
sql += `'${keastIds[0]}')`
|
|
@@ -90,7 +102,7 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
90
102
|
return sql
|
|
91
103
|
}
|
|
92
104
|
|
|
93
|
-
|
|
105
|
+
this.buildLabelSqlStatement = function (uberons) {
|
|
94
106
|
let sql = 'select entity, label from labels where entity in ('
|
|
95
107
|
if (uberons.length === 1) {
|
|
96
108
|
sql += `'${uberons[0]}')`
|
|
@@ -102,7 +114,7 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
102
114
|
return sql
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
|
|
117
|
+
this.findAllIdsFromConnectivity = function (connectivity) {
|
|
106
118
|
let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
|
|
107
119
|
let nodes = [...new Set(dnodes)] // remove duplicates
|
|
108
120
|
let found = []
|
|
@@ -116,52 +128,89 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
116
128
|
return [... new Set(found.flat())]
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
this.flattenConntectivity = function (connectivity) {
|
|
132
|
+
let dnodes = connectivity.flat() // get nodes from edgelist
|
|
133
|
+
let nodes = [...new Set(dnodes)] // remove duplicates
|
|
134
|
+
let found = []
|
|
135
|
+
nodes.forEach(n => {
|
|
136
|
+
if (Array.isArray(n)) {
|
|
137
|
+
found.push(n.flat())
|
|
138
|
+
} else {
|
|
139
|
+
found.push(n)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
return found.flat()
|
|
143
|
+
}
|
|
122
144
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
145
|
+
this.findComponents = function (connectivity) {
|
|
146
|
+
let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
|
|
147
|
+
let nodes = removeDuplicates(dnodes)
|
|
126
148
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
let found = []
|
|
150
|
+
let terminal = false
|
|
151
|
+
nodes.forEach(node => {
|
|
152
|
+
terminal = false
|
|
153
|
+
// Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
|
|
154
|
+
if (inArray(connectivity.axons, node)) {
|
|
155
|
+
terminal = true
|
|
156
|
+
}
|
|
157
|
+
if (inArray(connectivity.dendrites, node)) {
|
|
158
|
+
terminal = true
|
|
159
|
+
}
|
|
160
|
+
if (!terminal) {
|
|
161
|
+
found.push(node)
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
return found
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
this.retrieveFlatmapKnowledgeForEvent = async function(eventData){
|
|
169
|
+
// check if there is an existing query
|
|
170
|
+
if (this.controller) this.controller.abort();
|
|
171
|
+
|
|
172
|
+
// set up the abort controller
|
|
173
|
+
this.controller = new AbortController();
|
|
174
|
+
const signal = this.controller.signal;
|
|
175
|
+
|
|
176
|
+
const keastIds = eventData.resource
|
|
177
|
+
this.destinations = []
|
|
178
|
+
this.origins = []
|
|
179
|
+
this.components = []
|
|
180
|
+
if (!keastIds || keastIds.length == 0) return
|
|
181
|
+
const data = { sql: this.buildConnectivitySqlStatement(keastIds)};
|
|
182
|
+
let prom1 = new Promise(resolve=>{
|
|
183
|
+
fetch(`${this.flatmapApi}knowledge/query/`, {
|
|
184
|
+
method: 'POST',
|
|
185
|
+
headers: {
|
|
186
|
+
'Content-Type': 'application/json',
|
|
187
|
+
},
|
|
188
|
+
body: JSON.stringify(data),
|
|
189
|
+
signal: signal
|
|
190
|
+
})
|
|
142
191
|
.then(response => response.json())
|
|
143
192
|
.then(data => {
|
|
144
|
-
if
|
|
193
|
+
if(this.connectivityExists(data)){
|
|
145
194
|
let connectivity = JSON.parse(data.values[0][0])
|
|
146
|
-
processConnectivity(connectivity).then(()
|
|
195
|
+
this.processConnectivity(connectivity).then(()=>{
|
|
147
196
|
resolve(true)
|
|
148
197
|
})
|
|
149
198
|
} else {
|
|
150
199
|
console.log('No connectivity data found')
|
|
151
|
-
resolve(
|
|
200
|
+
resolve(false)
|
|
152
201
|
}
|
|
153
202
|
})
|
|
154
203
|
.catch((error) => {
|
|
155
204
|
console.error('Error:', error);
|
|
156
205
|
resolve(false)
|
|
157
206
|
})
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
207
|
+
})
|
|
208
|
+
let prom2 = this.pubmedQueryOnIds(eventData)
|
|
209
|
+
let results = await Promise.all([prom1, prom2])
|
|
210
|
+
return results.every(Boolean)
|
|
162
211
|
}
|
|
163
212
|
|
|
164
|
-
|
|
213
|
+
this.connectivityExists = function(data){
|
|
165
214
|
if (data.values && data.values.length > 0 && JSON.parse(data.values[0][0]).connectivity && JSON.parse(data.values[0][0]).connectivity.length > 0) {
|
|
166
215
|
return true
|
|
167
216
|
} else {
|
|
@@ -169,12 +218,12 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
169
218
|
}
|
|
170
219
|
}
|
|
171
220
|
|
|
172
|
-
|
|
221
|
+
this.createLabelFromNeuralNode = function(node, lookUp){
|
|
173
222
|
let label = lookUp[node[0]]
|
|
174
|
-
if (node.length === 2 && node[1].length > 0)
|
|
175
|
-
node[1].forEach(n
|
|
176
|
-
if (lookUp[n] == undefined)
|
|
177
|
-
label += `, ${n}`
|
|
223
|
+
if (node.length === 2 && node[1].length > 0){
|
|
224
|
+
node[1].forEach(n=>{
|
|
225
|
+
if (lookUp[n] == undefined){
|
|
226
|
+
label += `, ${n}`
|
|
178
227
|
} else {
|
|
179
228
|
label += `, ${lookUp[n]}`
|
|
180
229
|
}
|
|
@@ -183,12 +232,12 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
183
232
|
return label
|
|
184
233
|
}
|
|
185
234
|
|
|
186
|
-
|
|
187
|
-
|
|
235
|
+
this.flattenAndFindDatasets = function(components, axons, dendrites){
|
|
236
|
+
|
|
188
237
|
// process the nodes for finding datasets (Note this is not critical to the tooltip, only for the 'search on components' button)
|
|
189
|
-
let componentsFlat = flattenConntectivity(components)
|
|
190
|
-
let axonsFlat = flattenConntectivity(axons)
|
|
191
|
-
let dendritesFlat = flattenConntectivity(dendrites)
|
|
238
|
+
let componentsFlat = this.flattenConntectivity(components)
|
|
239
|
+
let axonsFlat = this.flattenConntectivity(axons)
|
|
240
|
+
let dendritesFlat = this.flattenConntectivity(dendrites)
|
|
192
241
|
|
|
193
242
|
// Filter for the anatomy which is annotated on datasets
|
|
194
243
|
this.destinationsWithDatasets = this.uberons.filter(ub => axonsFlat.indexOf(ub.id) !== -1)
|
|
@@ -196,36 +245,36 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
196
245
|
this.componentsWithDatasets = this.uberons.filter(ub => componentsFlat.indexOf(ub.id) !== -1)
|
|
197
246
|
}
|
|
198
247
|
|
|
199
|
-
|
|
200
|
-
return new Promise(resolve
|
|
248
|
+
this.processConnectivity = function(connectivity){
|
|
249
|
+
return new Promise (resolve=>{
|
|
201
250
|
|
|
202
251
|
// Filter the origin and destinations from components
|
|
203
|
-
let components = findComponents(connectivity)
|
|
252
|
+
let components = this.findComponents(connectivity)
|
|
204
253
|
|
|
205
254
|
// Remove duplicates
|
|
206
255
|
let axons = removeDuplicates(connectivity.axons)
|
|
207
256
|
let dendrites = removeDuplicates(connectivity.dendrites)
|
|
208
257
|
|
|
209
258
|
// Create list of ids to get labels for
|
|
210
|
-
let conIds = findAllIdsFromConnectivity(connectivity)
|
|
259
|
+
let conIds = this.findAllIdsFromConnectivity(connectivity)
|
|
211
260
|
|
|
212
261
|
// Create readable labels from the nodes. Setting this to 'this.origins' updates the display
|
|
213
|
-
createLabelLookup(conIds).then(lookUp
|
|
214
|
-
this.destinations = axons.map(a
|
|
215
|
-
this.origins = dendrites.map(d
|
|
216
|
-
this.components = components.map(c
|
|
217
|
-
flattenAndFindDatasets(components, axons, dendrites)
|
|
262
|
+
this.createLabelLookup(conIds).then(lookUp=>{
|
|
263
|
+
this.destinations = axons.map(a=>this.createLabelFromNeuralNode(a,lookUp))
|
|
264
|
+
this.origins = dendrites.map(d=>this.createLabelFromNeuralNode(d,lookUp))
|
|
265
|
+
this.components = components.map(c=>this.createLabelFromNeuralNode(c, lookUp))
|
|
266
|
+
this.flattenAndFindDatasets(components, axons, dendrites)
|
|
218
267
|
resolve(true)
|
|
219
268
|
})
|
|
220
269
|
})
|
|
221
270
|
}
|
|
222
271
|
|
|
223
|
-
|
|
272
|
+
this.flattenConntectivity = function(connectivity){
|
|
224
273
|
let dnodes = connectivity.flat() // get nodes from edgelist
|
|
225
274
|
let nodes = [...new Set(dnodes)] // remove duplicates
|
|
226
275
|
let found = []
|
|
227
|
-
nodes.forEach(n
|
|
228
|
-
if (Array.isArray(n))
|
|
276
|
+
nodes.forEach(n=>{
|
|
277
|
+
if (Array.isArray(n)){
|
|
229
278
|
found.push(n.flat())
|
|
230
279
|
} else {
|
|
231
280
|
found.push(n)
|
|
@@ -234,22 +283,22 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
234
283
|
return found.flat()
|
|
235
284
|
}
|
|
236
285
|
|
|
237
|
-
|
|
286
|
+
this.findComponents = function(connectivity){
|
|
238
287
|
let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
|
|
239
288
|
let nodes = removeDuplicates(dnodes)
|
|
240
289
|
|
|
241
290
|
let found = []
|
|
242
291
|
let terminal = false
|
|
243
|
-
nodes.forEach(node
|
|
292
|
+
nodes.forEach(node=>{
|
|
244
293
|
terminal = false
|
|
245
294
|
// Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
|
|
246
|
-
if
|
|
295
|
+
if(inArray(connectivity.axons,node)){
|
|
247
296
|
terminal = true
|
|
248
297
|
}
|
|
249
|
-
if
|
|
298
|
+
if(inArray(connectivity.dendrites, node)){
|
|
250
299
|
terminal = true
|
|
251
300
|
}
|
|
252
|
-
if (!terminal)
|
|
301
|
+
if (!terminal){
|
|
253
302
|
found.push(node)
|
|
254
303
|
}
|
|
255
304
|
})
|
|
@@ -257,11 +306,11 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
257
306
|
return found
|
|
258
307
|
}
|
|
259
308
|
|
|
260
|
-
|
|
309
|
+
this.stripPMIDPrefix = function (pubmedId){
|
|
261
310
|
return pubmedId.split(':')[1]
|
|
262
311
|
}
|
|
263
312
|
|
|
264
|
-
|
|
313
|
+
this.buildPubmedSqlStatement = function(keastIds) {
|
|
265
314
|
let sql = 'select distinct publication from publications where entity in ('
|
|
266
315
|
if (keastIds.length === 1) {
|
|
267
316
|
sql += `'${keastIds[0]}')`
|
|
@@ -273,12 +322,12 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
273
322
|
return sql
|
|
274
323
|
}
|
|
275
324
|
|
|
276
|
-
|
|
325
|
+
this.buildPubmedSqlStatementForModels = function(model) {
|
|
277
326
|
return `select distinct publication from publications where entity = '${model}'`
|
|
278
327
|
}
|
|
279
328
|
|
|
280
|
-
|
|
281
|
-
const data = { sql: sql
|
|
329
|
+
this.flatmapQuery = function(sql){
|
|
330
|
+
const data = { sql: sql}
|
|
282
331
|
return fetch(`${this.flatmapApi}knowledge/query/`, {
|
|
283
332
|
method: 'POST',
|
|
284
333
|
headers: {
|
|
@@ -286,43 +335,46 @@ exports.FlatmapQueries = function(sparcApi, flatmapApi) {
|
|
|
286
335
|
},
|
|
287
336
|
body: JSON.stringify(data),
|
|
288
337
|
})
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
338
|
+
.then(response => response.json())
|
|
339
|
+
.catch((error) => {
|
|
340
|
+
console.error('Error:', error)
|
|
341
|
+
})
|
|
293
342
|
}
|
|
294
343
|
|
|
295
|
-
|
|
344
|
+
this.pubmedQueryOnIds = function(eventData){
|
|
296
345
|
const keastIds = eventData.resource
|
|
297
346
|
const source = eventData.feature.source
|
|
298
|
-
if
|
|
299
|
-
const sql = buildPubmedSqlStatement(keastIds)
|
|
300
|
-
return flatmapQuery(sql).then(data
|
|
347
|
+
if(!keastIds || keastIds.length === 0) return
|
|
348
|
+
const sql = this.buildPubmedSqlStatement(keastIds)
|
|
349
|
+
return this.flatmapQuery(sql).then(data=>{
|
|
301
350
|
// Create pubmed url on paths if we have them
|
|
302
|
-
if (data.values.length > 0)
|
|
303
|
-
this.urls = [pubmedSearchUrl(data.values.map(id
|
|
351
|
+
if (data.values.length > 0){
|
|
352
|
+
this.urls = [this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0])))]
|
|
304
353
|
return true
|
|
305
354
|
} else { // Create pubmed url on models
|
|
306
|
-
pubmedQueryOnModels(source).then(()
|
|
355
|
+
this.pubmedQueryOnModels(source).then(()=>{return true})
|
|
307
356
|
}
|
|
357
|
+
return false
|
|
308
358
|
})
|
|
309
359
|
}
|
|
310
360
|
|
|
311
|
-
|
|
312
|
-
return flatmapQuery(buildPubmedSqlStatementForModels(source)).then(data
|
|
313
|
-
if (Array.isArray(data.values) && data.values.length > 0)
|
|
314
|
-
this.urls = [pubmedSearchUrl(data.values.map(id
|
|
361
|
+
this.pubmedQueryOnModels = function(source){
|
|
362
|
+
return this.flatmapQuery(this.buildPubmedSqlStatementForModels(source)).then(data=>{
|
|
363
|
+
if (Array.isArray(data.values) && data.values.length > 0){
|
|
364
|
+
this.urls = [this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0])))]
|
|
315
365
|
} else {
|
|
316
366
|
this.urls = [] // Clears the pubmed search button
|
|
317
|
-
}
|
|
367
|
+
}
|
|
318
368
|
return
|
|
319
369
|
})
|
|
320
370
|
}
|
|
321
371
|
|
|
322
|
-
|
|
372
|
+
this.pubmedSearchUrl = function(ids) {
|
|
323
373
|
let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
|
|
324
374
|
let params = new URLSearchParams()
|
|
325
375
|
params.append('term', ids)
|
|
326
376
|
return url + params.toString()
|
|
327
377
|
}
|
|
328
378
|
}
|
|
379
|
+
|
|
380
|
+
export {FlatmapQueries}
|