@abi-software/flatmap-viewer 2.4.1-b.1 → 2.4.1-b.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/README.rst +1 -1
- package/package.json +1 -1
- package/src/controls/taxons.js +73 -0
- package/src/flatmap-viewer.js +20 -6
- package/src/interactions.js +15 -5
- package/src/pathways.js +4 -0
- package/src/styling.js +14 -8
package/README.rst
CHANGED
|
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
|
|
|
38
38
|
Package Installation
|
|
39
39
|
====================
|
|
40
40
|
|
|
41
|
-
* ``npm install @abi-software/flatmap-viewer@2.4.1-b.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.4.1-b.3``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
|
|
3
|
+
Flatmap viewer and annotation tool
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2019 - 2023 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
|
+
|
|
22
|
+
import { Control } from './controls';
|
|
23
|
+
|
|
24
|
+
//==============================================================================
|
|
25
|
+
|
|
26
|
+
export class TaxonsControl extends Control
|
|
27
|
+
{
|
|
28
|
+
constructor(flatmap)
|
|
29
|
+
{
|
|
30
|
+
super(flatmap, 'taxon', 'taxons');
|
|
31
|
+
this.__taxonIds = flatmap.taxonIdentifiers.sort();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_addControlDetails()
|
|
35
|
+
//==================
|
|
36
|
+
{
|
|
37
|
+
let lines = 0;
|
|
38
|
+
let enabled = 0;
|
|
39
|
+
for (const taxonId of this.__taxonIds) {
|
|
40
|
+
const input = this._addControlLine(`${this.__prefix}${taxonId}`, taxonId);
|
|
41
|
+
input.checked = true;
|
|
42
|
+
enabled += 1;
|
|
43
|
+
lines += 1;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
enabled: enabled,
|
|
47
|
+
total: lines
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_enableAll(enable)
|
|
52
|
+
//================
|
|
53
|
+
{
|
|
54
|
+
for (const taxonId of this.__taxonIds) {
|
|
55
|
+
const checkbox = document.getElementById(`${this.__prefix}${taxonId}`);
|
|
56
|
+
if (checkbox) {
|
|
57
|
+
checkbox.checked = enable;
|
|
58
|
+
this.__flatmap.enableConnectivityByTaxonIds(taxonId, enable);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
__enableControl(id, enable)
|
|
64
|
+
//=========================
|
|
65
|
+
{
|
|
66
|
+
for (const taxonId of this.__taxonIds) {
|
|
67
|
+
if (id === taxonId) {
|
|
68
|
+
this.__flatmap.enableConnectivityByTaxonIds(taxonId, enable);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
package/src/flatmap-viewer.js
CHANGED
|
@@ -39,6 +39,7 @@ import {UserInteractions} from './interactions.js';
|
|
|
39
39
|
|
|
40
40
|
import {MinimapControl} from './controls/minimap.js';
|
|
41
41
|
import {NavigationControl} from './controls/controls.js';
|
|
42
|
+
import {APINATOMY_PATH_PREFIX} from './pathways';
|
|
42
43
|
|
|
43
44
|
import * as images from './images.js';
|
|
44
45
|
import * as utils from './utils.js';
|
|
@@ -49,6 +50,15 @@ const MAP_MAKER_SEPARATE_LAYERS_VERSION = 1.4;
|
|
|
49
50
|
|
|
50
51
|
//==============================================================================
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* The taxon identifier used when none has been given.
|
|
55
|
+
*
|
|
56
|
+
* @type {string}
|
|
57
|
+
*/
|
|
58
|
+
export const UNCLASSIFIED_TAXON_ID = 'NCBITaxon:2787823'; // unclassified entries
|
|
59
|
+
|
|
60
|
+
//==============================================================================
|
|
61
|
+
|
|
52
62
|
/**
|
|
53
63
|
* Maps are not created directly but instead are created and loaded by
|
|
54
64
|
* :meth:`LoadMap` of :class:`MapManager`.
|
|
@@ -533,7 +543,7 @@ class FlatMap
|
|
|
533
543
|
}
|
|
534
544
|
|
|
535
545
|
__updateFeatureIdMapEntry(propertyId, featureIdMap, featureId)
|
|
536
|
-
|
|
546
|
+
//============================================================
|
|
537
547
|
{
|
|
538
548
|
const featureIds = featureIdMap.get(propertyId);
|
|
539
549
|
if (featureIds) {
|
|
@@ -543,18 +553,22 @@ class FlatMap
|
|
|
543
553
|
}
|
|
544
554
|
}
|
|
545
555
|
|
|
546
|
-
__updateFeatureIdMap(property, featureIdMap, annotation)
|
|
547
|
-
|
|
556
|
+
__updateFeatureIdMap(property, featureIdMap, annotation, missingId=null)
|
|
557
|
+
//======================================================================
|
|
548
558
|
{
|
|
549
|
-
if (property in annotation) {
|
|
559
|
+
if (property in annotation && annotation[property].length) {
|
|
550
560
|
const propertyId = annotation[property];
|
|
551
561
|
if (Array.isArray(propertyId)) {
|
|
552
562
|
for (const id of propertyId) {
|
|
553
563
|
this.__updateFeatureIdMapEntry(id, featureIdMap, annotation.featureId);
|
|
554
564
|
}
|
|
555
565
|
} else {
|
|
556
|
-
this.__updateFeatureIdMapEntry(propertyId, featureIdMap, annotation.featureId)
|
|
566
|
+
this.__updateFeatureIdMapEntry(propertyId, featureIdMap, annotation.featureId);
|
|
557
567
|
}
|
|
568
|
+
} else if (missingId !== null
|
|
569
|
+
&& 'models' in annotation
|
|
570
|
+
&& annotation.models.startsWith(APINATOMY_PATH_PREFIX)) {
|
|
571
|
+
this.__updateFeatureIdMapEntry(missingId, featureIdMap, annotation.featureId);
|
|
558
572
|
}
|
|
559
573
|
}
|
|
560
574
|
|
|
@@ -566,7 +580,7 @@ class FlatMap
|
|
|
566
580
|
this.__updateFeatureIdMap('dataset', this.__datasetToFeatureIds, ann);
|
|
567
581
|
this.__updateFeatureIdMap('models', this.__modelToFeatureIds, ann);
|
|
568
582
|
this.__updateFeatureIdMap('source', this.__mapSourceToFeatureIds, ann);
|
|
569
|
-
this.__updateFeatureIdMap('taxons', this.__taxonToFeatureIds, ann);
|
|
583
|
+
this.__updateFeatureIdMap('taxons', this.__taxonToFeatureIds, ann, UNCLASSIFIED_TAXON_ID);
|
|
570
584
|
this.__annIdToFeatureId.set(ann.id, featureId);
|
|
571
585
|
}
|
|
572
586
|
|
package/src/interactions.js
CHANGED
|
@@ -45,6 +45,7 @@ import {AnnotatedControl, BackgroundControl, LayerControl, NerveControl,
|
|
|
45
45
|
import {PathControl} from './controls/paths';
|
|
46
46
|
import {SearchControl} from './controls/search';
|
|
47
47
|
import {SystemsControl} from './controls/systems';
|
|
48
|
+
import {TaxonsControl} from './controls/taxons';
|
|
48
49
|
|
|
49
50
|
import * as utils from './utils';
|
|
50
51
|
|
|
@@ -159,11 +160,12 @@ export class UserInteractions
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
// Note features that are FC systems
|
|
162
|
-
|
|
163
163
|
this.__systemsManager = new SystemsManager(this._flatmap, this, featuresEnabled);
|
|
164
164
|
|
|
165
|
-
//
|
|
165
|
+
// All taxons of connectivity paths are enabled by default
|
|
166
|
+
this.__enabledConnectivityTaxons = new Set(this._flatmap.taxonIdentifiers);
|
|
166
167
|
|
|
168
|
+
// Add various controls when running standalone
|
|
167
169
|
if (flatmap.options.standalone) {
|
|
168
170
|
// Add a control to search annotations if option set
|
|
169
171
|
this._map.addControl(new SearchControl(flatmap));
|
|
@@ -186,11 +188,14 @@ export class UserInteractions
|
|
|
186
188
|
this._map.addControl(new NerveControl(flatmap, this._layerManager, {showCentrelines: false}));
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
// SCKAN path and SYSTEMS controls for FC maps
|
|
190
191
|
if (flatmap.options.style === 'functional') {
|
|
192
|
+
// SCKAN path and SYSTEMS controls for FC maps
|
|
191
193
|
this._map.addControl(new SystemsControl(flatmap, this.__systemsManager.systems));
|
|
192
194
|
this._map.addControl(new SCKANControl(flatmap, flatmap.options.layerOptions));
|
|
193
195
|
this._map.addControl(new AnnotatedControl(this, flatmap.options.layerOptions));
|
|
196
|
+
} else {
|
|
197
|
+
// Connectivity taxon control for AC maps
|
|
198
|
+
this._map.addControl(new TaxonsControl(flatmap));
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
|
|
@@ -1136,10 +1141,15 @@ export class UserInteractions
|
|
|
1136
1141
|
//=================================================
|
|
1137
1142
|
{
|
|
1138
1143
|
if (enable) {
|
|
1139
|
-
|
|
1144
|
+
for (const taxonId of taxonIds) {
|
|
1145
|
+
this.__enabledConnectivityTaxons.add(taxonId);
|
|
1146
|
+
}
|
|
1140
1147
|
} else {
|
|
1141
|
-
|
|
1148
|
+
for (const taxonId of taxonIds) {
|
|
1149
|
+
this.__enabledConnectivityTaxons.delete(taxonId);
|
|
1150
|
+
}
|
|
1142
1151
|
}
|
|
1152
|
+
this._layerManager.setFilter({taxons: [...this.__enabledConnectivityTaxons.values()]});
|
|
1143
1153
|
}
|
|
1144
1154
|
|
|
1145
1155
|
excludeAnnotated(exclude=false)
|
package/src/pathways.js
CHANGED
|
@@ -28,6 +28,10 @@ export const PATHWAYS_LAYER = 'pathways';
|
|
|
28
28
|
|
|
29
29
|
//==============================================================================
|
|
30
30
|
|
|
31
|
+
export const APINATOMY_PATH_PREFIX = 'ilxtr:';
|
|
32
|
+
|
|
33
|
+
//==============================================================================
|
|
34
|
+
|
|
31
35
|
const PATH_TYPES = [
|
|
32
36
|
{ type: "cns", label: "CNS", colour: "#9B1FC1"},
|
|
33
37
|
{ type: "intracardiac", label: "Local circuit neuron", colour: "#F19E38"},
|
package/src/styling.js
CHANGED
|
@@ -26,7 +26,8 @@ export const VECTOR_TILES_SOURCE = 'vector-tiles';
|
|
|
26
26
|
|
|
27
27
|
//==============================================================================
|
|
28
28
|
|
|
29
|
-
import {
|
|
29
|
+
import {UNCLASSIFIED_TAXON_ID} from './flatmap-viewer';
|
|
30
|
+
import {PATH_STYLE_RULES} from './pathways';
|
|
30
31
|
|
|
31
32
|
//==============================================================================
|
|
32
33
|
|
|
@@ -482,14 +483,19 @@ export class PathLineLayer extends VectorStyleLayer
|
|
|
482
483
|
const sckan_filter = sckanFilter(options);
|
|
483
484
|
let taxonFilter = [];
|
|
484
485
|
if ('taxons' in options) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
if (options.taxons.length) {
|
|
487
|
+
taxonFilter.push('any');
|
|
488
|
+
for (const taxon of options.taxons) {
|
|
489
|
+
if (taxon !== UNCLASSIFIED_TAXON_ID) {
|
|
490
|
+
taxonFilter.push(['in', taxon, ['get', 'taxons']]);
|
|
491
|
+
} else {
|
|
492
|
+
taxonFilter.push(['case', ['has', 'taxons'], false, true]);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
taxonFilter = [taxonFilter];
|
|
496
|
+
} else {
|
|
497
|
+
taxonFilter.push(false);
|
|
490
498
|
}
|
|
491
|
-
taxonFilter.push(filterList);
|
|
492
|
-
taxonFilter = [taxonFilter];
|
|
493
499
|
}
|
|
494
500
|
|
|
495
501
|
return this.__dashed ? [
|