@abi-software/map-utilities 1.1.3-beta.1 → 1.2.0-beta.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/dist/map-utilities.js +6910 -23297
- package/dist/map-utilities.umd.cjs +41 -61
- package/dist/style.css +1 -1
- package/package.json +1 -2
- package/src/App.vue +8 -30
- package/src/components/TreeControls/TreeControls.vue +18 -1
- package/src/components/index.js +1 -9
- package/src/components.d.ts +0 -1
- package/src/components/ConnectivityGraph/ConnectivityGraph.vue +0 -230
- package/src/components/ConnectivityGraph/graph.js +0 -249
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/map-utilities",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/*",
|
|
6
6
|
"src/*",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@abi-software/svg-sprite": "^1.0.1",
|
|
33
33
|
"@element-plus/icons-vue": "^2.3.1",
|
|
34
|
-
"cytoscape": "^3.30.2",
|
|
35
34
|
"element-plus": "2.8.4",
|
|
36
35
|
"mitt": "^3.0.1",
|
|
37
36
|
"vue": "^3.4.21"
|
package/src/App.vue
CHANGED
|
@@ -26,6 +26,7 @@ const hoverVisibilities = [
|
|
|
26
26
|
{ value: false, refs: "toolbarPopover", ref: "polygonPopover" },
|
|
27
27
|
{ value: false, refs: "toolbarPopover", ref: "connectionPopover" },
|
|
28
28
|
];
|
|
29
|
+
const filterText = ref("")
|
|
29
30
|
const isFlatmap = ref(true);
|
|
30
31
|
const appRef = ref(null);
|
|
31
32
|
const newlyDrawnEntry = ref({});
|
|
@@ -38,7 +39,6 @@ const drawnTypes = [
|
|
|
38
39
|
{ value: "Polygon", label: "Polygon" },
|
|
39
40
|
{ value: "None", label: "None" },
|
|
40
41
|
];
|
|
41
|
-
const showConnectivityGraph = ref(false);
|
|
42
42
|
|
|
43
43
|
onMounted(() => {
|
|
44
44
|
console.log("🚀 ~ onMounted ~ appRef:", appRef.value);
|
|
@@ -423,25 +423,6 @@ function changeHover(value) {
|
|
|
423
423
|
</el-button>
|
|
424
424
|
</el-col>
|
|
425
425
|
</el-row>
|
|
426
|
-
<el-row>
|
|
427
|
-
<el-col>
|
|
428
|
-
<h3>Connectivity Graph</h3>
|
|
429
|
-
</el-col>
|
|
430
|
-
<el-col>
|
|
431
|
-
<el-button
|
|
432
|
-
@click="showConnectivityGraph = true"
|
|
433
|
-
size="small"
|
|
434
|
-
>
|
|
435
|
-
Show connectivity graph
|
|
436
|
-
</el-button>
|
|
437
|
-
<el-button
|
|
438
|
-
@click="showConnectivityGraph = false"
|
|
439
|
-
size="small"
|
|
440
|
-
>
|
|
441
|
-
Hide connectivity graph
|
|
442
|
-
</el-button>
|
|
443
|
-
</el-col>
|
|
444
|
-
</el-row>
|
|
445
426
|
|
|
446
427
|
<DrawToolbar
|
|
447
428
|
v-show="isFlatmap"
|
|
@@ -487,6 +468,11 @@ function changeHover(value) {
|
|
|
487
468
|
@annotation="commitAnnotationEvent"
|
|
488
469
|
@onActionClick="onActionClick"
|
|
489
470
|
/>
|
|
471
|
+
<el-input
|
|
472
|
+
v-model="filterText"
|
|
473
|
+
style="width: 240px"
|
|
474
|
+
placeholder="Filter keyword"
|
|
475
|
+
/>
|
|
490
476
|
<TreeControls
|
|
491
477
|
v-show="mapType === 'flatmap'"
|
|
492
478
|
mapType="flatmap"
|
|
@@ -498,6 +484,7 @@ function changeHover(value) {
|
|
|
498
484
|
@checkChanged="checkChanged"
|
|
499
485
|
@changeActive="changeActive"
|
|
500
486
|
@changeHover="changeHover"
|
|
487
|
+
:filterText="filterText"
|
|
501
488
|
/>
|
|
502
489
|
<TreeControls
|
|
503
490
|
v-show="mapType === 'scaffold'"
|
|
@@ -510,11 +497,7 @@ function changeHover(value) {
|
|
|
510
497
|
:showColourPicker="true"
|
|
511
498
|
@setColour="setColour"
|
|
512
499
|
@checkChanged="checkChanged"
|
|
513
|
-
|
|
514
|
-
<ConnectivityGraph
|
|
515
|
-
v-if="showConnectivityGraph"
|
|
516
|
-
entry="ilxtr:neuron-type-aacar-13"
|
|
517
|
-
map-server="https://mapcore-demo.org/curation/flatmap/"
|
|
500
|
+
:filterText="filterText"
|
|
518
501
|
/>
|
|
519
502
|
</div>
|
|
520
503
|
</template>
|
|
@@ -533,9 +516,4 @@ function changeHover(value) {
|
|
|
533
516
|
top: calc(50% - 100px);
|
|
534
517
|
left: calc(50% - 200px);
|
|
535
518
|
}
|
|
536
|
-
.connectivity-graph {
|
|
537
|
-
width: 600px;
|
|
538
|
-
height: 600px;
|
|
539
|
-
margin-top: 1rem;
|
|
540
|
-
}
|
|
541
519
|
</style>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<div :class="['tree-tooltip', tooltipAtBottom ? 'bottom' : '']" >
|
|
12
12
|
<el-popover
|
|
13
13
|
ref="tooltip"
|
|
14
|
-
:visible="tooltipVisible"
|
|
14
|
+
:visible="tooltipVisible && tooltipLabel !== ''"
|
|
15
15
|
placement="top"
|
|
16
16
|
:show-arrow="false"
|
|
17
17
|
:teleported="false"
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
:default-expanded-keys="expandedKeys"
|
|
39
39
|
@check="checkChanged"
|
|
40
40
|
:indent="8"
|
|
41
|
+
:filter-node-method="filterNode"
|
|
41
42
|
:class="[mapType === 'flatmap' ? 'hide_grandchildren_checkbox': '']"
|
|
42
43
|
>
|
|
43
44
|
<template #default="{ node, data }">
|
|
@@ -94,6 +95,10 @@
|
|
|
94
95
|
export default {
|
|
95
96
|
name: "TreeControls",
|
|
96
97
|
props: {
|
|
98
|
+
filterText: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: "",
|
|
101
|
+
},
|
|
97
102
|
/**
|
|
98
103
|
* The type of map that the TreeControls is used. Either "flatmap" or "scaffold".
|
|
99
104
|
*/
|
|
@@ -178,8 +183,17 @@ export default {
|
|
|
178
183
|
else this.myPopperClass = "hide-scaffold-colour-popup";
|
|
179
184
|
},
|
|
180
185
|
},
|
|
186
|
+
filterText: {
|
|
187
|
+
handler: function (value) {
|
|
188
|
+
if (this.$refs.regionTree) this.$refs.regionTree.filter(value);
|
|
189
|
+
},
|
|
190
|
+
},
|
|
181
191
|
},
|
|
182
192
|
methods: {
|
|
193
|
+
filterNode: function(value, data) {
|
|
194
|
+
if (!value) return true;
|
|
195
|
+
return data.label ? data.label.toLowerCase().includes(value) : false;
|
|
196
|
+
},
|
|
183
197
|
setColour: function (nodeData, value) {
|
|
184
198
|
this.$emit("setColour", nodeData, value);
|
|
185
199
|
},
|
|
@@ -250,6 +264,9 @@ export default {
|
|
|
250
264
|
unmounted: function () {
|
|
251
265
|
this.sortedPrimitiveGroups = undefined;
|
|
252
266
|
},
|
|
267
|
+
mounted: function() {
|
|
268
|
+
if (this.$refs.regionTree) this.$refs.regionTree.filter(this.filterText);
|
|
269
|
+
}
|
|
253
270
|
};
|
|
254
271
|
</script>
|
|
255
272
|
|
package/src/components/index.js
CHANGED
|
@@ -3,13 +3,5 @@ import HelpModeDialog from "./HelpModeDialog/HelpModeDialog.vue";
|
|
|
3
3
|
import Tooltip from "./Tooltip/Tooltip.vue";
|
|
4
4
|
import TreeControls from "./TreeControls/TreeControls.vue";
|
|
5
5
|
import CopyToClipboard from "./CopyToClipboard/CopyToClipboard.vue";
|
|
6
|
-
import ConnectivityGraph from "./ConnectivityGraph/ConnectivityGraph.vue";
|
|
7
6
|
|
|
8
|
-
export {
|
|
9
|
-
DrawToolbar,
|
|
10
|
-
HelpModeDialog,
|
|
11
|
-
Tooltip,
|
|
12
|
-
TreeControls,
|
|
13
|
-
CopyToClipboard,
|
|
14
|
-
ConnectivityGraph,
|
|
15
|
-
};
|
|
7
|
+
export { DrawToolbar, HelpModeDialog, Tooltip, TreeControls, CopyToClipboard };
|
package/src/components.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ declare module 'vue' {
|
|
|
9
9
|
export interface GlobalComponents {
|
|
10
10
|
AnnotationPopup: typeof import('./components/Tooltip/AnnotationPopup.vue')['default']
|
|
11
11
|
ConnectionDialog: typeof import('./components/DrawToolbar/ConnectionDialog.vue')['default']
|
|
12
|
-
ConnectivityGraph: typeof import('./components/ConnectivityGraph/ConnectivityGraph.vue')['default']
|
|
13
12
|
CopyToClipboard: typeof import('./components/CopyToClipboard/CopyToClipboard.vue')['default']
|
|
14
13
|
DrawToolbar: typeof import('./components/DrawToolbar/DrawToolbar.vue')['default']
|
|
15
14
|
ElButton: typeof import('element-plus/es')['ElButton']
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="connectivity-graph">
|
|
3
|
-
<div ref="graphCanvas" class="graph-canvas"></div>
|
|
4
|
-
<div class="node-key">
|
|
5
|
-
<div class="key-head">Node type:</div>
|
|
6
|
-
<div>
|
|
7
|
-
<div><span>Node:</span><span class="key-box" style="background: #80F0F0"/></div>
|
|
8
|
-
<div><span>Axon:</span><span class="key-box" style="background: green"/></div>
|
|
9
|
-
<div><span>Dendrite:</span><span class="key-box" style="background: red"/></div>
|
|
10
|
-
<div><span>Both:</span><span class="key-box" style="background: gray"/></div>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
import { ConnectivityGraph } from './graph';
|
|
18
|
-
|
|
19
|
-
const MIN_SCHEMA_VERSION = 1.3;
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
name: 'ConnectivityGraph',
|
|
23
|
-
props: {
|
|
24
|
-
/**
|
|
25
|
-
* Entity to load its connectivity graph.
|
|
26
|
-
*/
|
|
27
|
-
entry: {
|
|
28
|
-
type: String,
|
|
29
|
-
default: '',
|
|
30
|
-
},
|
|
31
|
-
mapServer: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: '',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
data: function () {
|
|
37
|
-
return {
|
|
38
|
-
cy: null,
|
|
39
|
-
connectivityGraph: null,
|
|
40
|
-
knowledgeByPath: new Map(),
|
|
41
|
-
labelledTerms: new Set(),
|
|
42
|
-
labelCache: new Map(),
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
mounted() {
|
|
46
|
-
this.run().then((res) => {
|
|
47
|
-
this.showGraph(this.entry);
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
methods: {
|
|
51
|
-
run: async function () {
|
|
52
|
-
const schemaVersion = await this.getSchemaVersion();
|
|
53
|
-
if (schemaVersion < MIN_SCHEMA_VERSION) {
|
|
54
|
-
console.warn('No Server!');
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this.showSpinner();
|
|
58
|
-
const selectedSource = await this.setSourceList();
|
|
59
|
-
await this.setPathList(selectedSource)
|
|
60
|
-
this.hideSpinner();
|
|
61
|
-
},
|
|
62
|
-
showGraph: async function (neuronPath) {
|
|
63
|
-
const graphCanvas = this.$refs.graphCanvas;
|
|
64
|
-
this.showSpinner();
|
|
65
|
-
this.connectivityGraph = new ConnectivityGraph(this.labelCache, graphCanvas);
|
|
66
|
-
await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(neuronPath));
|
|
67
|
-
this.hideSpinner();
|
|
68
|
-
this.connectivityGraph.showConnectivity(graphCanvas);
|
|
69
|
-
this.currentPath = neuronPath
|
|
70
|
-
},
|
|
71
|
-
query: async function (sql, params) {
|
|
72
|
-
const url = `${this.mapServer}knowledge/query/`;
|
|
73
|
-
const query = { sql, params }
|
|
74
|
-
try {
|
|
75
|
-
const response = await fetch(url, {
|
|
76
|
-
method: 'POST',
|
|
77
|
-
headers: {
|
|
78
|
-
"Accept": "application/json; charset=utf-8",
|
|
79
|
-
"Cache-Control": "no-store",
|
|
80
|
-
"Content-Type": "application/json"
|
|
81
|
-
},
|
|
82
|
-
body: JSON.stringify(query)
|
|
83
|
-
});
|
|
84
|
-
if (!response.ok) {
|
|
85
|
-
throw new Error(`Cannot access ${url}`);
|
|
86
|
-
}
|
|
87
|
-
return await response.json();
|
|
88
|
-
} catch {
|
|
89
|
-
return {
|
|
90
|
-
values: []
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
setSourceList: async function () {
|
|
95
|
-
const data = await this.getJsonData(`${this.mapServer}knowledge/sources`);
|
|
96
|
-
const sources = data ? (data.sources || []) : [];
|
|
97
|
-
|
|
98
|
-
// Order with most recent first...
|
|
99
|
-
let firstSource = '';
|
|
100
|
-
const sourceList = [];
|
|
101
|
-
for (const source of sources) {
|
|
102
|
-
if (source) {
|
|
103
|
-
sourceList.push(source);
|
|
104
|
-
if (firstSource === '') {
|
|
105
|
-
firstSource = source;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return firstSource;
|
|
110
|
-
},
|
|
111
|
-
setPathList: async function (source) {
|
|
112
|
-
const data = await this.query(
|
|
113
|
-
`select entity, knowledge from knowledge
|
|
114
|
-
where entity like 'ilxtr:%' and source=?
|
|
115
|
-
order by entity`,
|
|
116
|
-
[source]);
|
|
117
|
-
const pathList = [];
|
|
118
|
-
this.knowledgeByPath.clear();
|
|
119
|
-
this.labelledTerms = new Set();
|
|
120
|
-
for (const [key, jsonKnowledge] of data.values) {
|
|
121
|
-
const knowledge = JSON.parse(jsonKnowledge);
|
|
122
|
-
if ('connectivity' in knowledge) {
|
|
123
|
-
const label = knowledge.label || key;
|
|
124
|
-
const shortLabel = (label === key.slice(6).replace('-prime', "'").replaceAll('-', ' '))
|
|
125
|
-
? ''
|
|
126
|
-
: (label.length < 50) ? label : `${label.slice(0, 50)}...`;
|
|
127
|
-
pathList.push(key);
|
|
128
|
-
this.knowledgeByPath.set(key, knowledge);
|
|
129
|
-
this.cacheLabels(knowledge);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
await this.getCachedTermLabels();
|
|
133
|
-
return '';
|
|
134
|
-
},
|
|
135
|
-
getSchemaVersion: async function () {
|
|
136
|
-
const data = await this.getJsonData(`${this.mapServer}knowledge/schema-version`);
|
|
137
|
-
return data ? (+data.version || 0) : 0;
|
|
138
|
-
},
|
|
139
|
-
getJsonData: async function (url) {
|
|
140
|
-
try {
|
|
141
|
-
const response = await fetch(url, {
|
|
142
|
-
method: 'GET',
|
|
143
|
-
headers: {
|
|
144
|
-
"Accept": "application/json; charset=utf-8",
|
|
145
|
-
"Cache-Control": "no-store",
|
|
146
|
-
"Content-Type": "application/json"
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
if (!response.ok) {
|
|
150
|
-
console.error(`Cannot access ${url}`);
|
|
151
|
-
}
|
|
152
|
-
return await response.json();
|
|
153
|
-
} catch {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
getCachedTermLabels: async function () {
|
|
158
|
-
if (this.labelledTerms.size) {
|
|
159
|
-
const termLabels = await this.query(`
|
|
160
|
-
select entity, label from labels
|
|
161
|
-
where entity in (?${', ?'.repeat(this.labelledTerms.size-1)})`,
|
|
162
|
-
[...this.labelledTerms.values()]
|
|
163
|
-
);
|
|
164
|
-
for (const termLabel of termLabels.values) {
|
|
165
|
-
this.labelCache.set(termLabel[0], termLabel[1]);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
cacheNodeLabels: function (node) {
|
|
170
|
-
for (const term of [node[0], ...node[1]]) {
|
|
171
|
-
this.labelledTerms.add(term);
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
cacheLabels: async function (knowledge) {
|
|
175
|
-
for (const edge of knowledge.connectivity) {
|
|
176
|
-
this.cacheNodeLabels(edge[0]);
|
|
177
|
-
this.cacheNodeLabels(edge[1]);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
showSpinner: function () {
|
|
181
|
-
// show loading spinner
|
|
182
|
-
},
|
|
183
|
-
hideSpinner: function () {
|
|
184
|
-
// hide loading spinner
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
</script>
|
|
189
|
-
|
|
190
|
-
<style lang="scss" scoped>
|
|
191
|
-
.connectivity-graph,
|
|
192
|
-
.graph-canvas {
|
|
193
|
-
width: 100%;
|
|
194
|
-
height: 600px;
|
|
195
|
-
background-color: white;
|
|
196
|
-
position: relative;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.connectivity-graph {
|
|
200
|
-
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
|
|
201
|
-
border: solid 1px #e4e7ed;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.node-key {
|
|
205
|
-
position: absolute;
|
|
206
|
-
top: 1rem;
|
|
207
|
-
right: 1rem;
|
|
208
|
-
border: 1px solid $app-primary-color;
|
|
209
|
-
padding: 4px;
|
|
210
|
-
background-color: rgba(240, 240, 240, 0.8);
|
|
211
|
-
|
|
212
|
-
div div {
|
|
213
|
-
width: 90px;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.key-head {
|
|
218
|
-
text-align: center;
|
|
219
|
-
font-weight: bold;
|
|
220
|
-
border-bottom: 1px solid gray;
|
|
221
|
-
padding-bottom: 4px;
|
|
222
|
-
margin-bottom: 4px;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.key-box {
|
|
226
|
-
float: right;
|
|
227
|
-
width: 12px;
|
|
228
|
-
height: 12px;
|
|
229
|
-
}
|
|
230
|
-
</style>
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/*==============================================================================
|
|
2
|
-
|
|
3
|
-
A viewer for neuron connectivity graphs.
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2019 - 2024 David Brooks
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
==============================================================================*/
|
|
20
|
-
|
|
21
|
-
import cytoscape from 'cytoscape'
|
|
22
|
-
|
|
23
|
-
//==============================================================================
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//==============================================================================
|
|
27
|
-
|
|
28
|
-
export class ConnectivityGraph
|
|
29
|
-
{
|
|
30
|
-
cy = null
|
|
31
|
-
nodes = []
|
|
32
|
-
edges = []
|
|
33
|
-
axons = []
|
|
34
|
-
dendrites = []
|
|
35
|
-
labelCache = new Map()
|
|
36
|
-
graphCanvas = null
|
|
37
|
-
|
|
38
|
-
constructor(labelCache, graphCanvas)
|
|
39
|
-
{
|
|
40
|
-
this.labelCache = labelCache;
|
|
41
|
-
this.graphCanvas = graphCanvas;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async addConnectivity(knowledge)
|
|
45
|
-
//=====================================================
|
|
46
|
-
{
|
|
47
|
-
this.axons = knowledge.axons.map(node => JSON.stringify(node))
|
|
48
|
-
this.dendrites = knowledge.dendrites.map(node => JSON.stringify(node))
|
|
49
|
-
if (knowledge.connectivity.length) {
|
|
50
|
-
for (const edge of knowledge.connectivity) {
|
|
51
|
-
const e0 = await this.graphNode(edge[0])
|
|
52
|
-
const e1 = await this.graphNode(edge[1])
|
|
53
|
-
this.nodes.push(e0)
|
|
54
|
-
this.nodes.push(e1)
|
|
55
|
-
this.edges.push({
|
|
56
|
-
id: `${e0.id}_${e1.id}`,
|
|
57
|
-
source: e0.id,
|
|
58
|
-
target: e1.id
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
this.nodes.push({
|
|
63
|
-
id: 'MISSING',
|
|
64
|
-
label: 'NO PATHS'
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
showConnectivity(graphCanvas)
|
|
70
|
-
//================
|
|
71
|
-
{
|
|
72
|
-
this.cy = new CytoscapeGraph(this, graphCanvas)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
clearConnectivity()
|
|
76
|
-
//=================
|
|
77
|
-
{
|
|
78
|
-
if (this.cy) {
|
|
79
|
-
this.cy.remove()
|
|
80
|
-
this.cy = null
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get elements()
|
|
85
|
-
//============
|
|
86
|
-
{
|
|
87
|
-
return [
|
|
88
|
-
...this.nodes.map(n => { return {data: n}}),
|
|
89
|
-
...this.edges.map(e => { return {data: e}})
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get roots()
|
|
94
|
-
//===================
|
|
95
|
-
{
|
|
96
|
-
return this.dendrites
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async graphNode(node)
|
|
100
|
-
//=======================================================
|
|
101
|
-
{
|
|
102
|
-
const id = JSON.stringify(node)
|
|
103
|
-
const label = [node[0], ...node[1]]
|
|
104
|
-
const humanLabels = []
|
|
105
|
-
for (const term of label) {
|
|
106
|
-
const humanLabel = this.labelCache.has(term) ? this.labelCache.get(term) : ''
|
|
107
|
-
humanLabels.push(humanLabel)
|
|
108
|
-
}
|
|
109
|
-
label.push(...humanLabels)
|
|
110
|
-
|
|
111
|
-
const result = {
|
|
112
|
-
id,
|
|
113
|
-
label: label.join('\n')
|
|
114
|
-
}
|
|
115
|
-
if (this.axons.includes(id)) {
|
|
116
|
-
if (this.dendrites.includes(id)) {
|
|
117
|
-
result['both-a-d'] = true
|
|
118
|
-
} else {
|
|
119
|
-
result['axon'] = true
|
|
120
|
-
}
|
|
121
|
-
} else if (this.dendrites.includes(id)) {
|
|
122
|
-
result['dendrite'] = true
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
return result
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
//==============================================================================
|
|
130
|
-
|
|
131
|
-
const GRAPH_STYLE = [
|
|
132
|
-
{
|
|
133
|
-
'selector': 'node',
|
|
134
|
-
'style': {
|
|
135
|
-
'label': 'data(label)',
|
|
136
|
-
'background-color': '#80F0F0',
|
|
137
|
-
'text-valign': 'center',
|
|
138
|
-
'text-wrap': 'wrap',
|
|
139
|
-
'text-max-width': '80px',
|
|
140
|
-
'font-size': '6px'
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
'selector': 'node[axon]',
|
|
145
|
-
'style': {
|
|
146
|
-
'background-color': 'green'
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
'selector': 'node[dendrite]',
|
|
151
|
-
'style': {
|
|
152
|
-
'background-color': 'red'
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
'selector': 'node[both-a-d]',
|
|
157
|
-
'style': {
|
|
158
|
-
'background-color': 'gray'
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
'selector': 'edge',
|
|
163
|
-
'style': {
|
|
164
|
-
'width': 2,
|
|
165
|
-
'line-color': '#9dbaea',
|
|
166
|
-
'target-arrow-color': '#9dbaea',
|
|
167
|
-
'target-arrow-shape': 'triangle',
|
|
168
|
-
'curve-style': 'bezier'
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
]
|
|
172
|
-
|
|
173
|
-
//==============================================================================
|
|
174
|
-
|
|
175
|
-
class CytoscapeGraph
|
|
176
|
-
{
|
|
177
|
-
cy
|
|
178
|
-
tooltip
|
|
179
|
-
|
|
180
|
-
constructor(connectivityGraph, graphCanvas)
|
|
181
|
-
{
|
|
182
|
-
// const graphCanvas = document.getElementById('graph-canvas')
|
|
183
|
-
this.cy = cytoscape({
|
|
184
|
-
container: graphCanvas,
|
|
185
|
-
elements: connectivityGraph.elements,
|
|
186
|
-
layout: {
|
|
187
|
-
name: 'breadthfirst',
|
|
188
|
-
circle: false,
|
|
189
|
-
roots: connectivityGraph.roots
|
|
190
|
-
},
|
|
191
|
-
directed: true,
|
|
192
|
-
style: GRAPH_STYLE,
|
|
193
|
-
minZoom: 0.5,
|
|
194
|
-
maxZoom: 10,
|
|
195
|
-
wheelSensitivity: 0.4,
|
|
196
|
-
}).on('mouseover', 'node', this.overNode.bind(this))
|
|
197
|
-
.on('mouseout', 'node', this.exitNode.bind(this))
|
|
198
|
-
.on('position', 'node', this.moveNode.bind(this))
|
|
199
|
-
|
|
200
|
-
this.tooltip = document.createElement('div')
|
|
201
|
-
this.tooltip.id = 'tooltip'
|
|
202
|
-
this.tooltip.hidden = true
|
|
203
|
-
this.graphCanvas?.lastChild?.appendChild(this.tooltip)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
remove()
|
|
207
|
-
//======
|
|
208
|
-
{
|
|
209
|
-
if (this.cy) {
|
|
210
|
-
this.cy.destroy()
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
checkRightBoundary(leftPos)
|
|
215
|
-
//==================================
|
|
216
|
-
{
|
|
217
|
-
if ((leftPos + this.tooltip.offsetWidth) >= this.tooltip.parentElement?.offsetWidth) {
|
|
218
|
-
this.tooltip.style.left = `${leftPos - this.tooltip.offsetWidth}px`
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
overNode(event)
|
|
223
|
-
//==============
|
|
224
|
-
{
|
|
225
|
-
const node = event.target
|
|
226
|
-
this.tooltip.innerText = node.data().label
|
|
227
|
-
this.tooltip.style.left = `${event.renderedPosition.x}px`
|
|
228
|
-
this.tooltip.style.top = `${event.renderedPosition.y}px`
|
|
229
|
-
this.tooltip.hidden = false
|
|
230
|
-
this.checkRightBoundary(event.renderedPosition.x)
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
moveNode(event)
|
|
234
|
-
//==============
|
|
235
|
-
{
|
|
236
|
-
const node = event.target
|
|
237
|
-
this.tooltip.style.left = `${node.renderedPosition().x}px`
|
|
238
|
-
this.tooltip.style.top = `${node.renderedPosition().y}px`
|
|
239
|
-
this.checkRightBoundary(node.renderedPosition().x)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
exitNode(event)
|
|
243
|
-
//==============
|
|
244
|
-
{
|
|
245
|
-
this.tooltip.hidden = true
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
//==============================================================================
|