@abi-software/flatmapvuer 0.5.9 → 0.6.0-vue3-0
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/babel.config.js +0 -14
- package/dist/favicon.ico +0 -0
- package/dist/flatmapvuer.js +69542 -0
- package/dist/flatmapvuer.umd.cjs +1021 -0
- package/dist/index.html +17 -0
- package/dist/style.css +1 -0
- package/package.json +29 -21
- package/src/App.vue +180 -105
- package/src/assets/styles.scss +2 -3
- package/src/components/AnnotationTool.vue +193 -153
- package/src/components/EventBus.js +3 -3
- package/src/components/ExternalResourceCard.vue +39 -30
- package/src/components/FlatmapVuer.vue +734 -676
- package/src/components/MultiFlatmapVuer.vue +313 -246
- package/src/components/ProvenancePopup.vue +195 -121
- package/src/components/SelectionsGroup.vue +93 -84
- package/src/components/Tooltip.vue +11 -13
- package/src/components/TreeControls.vue +67 -64
- package/src/components/index.js +4 -7
- package/src/components/legends/DynamicLegends.vue +13 -19
- package/src/components/legends/SvgLegends.vue +72 -27
- package/src/components.d.ts +46 -0
- package/src/icons/flatmap-marker.js +1 -1
- package/src/icons/fonts/mapicon-species.eot +0 -0
- package/src/icons/fonts/mapicon-species.svg +0 -0
- package/src/icons/yellowstar.js +2 -2
- package/src/legends/legend.svg +0 -0
- package/src/main.js +2 -6
- package/src/services/flatmapQueries.js +175 -139
- package/vite.config.js +76 -0
- package/vue.config.js +14 -0
- package/CHANGELOG.md +0 -402
- package/dist/demo.html +0 -10
- package/dist/flatmapvuer.common.js +0 -22741
- package/dist/flatmapvuer.common.js.map +0 -1
- package/dist/flatmapvuer.css +0 -1
- package/dist/flatmapvuer.umd.js +0 -22751
- package/dist/flatmapvuer.umd.js.map +0 -1
- package/dist/flatmapvuer.umd.min.js +0 -4
- package/dist/flatmapvuer.umd.min.js.map +0 -1
- package/package-lock.json +0 -18473
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
2
|
// remove duplicates by stringifying the objects
|
|
3
|
-
const removeDuplicates = function(arrayOfAnything){
|
|
4
|
-
return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(
|
|
3
|
+
const removeDuplicates = function (arrayOfAnything) {
|
|
4
|
+
return [...new Set(arrayOfAnything.map((e) => JSON.stringify(e)))].map((e) =>
|
|
5
|
+
JSON.parse(e)
|
|
6
|
+
)
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
const cachedLabels = {}
|
|
9
|
+
const cachedLabels = {}
|
|
8
10
|
|
|
9
|
-
const findTaxonomyLabel = async function(flatmapAPI, taxonomy){
|
|
11
|
+
const findTaxonomyLabel = async function (flatmapAPI, taxonomy) {
|
|
10
12
|
if (cachedLabels && cachedLabels.hasOwnProperty(taxonomy)) {
|
|
11
|
-
return cachedLabels[taxonomy]
|
|
13
|
+
return cachedLabels[taxonomy]
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
return new Promise(resolve=>{
|
|
16
|
+
return new Promise((resolve) => {
|
|
15
17
|
fetch(`${flatmapAPI}knowledge/label/${taxonomy}`, {
|
|
16
18
|
method: 'GET',
|
|
17
19
|
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
20
|
+
.then((response) => response.json())
|
|
21
|
+
.then((data) => {
|
|
22
|
+
let label = data.label
|
|
23
|
+
if (label === 'Mammalia') {
|
|
24
|
+
label = 'Mammalia not otherwise specified'
|
|
25
|
+
}
|
|
26
|
+
cachedLabels[taxonomy] = label
|
|
27
|
+
resolve(label)
|
|
28
|
+
})
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
console.error('Error:', error)
|
|
31
|
+
cachedLabels[taxonomy] = taxonomy
|
|
32
|
+
resolve(taxonomy)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
const inArray = function(ar1, ar2){
|
|
37
|
+
const inArray = function (ar1, ar2) {
|
|
36
38
|
let as1 = JSON.stringify(ar1)
|
|
37
39
|
let as2 = JSON.stringify(ar2)
|
|
38
40
|
return as1.indexOf(as2) !== -1
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
let FlatmapQueries = function(){
|
|
42
|
-
|
|
43
|
-
this.initialise = function(flatmapApi){
|
|
43
|
+
let FlatmapQueries = function () {
|
|
44
|
+
this.initialise = function (flatmapApi) {
|
|
44
45
|
this.flatmapApi = flatmapApi
|
|
45
46
|
this.destinations = []
|
|
46
47
|
this.origins = []
|
|
@@ -53,21 +54,29 @@ let FlatmapQueries = function(){
|
|
|
53
54
|
|
|
54
55
|
this.createTooltipData = async function (eventData) {
|
|
55
56
|
let hyperlinks = []
|
|
56
|
-
if (
|
|
57
|
+
if (
|
|
58
|
+
eventData.feature.hyperlinks &&
|
|
59
|
+
eventData.feature.hyperlinks.length > 0
|
|
60
|
+
) {
|
|
57
61
|
hyperlinks = eventData.feature.hyperlinks
|
|
58
62
|
} else {
|
|
59
|
-
hyperlinks = this.urls.map(url=>({url: url, id:
|
|
63
|
+
hyperlinks = this.urls.map((url) => ({ url: url, id: 'pubmed' }))
|
|
60
64
|
}
|
|
61
|
-
let taxonomyLabel = undefined
|
|
65
|
+
let taxonomyLabel = undefined
|
|
62
66
|
if (eventData.provenanceTaxonomy) {
|
|
63
|
-
taxonomyLabel = []
|
|
67
|
+
taxonomyLabel = []
|
|
64
68
|
for (let i = 0; eventData.provenanceTaxonomy.length > i; i++) {
|
|
65
|
-
taxonomyLabel.push(
|
|
69
|
+
taxonomyLabel.push(
|
|
70
|
+
await findTaxonomyLabel(
|
|
71
|
+
this.flatmapAPI,
|
|
72
|
+
eventData.provenanceTaxonomy[i]
|
|
73
|
+
)
|
|
74
|
+
)
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
let tooltipData = {
|
|
70
|
-
destinations: this.destinations,
|
|
79
|
+
destinations: this.destinations,
|
|
71
80
|
origins: this.origins,
|
|
72
81
|
components: this.components,
|
|
73
82
|
destinationsWithDatasets: this.destinationsWithDatasets,
|
|
@@ -77,48 +86,48 @@ let FlatmapQueries = function(){
|
|
|
77
86
|
featureId: eventData.resource,
|
|
78
87
|
hyperlinks: hyperlinks,
|
|
79
88
|
provenanceTaxonomy: eventData.provenanceTaxonomy,
|
|
80
|
-
provenanceTaxonomyLabel: taxonomyLabel
|
|
89
|
+
provenanceTaxonomyLabel: taxonomyLabel,
|
|
81
90
|
}
|
|
82
91
|
return tooltipData
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
this.createComponentsLabelList = function(components, lookUp){
|
|
94
|
+
this.createComponentsLabelList = function (components, lookUp) {
|
|
86
95
|
let labelList = []
|
|
87
|
-
components.forEach(n=>{
|
|
96
|
+
components.forEach((n) => {
|
|
88
97
|
labelList.push(this.createLabelFromNeuralNode(n[0]), lookUp)
|
|
89
|
-
if (n.length === 2){
|
|
98
|
+
if (n.length === 2) {
|
|
90
99
|
labelList.push(this.createLabelFromNeuralNode(n[1]), lookUp)
|
|
91
100
|
}
|
|
92
101
|
})
|
|
93
102
|
return labelList
|
|
94
103
|
}
|
|
95
104
|
|
|
96
|
-
this.createLabelLookup = function(uberons) {
|
|
97
|
-
return new Promise(resolve=> {
|
|
105
|
+
this.createLabelLookup = function (uberons) {
|
|
106
|
+
return new Promise((resolve) => {
|
|
98
107
|
let uberonMap = {}
|
|
99
108
|
this.uberons = []
|
|
100
|
-
const data = { sql: this.buildLabelSqlStatement(uberons)}
|
|
109
|
+
const data = { sql: this.buildLabelSqlStatement(uberons) }
|
|
101
110
|
fetch(`${this.flatmapApi}knowledge/query/`, {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
.then(response => response.json())
|
|
109
|
-
.then(payload => {
|
|
110
|
-
const entity = payload.keys.indexOf(
|
|
111
|
-
const label = payload.keys.indexOf(
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: {
|
|
113
|
+
'Content-Type': 'application/json',
|
|
114
|
+
},
|
|
115
|
+
body: JSON.stringify(data),
|
|
116
|
+
})
|
|
117
|
+
.then((response) => response.json())
|
|
118
|
+
.then((payload) => {
|
|
119
|
+
const entity = payload.keys.indexOf('entity')
|
|
120
|
+
const label = payload.keys.indexOf('label')
|
|
112
121
|
if (entity > -1 && label > -1) {
|
|
113
|
-
payload.values.forEach(pair => {
|
|
114
|
-
uberonMap[pair[entity]] = pair[label]
|
|
122
|
+
payload.values.forEach((pair) => {
|
|
123
|
+
uberonMap[pair[entity]] = pair[label]
|
|
115
124
|
this.uberons.push({
|
|
116
125
|
id: pair[entity],
|
|
117
|
-
name: pair[label]
|
|
126
|
+
name: pair[label],
|
|
118
127
|
})
|
|
119
|
-
})
|
|
128
|
+
})
|
|
120
129
|
}
|
|
121
|
-
|
|
130
|
+
resolve(uberonMap)
|
|
122
131
|
})
|
|
123
132
|
})
|
|
124
133
|
}
|
|
@@ -151,21 +160,21 @@ let FlatmapQueries = function(){
|
|
|
151
160
|
let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
|
|
152
161
|
let nodes = [...new Set(dnodes)] // remove duplicates
|
|
153
162
|
let found = []
|
|
154
|
-
nodes.forEach(n => {
|
|
163
|
+
nodes.forEach((n) => {
|
|
155
164
|
if (Array.isArray(n)) {
|
|
156
165
|
found.push(n.flat())
|
|
157
166
|
} else {
|
|
158
167
|
found.push(n)
|
|
159
168
|
}
|
|
160
169
|
})
|
|
161
|
-
return [...
|
|
170
|
+
return [...new Set(found.flat())]
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
this.flattenConntectivity = function (connectivity) {
|
|
165
174
|
let dnodes = connectivity.flat() // get nodes from edgelist
|
|
166
175
|
let nodes = [...new Set(dnodes)] // remove duplicates
|
|
167
176
|
let found = []
|
|
168
|
-
nodes.forEach(n => {
|
|
177
|
+
nodes.forEach((n) => {
|
|
169
178
|
if (Array.isArray(n)) {
|
|
170
179
|
found.push(n.flat())
|
|
171
180
|
} else {
|
|
@@ -181,7 +190,7 @@ let FlatmapQueries = function(){
|
|
|
181
190
|
|
|
182
191
|
let found = []
|
|
183
192
|
let terminal = false
|
|
184
|
-
nodes.forEach(node => {
|
|
193
|
+
nodes.forEach((node) => {
|
|
185
194
|
terminal = false
|
|
186
195
|
// Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
|
|
187
196
|
if (inArray(connectivity.axons, node)) {
|
|
@@ -198,34 +207,34 @@ let FlatmapQueries = function(){
|
|
|
198
207
|
return found
|
|
199
208
|
}
|
|
200
209
|
|
|
201
|
-
this.retrieveFlatmapKnowledgeForEvent = async function(eventData){
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
this.retrieveFlatmapKnowledgeForEvent = async function (eventData) {
|
|
211
|
+
// check if there is an existing query
|
|
212
|
+
if (this.controller) this.controller.abort()
|
|
204
213
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
214
|
+
// set up the abort controller
|
|
215
|
+
this.controller = new AbortController()
|
|
216
|
+
const signal = this.controller.signal
|
|
208
217
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.then(response => response.json())
|
|
225
|
-
.then(data => {
|
|
226
|
-
if(this.connectivityExists(data)){
|
|
218
|
+
const keastIds = eventData.resource
|
|
219
|
+
this.destinations = []
|
|
220
|
+
this.origins = []
|
|
221
|
+
this.components = []
|
|
222
|
+
if (!keastIds || keastIds.length == 0) return
|
|
223
|
+
const data = { sql: this.buildConnectivitySqlStatement(keastIds) }
|
|
224
|
+
let prom1 = new Promise((resolve) => {
|
|
225
|
+
fetch(`${this.flatmapApi}knowledge/query/`, {
|
|
226
|
+
method: 'POST',
|
|
227
|
+
headers: {
|
|
228
|
+
'Content-Type': 'application/json',
|
|
229
|
+
},
|
|
230
|
+
body: JSON.stringify(data),
|
|
231
|
+
signal: signal,
|
|
232
|
+
})
|
|
233
|
+
.then((response) => response.json())
|
|
234
|
+
.then((data) => {
|
|
235
|
+
if (this.connectivityExists(data)) {
|
|
227
236
|
let connectivity = JSON.parse(data.values[0][0])
|
|
228
|
-
this.processConnectivity(connectivity).then(()=>{
|
|
237
|
+
this.processConnectivity(connectivity).then(() => {
|
|
229
238
|
resolve(true)
|
|
230
239
|
})
|
|
231
240
|
} else {
|
|
@@ -233,29 +242,34 @@ let FlatmapQueries = function(){
|
|
|
233
242
|
}
|
|
234
243
|
})
|
|
235
244
|
.catch((error) => {
|
|
236
|
-
console.error('Error:', error)
|
|
245
|
+
console.error('Error:', error)
|
|
237
246
|
resolve(false)
|
|
238
247
|
})
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
})
|
|
249
|
+
let prom2 = await this.pubmedQueryOnIds(eventData)
|
|
250
|
+
let results = await Promise.all([prom1, prom2])
|
|
251
|
+
return results
|
|
243
252
|
}
|
|
244
253
|
|
|
245
|
-
this.connectivityExists = function(data){
|
|
246
|
-
if (
|
|
254
|
+
this.connectivityExists = function (data) {
|
|
255
|
+
if (
|
|
256
|
+
data.values &&
|
|
257
|
+
data.values.length > 0 &&
|
|
258
|
+
JSON.parse(data.values[0][0]).connectivity &&
|
|
259
|
+
JSON.parse(data.values[0][0]).connectivity.length > 0
|
|
260
|
+
) {
|
|
247
261
|
return true
|
|
248
262
|
} else {
|
|
249
263
|
return false
|
|
250
264
|
}
|
|
251
265
|
}
|
|
252
266
|
|
|
253
|
-
this.createLabelFromNeuralNode = function(node, lookUp){
|
|
267
|
+
this.createLabelFromNeuralNode = function (node, lookUp) {
|
|
254
268
|
let label = lookUp[node[0]]
|
|
255
|
-
if (node.length === 2 && node[1].length > 0){
|
|
256
|
-
node[1].forEach(n=>{
|
|
257
|
-
if (lookUp[n] == undefined){
|
|
258
|
-
label += `, ${n}`
|
|
269
|
+
if (node.length === 2 && node[1].length > 0) {
|
|
270
|
+
node[1].forEach((n) => {
|
|
271
|
+
if (lookUp[n] == undefined) {
|
|
272
|
+
label += `, ${n}`
|
|
259
273
|
} else {
|
|
260
274
|
label += `, ${lookUp[n]}`
|
|
261
275
|
}
|
|
@@ -264,21 +278,26 @@ let FlatmapQueries = function(){
|
|
|
264
278
|
return label
|
|
265
279
|
}
|
|
266
280
|
|
|
267
|
-
this.flattenAndFindDatasets = function(components, axons, dendrites){
|
|
268
|
-
|
|
281
|
+
this.flattenAndFindDatasets = function (components, axons, dendrites) {
|
|
269
282
|
// process the nodes for finding datasets (Note this is not critical to the tooltip, only for the 'search on components' button)
|
|
270
283
|
let componentsFlat = this.flattenConntectivity(components)
|
|
271
284
|
let axonsFlat = this.flattenConntectivity(axons)
|
|
272
285
|
let dendritesFlat = this.flattenConntectivity(dendrites)
|
|
273
286
|
|
|
274
287
|
// Filter for the anatomy which is annotated on datasets
|
|
275
|
-
this.destinationsWithDatasets = this.uberons.filter(
|
|
276
|
-
|
|
277
|
-
|
|
288
|
+
this.destinationsWithDatasets = this.uberons.filter(
|
|
289
|
+
(ub) => axonsFlat.indexOf(ub.id) !== -1
|
|
290
|
+
)
|
|
291
|
+
this.originsWithDatasets = this.uberons.filter(
|
|
292
|
+
(ub) => dendritesFlat.indexOf(ub.id) !== -1
|
|
293
|
+
)
|
|
294
|
+
this.componentsWithDatasets = this.uberons.filter(
|
|
295
|
+
(ub) => componentsFlat.indexOf(ub.id) !== -1
|
|
296
|
+
)
|
|
278
297
|
}
|
|
279
298
|
|
|
280
|
-
this.processConnectivity = function(connectivity){
|
|
281
|
-
return new Promise
|
|
299
|
+
this.processConnectivity = function (connectivity) {
|
|
300
|
+
return new Promise((resolve) => {
|
|
282
301
|
// Filter the origin and destinations from components
|
|
283
302
|
let components = this.findComponents(connectivity)
|
|
284
303
|
|
|
@@ -287,25 +306,31 @@ let FlatmapQueries = function(){
|
|
|
287
306
|
let dendrites = removeDuplicates(connectivity.dendrites)
|
|
288
307
|
|
|
289
308
|
// Create list of ids to get labels for
|
|
290
|
-
let conIds = this.findAllIdsFromConnectivity(connectivity)
|
|
309
|
+
let conIds = this.findAllIdsFromConnectivity(connectivity)
|
|
291
310
|
|
|
292
311
|
// Create readable labels from the nodes. Setting this to 'this.origins' updates the display
|
|
293
|
-
this.createLabelLookup(conIds).then(lookUp=>{
|
|
294
|
-
this.destinations = axons.map(
|
|
295
|
-
|
|
296
|
-
|
|
312
|
+
this.createLabelLookup(conIds).then((lookUp) => {
|
|
313
|
+
this.destinations = axons.map((a) =>
|
|
314
|
+
this.createLabelFromNeuralNode(a, lookUp)
|
|
315
|
+
)
|
|
316
|
+
this.origins = dendrites.map((d) =>
|
|
317
|
+
this.createLabelFromNeuralNode(d, lookUp)
|
|
318
|
+
)
|
|
319
|
+
this.components = components.map((c) =>
|
|
320
|
+
this.createLabelFromNeuralNode(c, lookUp)
|
|
321
|
+
)
|
|
297
322
|
this.flattenAndFindDatasets(components, axons, dendrites)
|
|
298
323
|
resolve(true)
|
|
299
324
|
})
|
|
300
325
|
})
|
|
301
326
|
}
|
|
302
327
|
|
|
303
|
-
this.flattenConntectivity = function(connectivity){
|
|
328
|
+
this.flattenConntectivity = function (connectivity) {
|
|
304
329
|
let dnodes = connectivity.flat() // get nodes from edgelist
|
|
305
330
|
let nodes = [...new Set(dnodes)] // remove duplicates
|
|
306
331
|
let found = []
|
|
307
|
-
nodes.forEach(n=>{
|
|
308
|
-
if (Array.isArray(n)){
|
|
332
|
+
nodes.forEach((n) => {
|
|
333
|
+
if (Array.isArray(n)) {
|
|
309
334
|
found.push(n.flat())
|
|
310
335
|
} else {
|
|
311
336
|
found.push(n)
|
|
@@ -314,22 +339,22 @@ let FlatmapQueries = function(){
|
|
|
314
339
|
return found.flat()
|
|
315
340
|
}
|
|
316
341
|
|
|
317
|
-
this.findComponents = function(connectivity){
|
|
342
|
+
this.findComponents = function (connectivity) {
|
|
318
343
|
let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
|
|
319
344
|
let nodes = removeDuplicates(dnodes)
|
|
320
345
|
|
|
321
346
|
let found = []
|
|
322
347
|
let terminal = false
|
|
323
|
-
nodes.forEach(node=>{
|
|
348
|
+
nodes.forEach((node) => {
|
|
324
349
|
terminal = false
|
|
325
350
|
// Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
|
|
326
|
-
if(inArray(connectivity.axons,node)){
|
|
351
|
+
if (inArray(connectivity.axons, node)) {
|
|
327
352
|
terminal = true
|
|
328
353
|
}
|
|
329
|
-
if(inArray(connectivity.dendrites, node)){
|
|
354
|
+
if (inArray(connectivity.dendrites, node)) {
|
|
330
355
|
terminal = true
|
|
331
356
|
}
|
|
332
|
-
if (!terminal){
|
|
357
|
+
if (!terminal) {
|
|
333
358
|
found.push(node)
|
|
334
359
|
}
|
|
335
360
|
})
|
|
@@ -337,11 +362,11 @@ let FlatmapQueries = function(){
|
|
|
337
362
|
return found
|
|
338
363
|
}
|
|
339
364
|
|
|
340
|
-
this.stripPMIDPrefix = function (pubmedId){
|
|
365
|
+
this.stripPMIDPrefix = function (pubmedId) {
|
|
341
366
|
return pubmedId.split(':')[1]
|
|
342
367
|
}
|
|
343
368
|
|
|
344
|
-
this.buildPubmedSqlStatement = function(keastIds) {
|
|
369
|
+
this.buildPubmedSqlStatement = function (keastIds) {
|
|
345
370
|
let sql = 'select distinct publication from publications where entity in ('
|
|
346
371
|
if (keastIds.length === 1) {
|
|
347
372
|
sql += `'${keastIds[0]}')`
|
|
@@ -353,12 +378,12 @@ let FlatmapQueries = function(){
|
|
|
353
378
|
return sql
|
|
354
379
|
}
|
|
355
380
|
|
|
356
|
-
this.buildPubmedSqlStatementForModels = function(model) {
|
|
381
|
+
this.buildPubmedSqlStatementForModels = function (model) {
|
|
357
382
|
return `select distinct publication from publications where entity = '${model}'`
|
|
358
383
|
}
|
|
359
384
|
|
|
360
|
-
this.flatmapQuery = function(sql){
|
|
361
|
-
const data = { sql: sql}
|
|
385
|
+
this.flatmapQuery = function (sql) {
|
|
386
|
+
const data = { sql: sql }
|
|
362
387
|
return fetch(`${this.flatmapApi}knowledge/query/`, {
|
|
363
388
|
method: 'POST',
|
|
364
389
|
headers: {
|
|
@@ -366,25 +391,30 @@ let FlatmapQueries = function(){
|
|
|
366
391
|
},
|
|
367
392
|
body: JSON.stringify(data),
|
|
368
393
|
})
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
394
|
+
.then((response) => response.json())
|
|
395
|
+
.catch((error) => {
|
|
396
|
+
console.error('Error:', error)
|
|
397
|
+
})
|
|
373
398
|
}
|
|
374
399
|
// Note that this functin WILL run to the end, as it doesn not catch the second level of promises
|
|
375
|
-
this.pubmedQueryOnIds = function(eventData){
|
|
376
|
-
return new Promise(resolve=>{
|
|
400
|
+
this.pubmedQueryOnIds = function (eventData) {
|
|
401
|
+
return new Promise((resolve) => {
|
|
377
402
|
const keastIds = eventData.resource
|
|
378
403
|
const source = eventData.feature.source
|
|
379
|
-
if(!keastIds || keastIds.length === 0) return
|
|
404
|
+
if (!keastIds || keastIds.length === 0) return
|
|
380
405
|
const sql = this.buildPubmedSqlStatement(keastIds)
|
|
381
|
-
this.flatmapQuery(sql).then(data=>{
|
|
406
|
+
this.flatmapQuery(sql).then((data) => {
|
|
382
407
|
// Create pubmed url on paths if we have them
|
|
383
|
-
if (data.values.length > 0){
|
|
384
|
-
this.urls = [
|
|
408
|
+
if (data.values.length > 0) {
|
|
409
|
+
this.urls = [
|
|
410
|
+
this.pubmedSearchUrl(
|
|
411
|
+
data.values.map((id) => this.stripPMIDPrefix(id[0]))
|
|
412
|
+
),
|
|
413
|
+
]
|
|
385
414
|
resolve(true)
|
|
386
|
-
} else {
|
|
387
|
-
|
|
415
|
+
} else {
|
|
416
|
+
// Create pubmed url on models
|
|
417
|
+
this.pubmedQueryOnModels(source).then((result) => {
|
|
388
418
|
resolve(result)
|
|
389
419
|
})
|
|
390
420
|
}
|
|
@@ -392,19 +422,25 @@ let FlatmapQueries = function(){
|
|
|
392
422
|
})
|
|
393
423
|
}
|
|
394
424
|
|
|
395
|
-
this.pubmedQueryOnModels = function(source){
|
|
396
|
-
return this.flatmapQuery(
|
|
397
|
-
|
|
398
|
-
|
|
425
|
+
this.pubmedQueryOnModels = function (source) {
|
|
426
|
+
return this.flatmapQuery(
|
|
427
|
+
this.buildPubmedSqlStatementForModels(source)
|
|
428
|
+
).then((data) => {
|
|
429
|
+
if (Array.isArray(data.values) && data.values.length > 0) {
|
|
430
|
+
this.urls = [
|
|
431
|
+
this.pubmedSearchUrl(
|
|
432
|
+
data.values.map((id) => this.stripPMIDPrefix(id[0]))
|
|
433
|
+
),
|
|
434
|
+
]
|
|
399
435
|
return true
|
|
400
436
|
} else {
|
|
401
|
-
this.urls = [] // Clears the pubmed search button
|
|
402
|
-
}
|
|
437
|
+
this.urls = [] // Clears the pubmed search button
|
|
438
|
+
}
|
|
403
439
|
return false
|
|
404
440
|
})
|
|
405
441
|
}
|
|
406
442
|
|
|
407
|
-
this.pubmedSearchUrl = function(ids) {
|
|
443
|
+
this.pubmedSearchUrl = function (ids) {
|
|
408
444
|
let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
|
|
409
445
|
let params = new URLSearchParams()
|
|
410
446
|
params.append('term', ids)
|
|
@@ -412,4 +448,4 @@ let FlatmapQueries = function(){
|
|
|
412
448
|
}
|
|
413
449
|
}
|
|
414
450
|
|
|
415
|
-
export {FlatmapQueries, findTaxonomyLabel}
|
|
451
|
+
export { FlatmapQueries, findTaxonomyLabel }
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
const pathSrc = path.resolve(__dirname, "./src");
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
import vue from '@vitejs/plugin-vue'
|
|
5
|
+
import Components from 'unplugin-vue-components/vite'
|
|
6
|
+
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
7
|
+
import Unocss from 'unocss/vite'
|
|
8
|
+
import {
|
|
9
|
+
presetAttributify,
|
|
10
|
+
presetIcons,
|
|
11
|
+
presetUno,
|
|
12
|
+
transformerDirectives,
|
|
13
|
+
transformerVariantGroup,
|
|
14
|
+
} from 'unocss'
|
|
15
|
+
|
|
16
|
+
// https://vitejs.dev/config/
|
|
17
|
+
export default defineConfig(({ command, mode }) => {
|
|
18
|
+
const config = {
|
|
19
|
+
css: {
|
|
20
|
+
preprocessorOptions: {
|
|
21
|
+
scss: {
|
|
22
|
+
additionalData: `@use '${pathSrc}/assets/styles' as *;`
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
plugins: [
|
|
27
|
+
vue({
|
|
28
|
+
template: {
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
isCustomElement: (tag) => ['bx:grid'].includes(tag),
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
Components({
|
|
35
|
+
// allow auto load markdown components under `./src/components/`
|
|
36
|
+
extensions: ['vue', 'md'],
|
|
37
|
+
// allow auto import and register components used in markdown
|
|
38
|
+
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
39
|
+
resolvers: [
|
|
40
|
+
ElementPlusResolver({
|
|
41
|
+
importStyle: 'sass',
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
dts: 'src/components.d.ts',
|
|
45
|
+
}),
|
|
46
|
+
|
|
47
|
+
// https://github.com/antfu/unocss
|
|
48
|
+
// see unocss.config.ts for config
|
|
49
|
+
],
|
|
50
|
+
build: {
|
|
51
|
+
lib: {
|
|
52
|
+
entry: path.resolve(__dirname, "./src/components/index.js"),
|
|
53
|
+
name: "FlatmapVuer",
|
|
54
|
+
fileName: 'flatmapvuer',
|
|
55
|
+
},
|
|
56
|
+
rollupOptions: {
|
|
57
|
+
external: ["vue"],
|
|
58
|
+
output: {
|
|
59
|
+
globals: {
|
|
60
|
+
vue: "Vue",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if (command === 'serve') {
|
|
68
|
+
config.server = {
|
|
69
|
+
port: 8082,
|
|
70
|
+
};
|
|
71
|
+
} else if (command === "build-bundle") {
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
return config;
|
|
76
|
+
})
|
package/vue.config.js
CHANGED
|
@@ -7,6 +7,7 @@ module.exports = {
|
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
9
|
chainWebpack: config => {
|
|
10
|
+
config.resolve.alias.set('vue', '@vue/compat')
|
|
10
11
|
const fontsRule = config.module.rule('fonts')
|
|
11
12
|
fontsRule.uses.clear()
|
|
12
13
|
config.module
|
|
@@ -19,6 +20,19 @@ module.exports = {
|
|
|
19
20
|
return options
|
|
20
21
|
})
|
|
21
22
|
.end()
|
|
23
|
+
config.module
|
|
24
|
+
.rule('vue')
|
|
25
|
+
.use('vue-loader')
|
|
26
|
+
.tap((options) => {
|
|
27
|
+
return {
|
|
28
|
+
...options,
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
compatConfig: {
|
|
31
|
+
MODE: 3
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
22
36
|
},
|
|
23
37
|
css: {
|
|
24
38
|
//Import variables into all stylesheets.
|