Skip to content

Commit

Permalink
Pigean cleanup (#797)
Browse files Browse the repository at this point in the history
* gene page moved stuff to module

* refactored all pigean pages to use utils

* label fix
  • Loading branch information
moriondo2022 authored Dec 3, 2024
1 parent eb34995 commit cac59ff
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 79 deletions.
23 changes: 23 additions & 0 deletions src/utils/pigeanUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* PIGeAN Utilities
*/

export function toOldStyle(newStylePhenotype){
let oldStyle = structuredClone(newStylePhenotype);
oldStyle.description = newStylePhenotype.phenotype_name;
oldStyle.name = newStylePhenotype.phenotype;
oldStyle.group = newStylePhenotype.display_group;
return oldStyle;
}

export function mapPhenotypes(allPhenotypes){
let phenotypeMap = {};
allPhenotypes.forEach(item => {
phenotypeMap[item.phenotype] = toOldStyle(item);
});
return phenotypeMap;
}

export default {
toOldStyle,
mapPhenotypes
};
23 changes: 5 additions & 18 deletions src/views/PIGEAN/Gene/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import sortUtils from "@/utils/sortUtils";
import alertUtils from "@/utils/alertUtils";
import Formatters from "@/utils/formatters";
import dataConvert from "@/utils/dataConvert";
import pigeanUtils from "@/utils/pigeanUtils.js";
import { pageMixin } from "@/mixins/pageMixin.js";

new Vue({
Expand All @@ -44,8 +45,8 @@ new Vue({
pigeanPhenotypeMap: {},
filterFields: [
{ key: "combined", label: "Combined genetic support" },
{ key: "huge_score", label: "GWAS unweighted" },
{ key: "log_bf", label: "GWAS weighted" },
{ key: "huge_score", label: "Direct support w/o gene sets" },
{ key: "log_bf", label: "Direct support w/ gene sets" },
{ key: "prior", label: "Indirect support" },
],
tableConfig: {
Expand Down Expand Up @@ -175,7 +176,8 @@ new Vue({
this.$store.dispatch("bioPortal/getDiseaseGroups");
this.$store.dispatch("bioPortal/getPhenotypes");
await this.$store.dispatch("getPigeanPhenotypes");
this.pigeanPhenotypeMap = this.mapPhenotypes();
this.pigeanPhenotypeMap =
pigeanUtils.mapPhenotypes(this.$store.state.pigeanAllPhenotypes.data);
},
methods: {
// go to region page
Expand All @@ -188,21 +190,6 @@ new Vue({
}&start=${r.start - expanded}&end=${r.end + expanded}`;
}
},
mapPhenotypes(){
let phenotypeMap = {};
let phenotypes = this.$store.state.pigeanAllPhenotypes.data
phenotypes.forEach(item => {
phenotypeMap[item.phenotype] = this.toOldStyle(item);
});
return phenotypeMap;
},
toOldStyle(newStylePhenotype){
let oldStyle = structuredClone(newStylePhenotype);
oldStyle.description = newStylePhenotype.phenotype_name;
oldStyle.name = newStylePhenotype.phenotype;
oldStyle.group = newStylePhenotype.display_group;
return oldStyle;
},
},

render(createElement, context) {
Expand Down
22 changes: 3 additions & 19 deletions src/views/PIGEAN/GeneSet/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import uiUtils from "@/utils/uiUtils";
import plotUtils from "@/utils/plotUtils";
import sortUtils from "@/utils/sortUtils";
import alertUtils from "@/utils/alertUtils";
import pigeanUtils from "@/utils/pigeanUtils.js";
import Formatters from "@/utils/formatters";
import dataConvert from "@/utils/dataConvert";
import { pageMixin } from "@/mixins/pageMixin.js";
Expand Down Expand Up @@ -148,30 +149,13 @@ new Vue({
this.$store.dispatch("kp4cd/getFrontContents", group.name);
},
},
methods: {
mapPhenotypes(){
let phenotypeMap = {};
let phenotypes = this.$store.state.pigeanAllPhenotypes.data
phenotypes.forEach(item => {
phenotypeMap[item.phenotype] = this.toOldStyle(item);
});
return phenotypeMap;
},
toOldStyle(newStylePhenotype){
let oldStyle = structuredClone(newStylePhenotype);
oldStyle.description = newStylePhenotype.phenotype_name;
oldStyle.name = newStylePhenotype.phenotype;
oldStyle.group = newStylePhenotype.display_group;
return oldStyle;
},
},

async created() {
this.$store.dispatch("queryGeneset", this.$store.state.geneset);
this.$store.dispatch("bioPortal/getDiseaseGroups");
this.$store.dispatch("bioPortal/getPhenotypes");
await this.$store.dispatch("getPigeanPhenotypes");
this.pigeanPhenotypeMap = this.mapPhenotypes();
this.pigeanPhenotypeMap =
pigeanUtils.mapPhenotypes(this.$store.state.pigeanAllPhenotypes.data);
},

render(createElement, context) {
Expand Down
10 changes: 2 additions & 8 deletions src/views/PIGEAN/Index/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import uiUtils from "@/utils/uiUtils";
import plotUtils from "@/utils/plotUtils";
import sortUtils from "@/utils/sortUtils";
import alertUtils from "@/utils/alertUtils";
import pigeanUtils from "@/utils/pigeanUtils.js";
import Formatters from "@/utils/formatters";
import dataConvert from "@/utils/dataConvert";
import keyParams from "@/utils/keyParams";
Expand Down Expand Up @@ -402,18 +403,11 @@ new Vue({
return char.toUpperCase();
});
},
toOldStyle(newStylePhenotype){
let oldStyle = structuredClone(newStylePhenotype);
oldStyle.description = newStylePhenotype.phenotype_name;
oldStyle.name = newStylePhenotype.phenotype;
oldStyle.group = newStylePhenotype.display_group;
return oldStyle;
},
formatAllPhenotypes(){
let newPhenotypes = this.$store.state.pigeanAllPhenotypes.data;
let output = [];
for (let i = 0; i < newPhenotypes.length; i++){
output.push(this.toOldStyle(newPhenotypes[i]));
output.push(pigeanUtils.toOldStyle(newPhenotypes[i]));
}
this.$store.dispatch("phenotypesInSession", output);
}
Expand Down
21 changes: 4 additions & 17 deletions src/views/PIGEAN/NetworkGraph/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import NetworkGraph from "@/components/NetworkGraph.vue";
import SearchHeaderWrapper from "@/components/SearchHeaderWrapper.vue";
import GenesetSizeSelectPicker from "@/components/GenesetSizeSelectPicker.vue";
import keyParams from "@/utils/keyParams";
import pigeanUtils from "@/utils/pigeanUtils.js";
import { pageMixin } from "@/mixins/pageMixin.js";
new Vue({
store,
Expand Down Expand Up @@ -35,7 +36,7 @@ new Vue({
},
methods: {
setSelectedPhenotype(PHENOTYPE) {
let oldStylePhenotype = this.toOldStyle(PHENOTYPE);
let oldStylePhenotype = pigeanUtils.toOldStyle(PHENOTYPE);
this.newPhenotypeSearchKey = oldStylePhenotype.description;
this.phenotypeSearchKey = null;
this.selectedPhenotype = oldStylePhenotype;
Expand All @@ -52,33 +53,19 @@ new Vue({

return isInPhenotype == searchKeys.length ? true : null;
},
toOldStyle(newStylePhenotype){
let oldStyle = structuredClone(newStylePhenotype);
oldStyle.description = newStylePhenotype.phenotype_name;
oldStyle.name = newStylePhenotype.phenotype;
oldStyle.group = newStylePhenotype.display_group;
return oldStyle;
},
searchPhenotype(){
let phenotypeToSearch = this.selectedPhenotype
|| this.pigeanPhenotypeMap[keyParams.phenotype];
this.$store.dispatch("sendSearch", phenotypeToSearch);
},
mapPhenotypes(){
let phenotypeMap = {};
let phenotypes = this.$store.state.pigeanAllPhenotypes.data
phenotypes.forEach(item => {
phenotypeMap[item.phenotype] = this.toOldStyle(item);
});
return phenotypeMap;
},
},
async created() {
this.$store.dispatch("bioPortal/getDiseaseSystems");
this.$store.dispatch("bioPortal/getDiseaseGroups");
this.$store.dispatch("bioPortal/getPhenotypes");
await this.$store.dispatch("getPigeanPhenotypes");
this.pigeanPhenotypeMap = this.mapPhenotypes();
this.pigeanPhenotypeMap =
pigeanUtils.mapPhenotypes(this.$store.state.pigeanAllPhenotypes.data);
let initialPhenotype = this.pigeanPhenotypeMap[keyParams.phenotype];
this.$store.dispatch("sendSearch", initialPhenotype)
},
Expand Down
21 changes: 4 additions & 17 deletions src/views/PIGEAN/Phenotype/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Formatters from "@/utils/formatters";
import uiUtils from "@/utils/uiUtils";
import alertUtils from "@/utils/alertUtils";
import plotUtils from "@/utils/plotUtils";
import pigeanUtils from "@/utils/pigeanUtils.js";
import sessionUtils from "@/utils/sessionUtils";
import sortUtils from "@/utils/sortUtils";
import dataConvert from "@/utils/dataConvert";
Expand Down Expand Up @@ -362,7 +363,8 @@ new Vue({
this.$store.dispatch("bioPortal/getPhenotypes");
this.$store.dispatch("bioPortal/getDatasets");
await this.$store.dispatch("getPigeanPhenotypes");
this.pigeanPhenotypeMap = this.mapPhenotypes();
this.pigeanPhenotypeMap =
pigeanUtils.mapPhenotypes(this.$store.state.pigeanAllPhenotypes.data);
this.lookupInPigeanMap();
},
methods: {
Expand All @@ -372,7 +374,7 @@ new Vue({
uiUtils.getToolTipPosition(ELEMENT);
},
setSelectedPhenotype(PHENOTYPE) {
let oldStylePhenotype = this.toOldStyle(PHENOTYPE);
let oldStylePhenotype = pigeanUtils.toOldStyle(PHENOTYPE);
this.newPhenotypeSearchKey = oldStylePhenotype.description;
this.phenotypeSearchKey = null;
this.$store.dispatch("selectedPhenotype", oldStylePhenotype);
Expand Down Expand Up @@ -420,21 +422,6 @@ new Vue({
});
return data;
},
mapPhenotypes(){
let phenotypeMap = {};
let phenotypes = this.$store.state.pigeanAllPhenotypes.data
phenotypes.forEach(item => {
phenotypeMap[item.phenotype] = this.toOldStyle(item);
});
return phenotypeMap;
},
toOldStyle(newStylePhenotype){
let oldStyle = structuredClone(newStylePhenotype);
oldStyle.description = newStylePhenotype.phenotype_name;
oldStyle.name = newStylePhenotype.phenotype;
oldStyle.group = newStylePhenotype.display_group;
return oldStyle;
},
lookupInPigeanMap(){
let name = keyParams.phenotype;
let phenotype = this.pigeanPhenotypeMap[name];
Expand Down

0 comments on commit cac59ff

Please sign in to comment.