From 1ff3fbe5891c5b10f40090cbfc1790d3675f3b42 Mon Sep 17 00:00:00 2001 From: alan-wu Date: Wed, 25 Sep 2024 17:15:05 +1200 Subject: [PATCH] Remove hardcoded interactions. --- src/components/SimulatedData.js | 467 ------------------------ src/components/viewers/Flatmap.vue | 3 +- src/components/viewers/MultiFlatmap.vue | 2 +- src/mixins/ContentMixin.js | 6 +- 4 files changed, 3 insertions(+), 475 deletions(-) diff --git a/src/components/SimulatedData.js b/src/components/SimulatedData.js index 81fbc1ad..720f5b7d 100644 --- a/src/components/SimulatedData.js +++ b/src/components/SimulatedData.js @@ -203,441 +203,6 @@ const nerveMaps = [ } ]; - - -/* eslint-disable no-alert, no-console */ -function getGenericMarkerInfo(term ,label, dataset, scaffold, simulations) { - let data = {}; - data.dataset = dataset; - data.scaffold = scaffold; - data.simulations = simulations; - if (label) - data.title = label; - else - data.title = term; - data.description = ""; - data.actions = []; - if (term) { - switch (term) { - case "ICN": - data.title = "RNA"; - data.description = "The distribution of neurons in the intrinsic cardiac nervous system (ICN) were mapped and visualized in a 3D reconstruction of a male rat heart."; - data.actions = { - search: { - title: "Explore data", - resource: "icn", - type: "Search", - label: "ICN", - filter: { - facet: 'genotype', - term: 'heart' - }, - }, - plot: { - title: "View plot", - label: "ICN", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/ISAN/csv-data/use-case-4/RNA_Seq.csv", - type: "Plot", - plotType: "heatmap", - datasetTitle: "Molecular Phenotype Distribution of Single Rat Intracardiac Neurons", - datasetDescription: "Images collected from serial cryostat sectioning of a cryopreserved heart was used to reconstruct the 3D context. Transcriptional profiles taken from isolated single neurons and mapped back into the previously generated 3D context.", - datasetUrl: "https://discover.pennsieve.io/datasets/29", - datasetImage: "https://assets.discover.pennsieve.io/dataset-assets/29/6/revisions/1/banner.jpg" - }, - }; - break; - default: - break; - } - } else { - data.actions = []; - } - return data; -} - - -function getHumanData(term, label, dataset, scaffold, simulations) { - if (term || label) { - let data = {}; - switch (term) { - case "UBERON:0001157": - data.title = "Colon"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=colon", - type: "Search", - filter: { - facet: 'genotype', - term: 'colon' - }, - }, - scaffold: { - title: "View 3D scaffold", - label: "Colon", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Colon/human/humanColon_metadata.json", - type: "Scaffold" - }, - }; - break; - case "UBERON:0000948": - case "UBERON:0002080": { - data.title = "Heart"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Heart", - resource: "https://sparc.science/data?type=dataset&q=colon", - type: "Search", - filter: { - facet: 'genotype', - term: 'heart' - }, - }, - scaffold: { - title: "View 3D scaffold", - label: "Heart", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Heart/human/humanHeart_metadata.json", - type: "Scaffold" - }, - }; - } - break; - case "UBERON:0002048": - data.title = "Lung"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Lung", - resource: "https://sparc.science/data?type=dataset&q=lung", - type: "Search" - }, - scaffold: { - title: "View 3D scaffold", - label: "Lung", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Lungs/human/humanLeftLung_metadata.json", - type: "Scaffold" - }, - }; - break; - default: - data = getGenericMarkerInfo(term, label, dataset, scaffold, simulations); - break; - } - return data; - } - return undefined; -} - -function getRatData(term, label, dataset, scaffold, simulations) { - if (term || label) { - let data = {}; - switch (term) { - case "UBERON:0000948": - case "UBERON:0002080": - if (!simulations) { - data.title = "Heart"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Heart", - resource: "https://sparc.science/data?type=dataset&q=heart", - type: "Search", - filter: { - facet: 'genotype', - term: 'heart' - }, - }, - scaffold: { - title: "View 3D scaffold", - label: "Heart", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Heart/rat/ratHeart_metadata.json", - type: "Scaffold" - }, - simulation: { - title: "Explore simulations", - label: "Heart", - resource: "https://sparc.science/data?type=simulation&q=heart", - type: "URL" - }, - }; - } else { - data = getGenericMarkerInfo(term, label, dataset, scaffold, simulations); - } - break; - case "UBERON:0001156": - data.title = "Colon"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=colon", - type: "Search" - }, - }; - break; - case "UBERON:0002108": - data.title = "Small intestines"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=small+intestines", - type: "Search" - }, - }; - break; - case "UBERON:0001255": - data.title = "Urinary bladder"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Urinary Bladder", - resource: "https://sparc.science/data?type=dataset&q=bladder", - type: "Search" - }, - scaffold: { - title: "View 3D scaffold", - label: "Bladder", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Bladder/rat/ratBladder_metadata.json", - type: "Scaffold" - }, - }; - break; - case "UBERON:0002048": - data.title = "Lung"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Lung", - resource: "https://sparc.science/data?type=dataset&q=lung", - type: "Search" - }, - }; - break; - case "ICN": - data.title = "RNA"; - data.description = "The distribution of neurons in the intrinsic cardiac nervous system (ICN) were mapped and visualized in a 3D reconstruction of a male rat heart."; - data.actions = { - search: { - title: "Explore data", - resource: "icn", - type: "Search" - }, - plot: { - title: "View plot", - label: "ICN", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/ISAN/csv-data/use-case-4/RNA_Seq.csv", - type: "Plot", - plotType: "heatmap", - datasetTitle: "Molecular Phenotype Distribution of Single Rat Intracardiac Neurons", - datasetDescription: "Images collected from serial cryostat sectioning of a cryopreserved heart was used to reconstruct the 3D context. Transcriptional profiles taken from isolated single neurons and mapped back into the previously generated 3D context.", - datasetUrl: "https://discover.pennsieve.io/datasets/29", - datasetImage: "https://assets.discover.pennsieve.io/dataset-assets/29/6/revisions/1/banner.jpg" - }, - }; - break; - case "UBERON:0000945": - case "UBERON:0001160": - case "UBERON:0001161": - data.title = "Stomach"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Stomach", - resource: "https://sparc.science/data?type=dataset&q=stomach", - type: "Search" - }, - scaffold: { - title: "View 3D scaffold", - label: "Stomach", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Stomach/rat/ratStomach_metadata.json", - type: "Scaffold" - }, - }; - break; - case "UBERON:0001759": - if (label) - data.title = label; - else - data.title = "Vagus nerve"; - data.actions = { - search: { - title: "Explore data", - label: "Vagus nerve", - resource: "https://sparc.science/data?type=dataset&q=vagus+nerve", - type: "Search" - }, - simulation: { - title: "Explore simulations", - label: "Vagus nerve", - resource: "https://sparc.science/data?type=simulation&q=vagus%20nerve", - type: "simulation" - }, - }; - break; - default: - data = getGenericMarkerInfo(term, label, dataset, scaffold, simulations); - break; - } - return data; - } - return undefined; -} - -function getMouseData(term, label, dataset, scaffold, simulations) { - if (term || label) { - let data = {}; - switch (term) { - case "UBERON:0001156": - data.title = "Colon"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=colon", - type: "Search" - }, - scaffold: { - title: "View 3D scaffold", - label: "Colon", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Colon/mouse/mouseColon_metadata.json", - type: "Scaffold" - }, - }; - break; - case "UBERON:0002048": - data.title = "Lung"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Lung", - resource: "https://sparc.science/data?type=dataset&q=lung", - type: "Search" - }, - scaffold: { - title: "View 3D scaffold", - label: "Lung", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Lungs/mouse/mouseLeftLung_metadata.json", - type: "Scaffold" - }, - }; - break; - case "UBERON:0002108": - data.title = "Small intestines"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=small+intestines", - type: "Search" - }, - }; - break; - default: - data = getGenericMarkerInfo(term, label, dataset, scaffold, simulations); - break; - } - return data; - } - return undefined; -} - -function getPigData(term, label, dataset, scaffold, simulations) { - if (term || label) { - let data = {}; - switch (term) { - case "UBERON:0008972": - data.title = "Colon"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=colon", - type: "Search" - }, - scaffold: { - title: "View 3D scaffold", - label: "Colon", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Colon/pig/pigColon_metadata.json", - type: "Scaffold" - }, - }; - break; - case "UBERON:0002108": - data.title = "Small intestines"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Colon", - resource: "https://sparc.science/data?type=dataset&q=small+intestines", - type: "Search" - }, - }; - break; - case "UBERON:0000948": - case "UBERON:0002080": { - data.title = "Heart"; - data.description = ""; - data.actions = { - search: { - title: "Explore data", - label: "Heart", - resource: "https://sparc.science/data?type=dataset&q=colon", - type: "Search", - filter: { - facet: 'genotype', - term: 'heart' - }, - }, - scaffold: { - title: "View 3D scaffold", - label: "Heart", - resource: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/Generic+Scaffold/Heart/pig/pigHeart_metadata.json", - type: "Scaffold" - }, - }; - } - break; - default: - data = getGenericMarkerInfo(term, label, dataset, scaffold, simulations); - break; - } - return data; - } - return undefined; -} - -function simulatedData(term, taxonomy, label, dataset, scaffold, simulations) { - switch (taxonomy) { - case "NCBITaxon:9606": - return getHumanData(term, label, dataset, scaffold, simulations); - case "NCBITaxon:9823": - return getPigData(term, label, dataset, scaffold, simulations); - case "NCBITaxon:10090": - return getMouseData(term, label, dataset, scaffold, simulations); - case "NCBITaxon:10114": - return getRatData(term, label, dataset, scaffold, simulations); - default: - return getGenericMarkerInfo(term, taxonomy, label, dataset, scaffold, simulations); - } -} - function getRatTerms() { return [ {id: "UBERON:0000948", name: "Heart", type:"simulation"}, @@ -687,35 +252,3 @@ export function getParentsRegion(name) { return undefined; } -export function getInteractiveAction(result, action) { - if (result && result.resource) { - let resource = result.resource; - if (Array.isArray(resource) && resource[0]) - resource = resource[0]; - let term = undefined; - let label = undefined; - let dataset = undefined; - let scaffold = undefined; - let simulations = undefined; - let taxonomy = resource.taxonomy; - if (resource.data && resource.data.id) { - term = resource.data.id; - label = resource.data.id; - } else if (resource.feature) { - term = resource.feature.models; - label = resource.feature.label; - dataset = resource.feature.dataset; - scaffold = resource.feature.scaffold; - simulations = resource.feature.simulations; - } - if (term || label) { - let data = simulatedData(term, taxonomy, label, dataset, scaffold, simulations); - if (data && data.actions) { - return data.actions[action]; - } - } - } - return undefined; -} - -export { simulatedData }; diff --git a/src/components/viewers/Flatmap.vue b/src/components/viewers/Flatmap.vue index 4a81e3a6..f3ad0592 100644 --- a/src/components/viewers/Flatmap.vue +++ b/src/components/viewers/Flatmap.vue @@ -75,8 +75,7 @@ export default { return this.$refs.flatmap?.mapImp; }, flatmaprResourceSelected: function (type, resource) { - this.resourceSelected( - type, resource, (this.$refs.flatmap.viewingMode === "Exploration")); + this.resourceSelected(type, resource); if (resource.eventType === 'click' && resource.feature.type === 'feature') { const eventData = { diff --git a/src/components/viewers/MultiFlatmap.vue b/src/components/viewers/MultiFlatmap.vue index f7f89e5c..d6ae6323 100644 --- a/src/components/viewers/MultiFlatmap.vue +++ b/src/components/viewers/MultiFlatmap.vue @@ -188,7 +188,7 @@ export default { }, flatmaprResourceSelected: function (type, resource) { const map = this.$refs.multiflatmap.getCurrentFlatmap(); - this.resourceSelected(type, resource, (map.viewingMode === "Exploration")); + this.resourceSelected(type, resource); if (resource.eventType === 'click' && resource.feature.type === 'feature') { const eventData = { diff --git a/src/mixins/ContentMixin.js b/src/mixins/ContentMixin.js index 4d176c03..2b746b3a 100644 --- a/src/mixins/ContentMixin.js +++ b/src/mixins/ContentMixin.js @@ -1,5 +1,4 @@ import { - getInteractiveAction, getNerveNames, getParentsRegion, } from "../components/SimulatedData.js"; @@ -102,7 +101,7 @@ export default { /** * Callback when the vuers emit a selected event. */ - resourceSelected: function (type, resource, augmented) { + resourceSelected: function (type, resource) { // Skip processing if resources already has actions if (this.resourceHasAction(resource)) { EventBus.emit("PopoverActionClick", resource); @@ -200,9 +199,6 @@ export default { fireResourceSelected = true; action = "search"; } - if ((returnedAction === undefined) && augmented) { - returnedAction = getInteractiveAction(result, action); - } if (returnedAction) EventBus.emit("PopoverActionClick", returnedAction); if (fireResourceSelected) this.$emit("resource-selected", result); },