Commit e1b27ecf authored by Piotr Gawron's avatar Piotr Gawron
Browse files

mi rna panel

parent 4491c406
......@@ -72,19 +72,6 @@ GuiConnector.init = function() {
GuiConnector.leftPanelTabNavi = new TabNavi("tabView", {
top : "17px"
});
if (document.getElementById("tabView:chemicalForm:chemicalResults") !== null
&& document.getElementById("tabView:chemicalForm:chemicalResults") !== undefined) {
GuiConnector.chemicalTabNavi = new TabNavi("tabView:chemicalForm:chemicalResults", {
hideRemaining : false,
tabSize : 1,
top : "5px"
});
}
GuiConnector.miRnaTabNavi = new TabNavi("tabView:miRNAForm:miRNAResults", {
hideRemaining : false,
tabSize : 1,
top : "5px"
});
};
/**
......
......@@ -189,46 +189,6 @@ ServerConnector.clearDataMiningOverlay = function() {
_clearMissingConnectionOverlayCollection();
};
/**
* Register 'drug' overlay on the server.
*/
ServerConnector.registerMiRnaOverlay = function() {
_registerMiRnaOverlayCollection([ {
name : "overlayName",
value : ServerConnector.MI_RNA_OVERLAY_NAME,
} ]);
};
ServerConnector.requestMiRnaDetailDataFunction = function(identfiedElement, id) {
_requestMiRnaDetailDataFunction([ {
name : "searchResultIdentifier",
value : id,
}, {
name : "objectIdentifier",
value : identfiedElement.getId(),
}, {
name : "modelIdentifier",
value : identfiedElement.getModelId(),
}, {
name : "type",
value : identfiedElement.getType(),
} ]);
};
/**
* Sends request to the server to refresh data in 'drug' overlay.
*/
ServerConnector.refreshMiRnaOverlay = function() {
_refreshMiRnaOverlayCollection();
};
/**
* Clear data related to 'mirna' overlay.
*/
ServerConnector.clearMiRnaOverlay = function() {
_clearMiRnaOverlayCollection();
};
/**
* Define pack of methods for 'data minig' overlay.
*/
......@@ -238,13 +198,6 @@ ServerConnector._overlayMethods[ServerConnector.DATA_MINING_OVERLAY_NAME] = {
clearFunction : ServerConnector.clearDataMiningOverlay,
};
ServerConnector._overlayMethods[ServerConnector.MI_RNA_OVERLAY_NAME] = {
initFunction : ServerConnector.registerMiRnaOverlay,
refreshFunction : ServerConnector.refreshMiRnaOverlay,
clearFunction : ServerConnector.clearMiRnaOverlay,
requestDetailDataFunction : ServerConnector.requestMiRnaDetailDataFunction,
};
ServerConnector.sendClearRequest = function(overlayName) {
var functions = ServerConnector._overlayMethods[overlayName];
if (functions !== undefined) {
......@@ -254,7 +207,7 @@ ServerConnector.sendClearRequest = function(overlayName) {
} else {
logger.warn("Clear function for " + overlayName + " doesn't exist");
}
} else if (overlayName==="search" || overlayName==="comment" || overlayName ==="drug"|| overlayName ==="chemical"){
} else if (overlayName==="search" || overlayName==="comment" || overlayName ==="drug"|| overlayName ==="chemical" || overlayName ==="mirna"){
logger.warn("Send clear request for overlay that doesn't support it: "+overlayName);
} else {
throw new Error("[Clear function] Unknown overlay: ", overlayName);
......
......@@ -124,6 +124,15 @@ AbstractPanel.prototype.createNewLine=function(count) {
return result;
};
AbstractPanel.prototype.createLink=function(url, name) {
var link = document.createElement("a");
link.href = url;
link.innerHTML = name;
link.style.textDecoration = "underline";
return link;
};
AbstractPanel.prototype.createAnnotationLink=function(element, showType) {
var name, type, hint;
if (element.title!==undefined) {
......@@ -134,14 +143,12 @@ AbstractPanel.prototype.createAnnotationLink=function(element, showType) {
name = element.name;
type = element.type;
}
var link = document.createElement("a");
link.href = element.link;
var link;
if (showType) {
link.innerHTML = type + " (" + name + ")";
link = this.createLink(element.link, type + " (" + name + ")");
} else {
link.innerHTML = name ;
link = this.createLink(element.link, name);
}
link.style.textDecoration = "underline";
if (hint!==undefined) {
var div = document.createElement("div");
div.title = hint;
......
"use strict";
/* exported logger */
var logger = require('../logger');
var AbstractPanel = require('./AbstractPanel');
function MiRnaPanel(params) {
params.panelName = "mirna";
AbstractPanel.call(this, params);
}
MiRnaPanel.prototype = Object.create(AbstractPanel.prototype);
MiRnaPanel.prototype.constructor = MiRnaPanel;
MiRnaPanel.prototype.createPreamble = function(miRna) {
var self = this;
var result = document.createElement("div");
if (miRna === undefined || miRna.getName() === undefined) {
result.appendChild(self.createLabel("NOT FOUND"));
} else {
var line= document.createElement("div");
line.appendChild(self.createLabel("μRna: "));
line.appendChild(self.createLink("http://www.mirbase.org/cgi-bin/mirna_entry.pl?acc=",miRna.getName()));
line.appendChild(self.createNewLine());
result.appendChild(line);
result.appendChild(self.createNewLine());
}
return result;
};
MiRnaPanel.prototype.createTableElement = function(target, icon) {
return this.createTargetRow(target, icon);
};
MiRnaPanel.prototype.searchByQuery = function() {
var self = this;
var query = self.getSearchInput().value;
return self.getOverlayDb().searchByQuery(query);
};
module.exports = MiRnaPanel;
......@@ -10,6 +10,8 @@ var ControlType = require('./map/ControlType');
var CustomMap = require('./map/CustomMap');
var DrugDbOverlay = require('./map/overlay/DrugDbOverlay');
var DrugPanel = require('./gui/DrugPanel');
var MiRnaDbOverlay = require('./map/overlay/MiRnaDbOverlay');
var MiRnaPanel = require('./gui/MiRnaPanel');
var OverlayCollection = require('./map/overlay/OverlayCollection');
var SearchDbOverlay = require('./map/overlay/SearchDbOverlay');
var SearchPanel = require('./gui/SearchPanel');
......@@ -74,6 +76,15 @@ function restoreChemicalQuery(customMap) {
}
};
function restoreMiRnaQuery(customMap) {
var query = ServerConnector.getSessionData().getMiRnaQuery();
if (query!==undefined) {
return customMap.getOverlayByName("mirna").searchByEncodedQuery(query);
} else {
return Promise.resolve();
}
};
function create(params) {
var project = params.project;
if (project===undefined) {
......@@ -136,6 +147,13 @@ function create(params) {
element : document.getElementById("drugTab"),
customMap : result
});
} else if (collectionParams.name === "mirna") {
collection = new MiRnaDbOverlay(collectionParams);
result.registerSource(collection);
new MiRnaPanel({
element : document.getElementById("mirnaTab"),
customMap : result
});
} else if (collectionParams.name === "chemical") {
collection = new ChemicalDbOverlay(collectionParams);
result.registerSource(collection);
......@@ -164,6 +182,8 @@ function create(params) {
}).then(function(){
return restoreChemicalQuery(result);
}).then(function(){
return restoreMiRnaQuery(result);
}).then(function(){
if (ServerConnector.getSessionData().getShowComments()) {
result.getControl(ControlType.COMMENT_CHECKBOX).checked=true;
......
"use strict";
var Helper = require('../helper');
require("../mocha-config.js");
var MiRna = require('../../../main/js/map/data/MiRna');
var MiRnaPanel = require('../../../main/js/gui/MiRnaPanel');
var chai = require('chai');
var assert = chai.assert;
var logger = require('../logger');
describe('MiRnaPanel', function() {
var helper;
before(function() {
helper = new Helper();
});
it('contructor', function() {
var div = helper.createMiRnaTab();
var map = helper.createCustomMap();
helper.createMiRnaDbOverlay(map);
new MiRnaPanel({
element : div,
customMap : map
});
assert.equal(logger.getWarnings().length, 0);
});
it('createMiRnaeader for empty', function() {
var div = helper.createMiRnaTab();
var map = helper.createCustomMap();
helper.createMiRnaDbOverlay(map);
var panel = new MiRnaPanel({
element : div,
customMap : map
});
assert.ok(panel.createPreamble().innerHTML.indexOf("NOT FOUND") > 0);
});
it('createMiRnaeader for empty', function() {
var div = helper.createMiRnaTab();
var map = helper.createCustomMap();
helper.createMiRnaDbOverlay(map);
var panel = new MiRnaPanel({
element : div,
customMap : map
});
assert.ok(panel.createPreamble(new MiRna()).innerHTML.indexOf("NOT FOUND") > 0);
});
it('on searchResults changed', function() {
var div = helper.createMiRnaTab();
var map = helper.createCustomMap();
map.getModel().setId(15781);
var miRnaDbOverlay = helper.createMiRnaDbOverlay(map);
new MiRnaPanel({
element : div,
customMap : map
});
return miRnaDbOverlay.searchByQuery("hsa-miR-125a-3p").then(function() {
assert.equal(logger.getWarnings().length, 0);
assert.ok(div.innerHTML.indexOf("hsa-miR-125a-3p") >= 0);
});
});
it('searchByQuery', function() {
var div = helper.createMiRnaTab();
var map = helper.createCustomMap();
map.getModel().setId(15781);
helper.createMiRnaDbOverlay(map);
var panel = new MiRnaPanel({
element : div,
customMap : map
});
panel.getSearchInput().value = "hsa-miR-125a-3p";
return panel.searchByQuery().then(function() {
assert.equal(logger.getWarnings().length, 0);
assert.ok(div.innerHTML.indexOf("http://www.mirbase.org/cgi-bin/mirna_entry.pl?acc") >= 0);
});
});
});
......@@ -26,12 +26,16 @@ describe('minerva global', function() {
global.chemicalTab = helper.createChemicalTab();
document.body.appendChild(global.chemicalTab);
global.mirnaTab = helper.createMiRnaTab();
document.body.appendChild(global.mirnaTab);
});
afterEach(function() {
document.body.removeChild(global.searchTab);
document.body.removeChild(global.drugTab);
document.body.removeChild(global.chemicalTab);
document.body.removeChild(global.mirnaTab);
});
it('create', function() {
......@@ -167,6 +171,20 @@ describe('minerva global', function() {
});
});
it('create with mirna overlay', function() {
var project = helper.createProject();
project.getModel().setId(15781);
var options = helper.createOptions(project);
options.dataCollections.push({
name : "mirna"
});
return minerva.create(options).then(function(result) {
assert.ok(result);
});
});
it('create with search overlay and GET search param', function() {
GuiConnector.getParams["search"] = "s1";
......
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