Skip to content

Commit

Permalink
Metabolic pathways visualisation (#731): load pathway from url
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriiKrasnov committed Apr 4, 2022
1 parent 06d35f0 commit 30a1988
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
7 changes: 6 additions & 1 deletion client/client/app/app.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class ngbAppController extends baseController {
projectContext,
miewContext,
heatmapContext,
ngbPathwaysService,
eventHotkey,
$stateParams,
$rootScope,
Expand All @@ -41,6 +42,7 @@ export default class ngbAppController extends baseController {
projectContext,
miewContext,
heatmapContext,
ngbPathwaysService,
projectDataService,
utilsDataService,
apiService,
Expand Down Expand Up @@ -213,7 +215,8 @@ export default class ngbAppController extends baseController {
filterByGenome,
collapsedTrackHeaders,
miew,
heatmap
heatmap,
pathway
} = params;
const position = start
? {end, start}
Expand All @@ -226,6 +229,7 @@ export default class ngbAppController extends baseController {
}
this.miewContext.routeInfo = miew;
this.heatmapContext.routeInfo = heatmap;
this.ngbPathwaysService.routeInfo = pathway;
const tracksState = tracks
? this.projectContext
.convertTracksStateFromJson(tracks)
Expand Down Expand Up @@ -318,6 +322,7 @@ export default class ngbAppController extends baseController {
}
state.miew = this.miewContext.routeInfo;
state.heatmap = this.heatmapContext.routeInfo;
state.pathway = this.ngbPathwaysService.routeInfo;
this.$state.go(this.$state.current.name, state, options);
}

Expand Down
8 changes: 5 additions & 3 deletions client/client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import routes from './app.routes';
import './app.scss';
import angularMaterial from './compat/angularMaterial';
import components from './components';
import PathwaysService from './components/ngbPathways/ngbPathways.service.js';
import AppearanceContext from './shared/appearanceContext';
import BamCoverageContext from './shared/bamCoverageContext';
import BLASTContext from './shared/blastContext';
import browserDetect from './shared/browserDetect';
import sharedComponents from './shared/components';
Expand All @@ -33,10 +36,8 @@ import HeatmapContext from './shared/heatmapContext';
import './shared/hotkeys';
import lastActionRepeater from './shared/lastActionRepeater';
import MiewContext from './shared/miewContext';
import NotificationsContext from './shared/notificationsContext';
import AppearanceContext from './shared/appearanceContext';
import MotifsContext from './shared/motifsContext';
import BamCoverageContext from './shared/bamCoverageContext';
import NotificationsContext from './shared/notificationsContext';

// Import internal modules
import projectContext from './shared/projectContext';
Expand Down Expand Up @@ -79,4 +80,5 @@ export default angular.module('NGB', [
.service('appearanceContext', AppearanceContext.instance)
.service('motifsContext', MotifsContext.instance)
.service('bamCoverageContext', BamCoverageContext.instance)
.service('ngbPathwaysService', PathwaysService.instance)
.name;
3 changes: 2 additions & 1 deletion client/client/app/app.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function routes($urlRouterProvider, $httpProvider, $stateProvider
collapsedTrackHeaders: null,
miew: null,
heatmap: null,
pathway: null,
embedded: null,
controls: null
},
Expand All @@ -31,7 +32,7 @@ export default function routes($urlRouterProvider, $httpProvider, $stateProvider
},
reloadOnSearch: false,
template: require('./app.tpl.html'),
url: '/:referenceId/:chromosome/:start/:end?rewrite&bookmark&screenshot&toolbar&layout&tracks&filterByGenome&collapsedTrackHeaders&miew&heatmap&embedded&controls'
url: '/:referenceId/:chromosome/:start/:end?rewrite&bookmark&screenshot&toolbar&layout&tracks&filterByGenome&collapsedTrackHeaders&miew&heatmap&embedded&controls&pathway'
});

}
2 changes: 0 additions & 2 deletions client/client/app/components/ngbPathways/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import cytoscapePathwayComponent from './ngbCytoscapePathway';
// Import components
import ngbInternalPathwaysResult from './ngbInternalPathwaysResult';
import ngbInternalPathwaysTable from './ngbInternalPathwaysTable';
import service from './ngbPathways.service';
import ngbPathwaysAnnotation from './ngbPathwaysAnnotation';
import ngbPathwaysColorSchemePreference from './ngbPathwaysColorSchemePreference';

Expand All @@ -26,7 +25,6 @@ export default angular
ngbPathwaysColorSchemePreference,
ngbPathwaysAnnotation
])
.service('ngbPathwaysService', service.instance)
.component('ngbPathwaysPanel', ngbPathwaysPanel)
.controller(controller.UID, controller)
.name;
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class ngbInternalPathwaysTableService extends ClientPaginationSer
}

