Commit a5eca9c1 authored by Marek Ostaszewski's avatar Marek Ostaszewski
Browse files

initial changes

parent d030407a
Pipeline #7082 failed with stages
in 35 seconds
{
"name": "minerva-plugins-starter-kit",
"version": "1.0.0",
"name": "minerva-plugins-gsea",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"build-css": "node-sass --include-path src/css src/css/styles.scss src/css/styles.css",
"build": "mkdirp dist && npm run build-css && browserify -t [ babelify --presets es2015 ] -t browserify-css src/js/index.js | uglifyjs --compress --mangle > dist/plugin.js ",
"watch-js": "mkdirp dist && npm run build-css && watchify -v -t [ babelify --presets es2015 ] -t browserify-css src/js/index.js -o dist/plugin.js",
"build": "mkdirp dist && npm run build-css && browserify -t [ babelify --presets es2015 ] -t browserify-css src/js/index.js | uglifyjs --compress --mangle > ~/Dropbox/GSEA_plugin/plugin.js ",
"build-debug": "mkdirp dist && npm run build-css && browserify -t [ babelify --presets es2015 ] -t browserify-css src/js/index.js > ~/Dropbox/GSEA_plugin/plugin.js ",
"watch-js": "mkdirp dist && npm run build-css && watchify -v -t [ babelify --presets es2015 ] -t browserify-css src/js/index.js -o ~/Dropbox/GSEA_plugin/plugin.js",
"clean": "rimraf dist"
},
"author": "David Hoksza",
"author": "David Hoksza and Marek Ostaszewski",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
......@@ -23,4 +24,4 @@
"uglify-js": "^3.1.9",
"watchify": "^3.9.0"
}
}
}
\ No newline at end of file
require('../css/styles.css');
const pluginName = 'starter-kit';
const pluginVersion = '1.0.1';
const pluginName = 'GSEA';
const pluginVersion = '0.0.1';
const minervaProxyServer = 'https://minerva-dev.lcsb.uni.lu/minerva-proxy/';
const globals = {
selected: [],
allBioEntities: [],
pathways: [],
pickedRandomly: undefined
};
......@@ -33,6 +34,8 @@ const register = function(_minerva) {
console.log('project id: ', minervaProxy.project.data.getProjectId());
console.log('model id: ', minervaProxy.project.data.getModels()[0].modelId);
globals.modelIds = minervaProxy.project.data.getModels();
initPlugin();
};
......@@ -59,7 +62,8 @@ minervaDefine(function (){
register: register,
unregister: unregister,
getName: getName,
getVersion: getVersion
getVersion: getVersion,
minWidth: 400
}
});
......@@ -86,6 +90,7 @@ function unregisterListeners() {
function deHighlightAll(){
pluginContainer.find('.panel-events .panel-body').html('');
return minervaProxy.project.map.getHighlightedBioEntities().then( highlighted => minervaProxy.project.map.hideBioEntity(highlighted) );
}
......@@ -98,16 +103,15 @@ function initMainPageStructure(){
const container = $('<div class="' + pluginName + '-container"></div>').appendTo(pluginContainer);
container.append(`
<div class="panel panel-default panel-events">
<div class="panel-heading">Events (Select an element in the map)</div>
<div class="panel-heading">Gene Set Enrichment Analysis</div>
<div class="panel-body">
</div>
</div>
`);
container.append('<button type="button" class="btn-focus btn btn-primary btn-default btn-block">Focus</button>');
container.append('<button type="button" class="btn-highlight btn btn-primary btn-default btn-block">Highlight</button>');
container.append('<button type="button" class="btn-calc btn btn-primary btn-default btn-block">Enrich for active overlays</button>');
container.append('<hr>');
container.append('<button type="button" class="btn-pick-random btn btn-primary btn-default btn-block">Retrieve random object from map</button>');
container.append('<button type="button" class="btn-reset btn btn-primary btn-default btn-block">Reset</button>');
container.append(`
<div class="panel panel-default panel-randomly-picked">
<div class="panel-heading">Randomly picked object</div>
......@@ -156,9 +160,8 @@ function initMainPageStructure(){
</div>
`);
container.find('.btn-highlight').on('click', () => highlightSelected() );
container.find('.btn-focus').on('click', () => focusOnSelected() );
container.find('.btn-pick-random').on('click', () => pickRandom() );
container.find('.btn-calc').on('click', () => calculatePathways() );
container.find('.btn-reset').on('click', () => deHighlightAll() );
container.find('.btn-highlight-random').on('click', () => highlightSelected(true) );
container.find('.btn-focus-random').on('click', () => focusOnSelected(true) );
container.find('.btn-uniprot').on('click', () => retrieveUniprot() );
......@@ -231,7 +234,70 @@ function highlightSelected(pickedRandomly = false) {
minervaProxy.project.map.showBioEntity(highlightDefs);
}
function focusOnSelected(pickedRandomly = false) {
//temp1.project.map.getVisibleDataOverlays().then(function(data) { console.log(data)})
function calculatePathways() {
function populatePathways(){
const pathwayObjs = [];
const pgrObjects = [];
// For the time being, handle only the main map
// minervaProxy.project.data.getModels() registered earlier
globals.allBioEntities.forEach( e => {
if(e.getModelId() == globals.modelIds[0].modelId) {
var this_type = e.getType();
if(this_type == "Compartment" && e.getElementId().startsWith("art")){
pathwayObjs.push(e)
}
else if (this_type == "Protein" || this_type == "RNA" || this_type == "Gene" ) {
pgrObjects.push(e)
}
}
});
}
let html = "";
pathwayObjs.forEach(
e => { html += `${e.getElementId()} - ${e.getName()}; `; }
);
pluginContainer.find('.panel-events .panel-body').html(html);
const highlightDefs = [];
pathwayObjs.forEach( e => {
highlightDefs.push({
element: {
id: e.getId(),
modelId: e.getModelId(),
type: e.constructor.name.toUpperCase()
},
type: "SURFACE",
options: {
color: '#00FF00',
opacity: 0.5
}
});
});
minervaProxy.project.map.showBioEntity(highlightDefs);
if (globals.allBioEntities.length > 0) {
populatePathways();
}
else {
minervaProxy.project.data.getAllBioEntities().then(function(bioEntities) {
globals.allBioEntities = bioEntities;
populatePathways();
});
}
}
function calculateGSEA() {
function focus(entity) {
if (entity.constructor.name === 'Alias') {
......@@ -253,6 +319,17 @@ function focusOnSelected(pickedRandomly = false) {
}
}
if (globals.allBioEntities.length > 0) {
pick();
}
else {
minervaProxy.project.data.getAllBioEntities().then(function(bioEntities) {
globals.allBioEntities = bioEntities;
pick();
});
}
if (!pickedRandomly && globals.selected.length > 0) focus(globals.selected[0]);
if (pickedRandomly && globals.pickedRandomly) focus(globals.pickedRandomly);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment