@abi-software/flatmapvuer 1.9.3-beta.1 → 1.9.3-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmapvuer",
3
- "version": "1.9.3-beta.1",
3
+ "version": "1.9.3-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist/*",
package/src/App.vue CHANGED
@@ -277,6 +277,7 @@ export default {
277
277
  },
278
278
  Vagus: {
279
279
  taxo: 'UBERON:0001759',
280
+ uuid: "0ea568ec-538d-52f3-a8e7-0437d844e1cf",
280
281
  },
281
282
  Sample: { taxo: 'NCBITaxon:1', displayWarning: true },
282
283
  'Functional Connectivity': {
@@ -318,7 +318,7 @@ Please use `const` to assign meaningful names to them...
318
318
  ref="treeControls"
319
319
  />
320
320
  <selections-group
321
- v-if="containsAlert && alertOptions"
321
+ v-if="containsAlert && alertOptions && showPathwayFilter"
322
322
  title="Alert"
323
323
  labelKey="label"
324
324
  identifierKey="key"
@@ -357,7 +357,7 @@ Please use `const` to assign meaningful names to them...
357
357
  />
358
358
  -->
359
359
  <selections-group
360
- v-if="pathways && pathways.length > 0"
360
+ v-if="pathways && pathways.length > 0 & showPathwayFilter"
361
361
  title="Pathways"
362
362
  labelKey="label"
363
363
  identifierKey="type"
@@ -370,7 +370,7 @@ Please use `const` to assign meaningful names to them...
370
370
  key="pathwaysSelection"
371
371
  />
372
372
  <selections-group
373
- v-if="taxonConnectivity && taxonConnectivity.length > 0"
373
+ v-if="taxonConnectivity && taxonConnectivity.length > 0 && showPathwayFilter"
374
374
  title="Studied in"
375
375
  labelKey="label"
376
376
  identifierKey="taxon"
@@ -739,6 +739,20 @@ export default {
739
739
  return { annotator }
740
740
  },
741
741
  methods: {
742
+ /**
743
+ *
744
+ * @param filter format should follow #makeStyleFilter (flatmap-viewer)
745
+ */
746
+ setVisibilityFilter: function (filter) {
747
+ // More filter options -> this.mapImp.featureFilterRanges()
748
+ if (this.mapImp) {
749
+ if (filter) {
750
+ this.mapImp.setVisibilityFilter(filter);
751
+ } else {
752
+ this.mapImp.clearVisibilityFilter();
753
+ }
754
+ }
755
+ },
742
756
  /**
743
757
  * @public
744
758
  * Function to manually send aborted signal when annotation tooltip popup or sidebar tab closed.
@@ -1189,6 +1203,7 @@ export default {
1189
1203
  ];
1190
1204
 
1191
1205
  map.setMaxBounds(null); // override default
1206
+ map.setRenderWorldCopies(false);
1192
1207
 
1193
1208
  this.initMapState = markRaw({
1194
1209
  initBounds,
@@ -2005,22 +2020,30 @@ export default {
2005
2020
  // load and store knowledge
2006
2021
  loadAndStoreKnowledge(this.mapImp, this.flatmapQueries);
2007
2022
  let prom1 = []
2008
- // When there are multiple paths, emit placeholders first.
2023
+ // Emit placeholders first.
2009
2024
  // This may contain invalid connectivity.
2010
- if (data.length > 1) {
2011
- this.tooltipEntry = data.map((tooltip) => {
2025
+ this.tooltipEntry = data
2026
+ .filter((tooltip) => {
2027
+ return (
2028
+ tooltip.resource[0] &&
2029
+ this.mapImp.pathModelNodes(tooltip.resource).length > 0
2030
+ )
2031
+ })
2032
+ .map((tooltip) => {
2012
2033
  return { title: tooltip.label, featureId: tooltip.resource, ready: false }
2013
2034
  })
2035
+ // this should only for flatmap paths not all features
2036
+ if (this.tooltipEntry.length) {
2014
2037
  this.$emit('connectivity-info-open', this.tooltipEntry);
2015
- }
2016
- // While having placeholders displayed, get details for all paths and then replace.
2017
- for (let index = 0; index < data.length; index++) {
2018
- prom1.push(await this.getKnowledgeTooltip(data[index]))
2019
- }
2020
- this.tooltipEntry = await Promise.all(prom1)
2021
- const featureIds = this.tooltipEntry.map(tooltip => tooltip.featureId[0])
2022
- if (featureIds.length > 0) {
2023
- this.displayTooltip(featureIds)
2038
+ // While having placeholders displayed, get details for all paths and then replace.
2039
+ for (let index = 0; index < data.length; index++) {
2040
+ prom1.push(await this.getKnowledgeTooltip(data[index]))
2041
+ }
2042
+ this.tooltipEntry = await Promise.all(prom1)
2043
+ const featureIds = this.tooltipEntry.map(tooltip => tooltip.featureId[0])
2044
+ if (featureIds.length > 0) {
2045
+ this.displayTooltip(featureIds)
2046
+ }
2024
2047
  }
2025
2048
  }
2026
2049
  },
@@ -2315,7 +2338,9 @@ export default {
2315
2338
  options.annotationFeatureGeometry = geometry
2316
2339
  } else {
2317
2340
  const entry = Array.isArray(feature) ? feature[0] : feature
2318
- featureId = this.mapImp.modelFeatureIds(entry)[0]
2341
+ if (entry) {
2342
+ featureId = this.mapImp.modelFeatureIds(entry)[0]
2343
+ }
2319
2344
  if (!this.activeDrawTool) {
2320
2345
  options.positionAtLastClick = true
2321
2346
  }
@@ -2338,6 +2363,7 @@ export default {
2338
2363
  // Provenance popup will be shown on map
2339
2364
  // Tooltip will be shown for Annotation view
2340
2365
  if (
2366
+ featureId &&
2341
2367
  !this.disableUI &&
2342
2368
  (
2343
2369
  (this.viewingMode === 'Annotation' && !this.annotationSidebar) ||
@@ -2676,6 +2702,117 @@ export default {
2676
2702
  console.error('Map resize error')
2677
2703
  }
2678
2704
  },
2705
+ getFilterSources: function () {
2706
+ const FILTER_PROPERTIES = ['kind', 'taxons']
2707
+ let withAlert = new Set()
2708
+ let withoutAlert = new Set()
2709
+ let filterSourcesMap = new Map()
2710
+ for (const annotation of this.mapImp.annotations.values()) {
2711
+ if (annotation.source) {
2712
+ if ("alert" in annotation) {
2713
+ withAlert.add(annotation.source)
2714
+ } else {
2715
+ withoutAlert.add(annotation.source)
2716
+ }
2717
+ for (const [key, value] of Object.entries(annotation)) {
2718
+ if (FILTER_PROPERTIES.includes(key)) {
2719
+ if (!filterSourcesMap.has(key)) {
2720
+ filterSourcesMap.set(key, new Map())
2721
+ }
2722
+ const sourceMap = filterSourcesMap.get(key)
2723
+ const addToSourceMap = (val) => {
2724
+ const setKey = val
2725
+ if (!sourceMap.has(setKey)) {
2726
+ sourceMap.set(setKey, new Set())
2727
+ }
2728
+ sourceMap.get(setKey).add(`${annotation.source}`)
2729
+ };
2730
+ if (Array.isArray(value)) {
2731
+ value.forEach(addToSourceMap)
2732
+ } else {
2733
+ addToSourceMap(value)
2734
+ }
2735
+ }
2736
+ }
2737
+ }
2738
+ }
2739
+ let filterSources = {
2740
+ 'alert': {
2741
+ 'with': [...withAlert],
2742
+ 'without': [...withoutAlert]
2743
+ }
2744
+ }
2745
+ for (const [key, value] of filterSourcesMap.entries()) {
2746
+ filterSources[key] = {}
2747
+ for (const [key1, value1] of value.entries()) {
2748
+ filterSources[key][key1] = [...value1.values()]
2749
+ }
2750
+ }
2751
+ return filterSources
2752
+ },
2753
+ getFilterOptions: async function () {
2754
+ if (this.mapImp) {
2755
+ let filterOptions = []
2756
+ const filterRanges = this.mapImp.featureFilterRanges()
2757
+ for (const [key, value] of Object.entries(filterRanges)) {
2758
+ let main = {
2759
+ key: `flatmap.connectivity.${key}`,
2760
+ label: "",
2761
+ children: []
2762
+ }
2763
+ if (key === "kind") {
2764
+ main.label = "Pathways"
2765
+ for (const facet of value) {
2766
+ const pathway = this.pathways.find(p => p.type !== "centreline" && p.type === facet)
2767
+ if (pathway) {
2768
+ main.children.push({
2769
+ key: `${main.key}.${facet}`,
2770
+ label: pathway.label
2771
+ })
2772
+ }
2773
+ }
2774
+ } else if (key === "taxons") {
2775
+ main.label = "Studied in"
2776
+ const entityLabels = await findTaxonomyLabels(this.mapImp, this.mapImp.taxonIdentifiers)
2777
+ if (entityLabels.length) {
2778
+ for (const facet of value) {
2779
+ const taxon = entityLabels.find(p => p.taxon === facet)
2780
+ if (taxon) {
2781
+ main.children.push({
2782
+ key: `${main.key}.${facet}`,
2783
+ label: taxon.label
2784
+ })
2785
+ }
2786
+ }
2787
+ }
2788
+ } else if (key === "alert") {
2789
+ main.label = "Alert"
2790
+ for (const facet of ["with", "without"]) {
2791
+ main.children.push({
2792
+ key: `${main.key}.${facet}`,
2793
+ label: `${facet} alerts`
2794
+ })
2795
+ }
2796
+ }
2797
+ if (main.label && main.children.length) {
2798
+ filterOptions.push(main)
2799
+ }
2800
+ }
2801
+ // let hardcode = {
2802
+ // key: "flatmap.connectivity.source",
2803
+ // label: "Connectivity",
2804
+ // children: []
2805
+ // }
2806
+ // for (const facet of ["Origins", "Components", "Destinations"]) {
2807
+ // hardcode.children.push({
2808
+ // key: `flatmap.connectivity.source.${facet}`,
2809
+ // label: facet
2810
+ // })
2811
+ // }
2812
+ // filterOptions.push(hardcode)
2813
+ return filterOptions
2814
+ }
2815
+ },
2679
2816
  /**
2680
2817
  * @public
2681
2818
  * This function is used for functions that need to run immediately after the flatmap is loaded.
@@ -3028,6 +3165,13 @@ export default {
3028
3165
  type: Boolean,
3029
3166
  default: true,
3030
3167
  },
3168
+ /**
3169
+ * The option to show pathway drawer
3170
+ */
3171
+ showPathwayFilter: {
3172
+ type: Boolean,
3173
+ default: true,
3174
+ },
3031
3175
  },
3032
3176
  provide() {
3033
3177
  return {
@@ -88,6 +88,7 @@
88
88
  :sparcAPI="sparcAPI"
89
89
  :showLocalSettings="showLocalSettings"
90
90
  :showOpenMapButton="showOpenMapButton"
91
+ :showPathwayFilter="showPathwayFilter"
91
92
  />
92
93
  </div>
93
94
  </template>
@@ -779,6 +780,13 @@ export default {
779
780
  type: Boolean,
780
781
  default: true,
781
782
  },
783
+ /**
784
+ * The option to show pathway drawer
785
+ */
786
+ showPathwayFilter: {
787
+ type: Boolean,
788
+ default: true,
789
+ },
782
790
  },
783
791
  data: function () {
784
792
  return {
@@ -344,20 +344,6 @@ let FlatmapQueries = function () {
344
344
  }
345
345
  }
346
346
 
347
- this.queryMapPaths = async function (mapuuid) {
348
- const url = this.flatmapAPI + `flatmap/${mapuuid}/pathways`;
349
-
350
- try {
351
- const response = await fetch(url);
352
- if (!response.ok) {
353
- throw new Error(`Response status: ${response.status}`);
354
- }
355
- return await response.json();
356
- } catch (error) {
357
- throw new Error(error);
358
- }
359
- }
360
-
361
347
  this.queryForConnectivity = function (mapImp, keastIds, signal, processConnectivity=true) {
362
348
  const data = { sql: this.buildConnectivitySqlStatement(keastIds) }
363
349
  const headers = {
@@ -478,11 +464,15 @@ let FlatmapQueries = function () {
478
464
  const sourceKey = ["ilxtr:hasSomaLocatedIn"]
479
465
  const destinationKey = ["ilxtr:hasAxonPresynapticElementIn", "ilxtr:hasAxonSensorySubcellularElementIn"]
480
466
  sourceKey.forEach((key)=>{
481
- dendrites.push(...connectivity["node-phenotypes"][key])
467
+ if (key in connectivity["node-phenotypes"]) {
468
+ dendrites.push(...connectivity["node-phenotypes"][key])
469
+ }
482
470
  })
483
471
  dendrites = removeDuplicates(dendrites)
484
472
  destinationKey.forEach((key)=>{
485
- axons.push(...connectivity["node-phenotypes"][key])
473
+ if (key in connectivity["node-phenotypes"]) {
474
+ axons.push(...connectivity["node-phenotypes"][key])
475
+ }
486
476
  })
487
477
  axons = removeDuplicates(axons)
488
478
  } else {