async loadInternalPathways(currentSearch) {
if (currentSearch.rewriteSpecies) {
if (currentSearch && currentSearch.rewriteSpecies) {
this.internalPathwaysFilter.organisms = currentSearch.speciesList;
currentSearch.speciesList = [];
currentSearch.rewriteSpecies = false;
Expand All @@ -125,7 +125,7 @@ export default class ngbInternalPathwaysTableService extends ClientPaginationSer
pageNum: this.currentPage
},
sortInfo: this.orderBy ? this.orderBy[0] : null,
term: currentSearch.search || '',
term: currentSearch && currentSearch.search || '',
taxIds: this.internalPathwaysFilter.organisms || []
};

Expand Down
34 changes: 32 additions & 2 deletions client/client/app/components/ngbPathways/ngbPathways.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class ngbPathwaysService {
...loadedState,
internalPathway: this._currentInternalPathway
}));
this.report();
}

_currentState;
Expand All @@ -72,6 +73,30 @@ export default class ngbPathwaysService {
}));
}

get routeInfo() {
if (this.currentInternalPathway) {
return JSON.stringify(this.currentInternalPathway);
}
return null;
}

set routeInfo(routeInfo) {
try {
if (routeInfo) {
const internalPathway = JSON.parse(routeInfo);
const state = {
internalPathway,
state: this.pathwaysStates.INTERNAL_PATHWAYS_RESULT
};
this.initState(state);
this.dispatcher.emit('load:pathways', state);
}
} catch (_) {
this.currentState = this.pathwaysStates.INTERNAL_PATHWAYS;
}
}


static instance(dispatcher, projectContext,
ngbInternalPathwaysTableService, ngbInternalPathwaysResultService,
ngbPathwaysAnnotationService) {
Expand All @@ -92,14 +117,14 @@ export default class ngbPathwaysService {
...loadedState
};
this._currentState = loadedState.state;
this._currentInternalPathway = loadedState.internalPathway;
this.currentInternalPathway = loadedState.internalPathway;
}

recoverLocalState(state) {
if (state) {
this.initState(state.layout);
this.ngbPathwaysAnnotationService.initState(state.annotations);
this.dispatcher.emit('session:load:pathways', state.layout);
this.dispatcher.emit('load:pathways', state.layout);
}
}

Expand All @@ -110,4 +135,9 @@ export default class ngbPathwaysService {
};
}

report() {
this.dispatcher.emitGlobalEvent('route:change');
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class ngbPathwaysPanelController extends baseController {
this.searchRequest = data ? data.search : null;
this.changeState('INTERNAL_PATHWAYS');
},
'session:load:pathways': data => {
'load:pathways': data => {
if (data && data.state) {
this.changeState(data.state);
}
Expand Down Expand Up @@ -44,7 +44,11 @@ export default class ngbPathwaysPanelController extends baseController {
this.currentPathwaysState = this.pathwaysStates[state];
this.service = this.ngbPathwaysService.pathwaysServiceMap[this.currentPathwaysState];
switch (state) {
case this.pathwaysStates.INTERNAL_PATHWAYS:
case this.pathwaysStates.INTERNAL_PATHWAYS: {
this.ngbPathwaysService.currentInternalPathway = undefined;
this.tabSelected = this.pathwaysStates.INTERNAL_PATHWAYS;
break;
}
case this.pathwaysStates.INTERNAL_PATHWAYS_RESULT: {
this.tabSelected = this.pathwaysStates.INTERNAL_PATHWAYS;
break;
Expand Down

0 comments on commit 30a1988

Please sign in to comment.