Commit 4491c406 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

MiRna Overlay Db implemented

parent b806fc06
......@@ -16,6 +16,7 @@ var IdentifiedElement= require('./map/data/IdentifiedElement');
var LayoutAlias = require('./map/data/LayoutAlias');
var LayoutData = require('./map/data/LayoutData');
var LayoutReaction = require('./map/data/LayoutReaction');
var MiRna = require('./map/data/MiRna');
var Project = require('./map/data/Project');
var Reaction = require('./map/data/Reaction');
var SessionData = require('./SessionData');
......@@ -690,6 +691,41 @@ ServerConnector.getDrugsByTargetUrl = function(params) {
});
};
ServerConnector.getMiRnasByQueryUrl = function(params) {
var query = params.query;
var projectId = params.projectId;
var token = params.token;
return this.getApiUrl({type:"miRna",
method:"getMiRnasByQuery",
params: {
projectId: projectId,
query: query,
token: token},
});
};
ServerConnector.getMiRnasByTargetUrl = function(params) {
var query = params.query;
var projectId = params.projectId;
var token = params.token;
var columns = this.idsToString(params.columns);
var targetId = params.target.getId();
var targetType = params.target.getType();
return this.getApiUrl({type:"miRna",
method:"getMiRnasByTarget",
params: {
projectId: projectId,
query: query,
columns: columns,
token: token,
targetId: targetId,
targetType: targetType,
},
});
};
ServerConnector.getChemicalsByQueryUrl = function(params) {
var query = params.query;
var projectId = params.projectId;
......@@ -1012,6 +1048,28 @@ ServerConnector.getDrugsByQuery = function(params) {
});
};
ServerConnector.getMiRnasByQuery = function(params) {
var self = this;
return new Promise(function(resolve, reject) {
return self.getProjectId(params.projectId).then(function(result) {
params.projectId = result;
return self.getToken();
}).then(function(token) {
params.token = token;
return self.readFile(self.getMiRnasByQueryUrl(params));
}).then(function(content) {
var array=JSON.parse(content);
var result = [];
for (var i = 0; i < array.length; i++) {
result.push(new MiRna(array[i]));
}
resolve(result);
}).catch(function(exception){
reject(exception);
});
});
};
ServerConnector.getChemicalsByQuery = function(params) {
var self = this;
return new Promise(function(resolve, reject) {
......@@ -1057,6 +1115,29 @@ ServerConnector.getDrugNamesByTarget = function(params) {
});
};
ServerConnector.getMiRnaNamesByTarget = function(params) {
var self = this;
params.columns = ["name"];
return new Promise(function(resolve, reject) {
return self.getProjectId(params.projectId).then(function(result) {
params.projectId = result;
return self.getToken();
}).then(function(token) {
params.token = token;
return self.readFile(self.getMiRnasByTargetUrl(params));
}).then(function(content) {
var result = [];
var object = JSON.parse(content);
for (var i=0;i<object.length;i++){
result.push(object[i].name);
}
resolve(result);
}).catch(function(exception){
reject(exception);
});
});
};
ServerConnector.getChemicalNamesByTarget = function(params) {
var self = this;
params.columns = ["name"];
......
......@@ -36,6 +36,8 @@ SessionData.prototype.setQuery = function(param) {
this.setSearchQuery(param.query);
} else if (param.type === "chemical") {
this.setChemicalQuery(param.query);
} else if (param.type === "mirna") {
this.setMiRnaQuery(param.query);
} else {
throw new Error("Invalid query type: " + param.type);
}
......@@ -64,6 +66,20 @@ SessionData.prototype.getDrugQuery = function() {
return result;
};
SessionData.prototype.setMiRnaQuery = function(value) {
var key = this.getKey(SessionObjectType.MI_RNA_QUERY);
Cookies.set(key, JSON.stringify(value));
};
SessionData.prototype.getMiRnaQuery = function() {
var key = this.getKey(SessionObjectType.MI_RNA_QUERY);
var result = Cookies.get(key);
if (result !== undefined) {
result = JSON.parse(result);
}
return result;
};
SessionData.prototype.setChemicalQuery = function(value) {
var key = this.getKey(SessionObjectType.CHEMICAL_QUERY);
Cookies.set(key, JSON.stringify(value));
......
......@@ -3,6 +3,7 @@
var SessionObjectType = {
CHEMICAL_QUERY : "CHEMICAL_QUERY",
DRUG_QUERY : "DRUG_QUERY",
MI_RNA_QUERY : "MI_RNA_QUERY",
SHOW_COMMENT : "SHOW_COMMENT",
SELECTED_BACKGROUND_OVERLAY : "SELECTED_BACKGROUND_OVERLAY",
SEARCH_QUERY : "SEARCH_QUERY",
......
"use strict";
var Target = require("./Target");
function MiRna(javaObject) {
if (javaObject !== undefined) {
this.setName(javaObject.name);
this.setId(javaObject.id);
this.setTargets(javaObject.targets);
}
}
MiRna.prototype.setName = function(name) {
this._name = name;
};
MiRna.prototype.getName = function() {
return this._name;
};
MiRna.prototype.setId = function(id) {
this._id = id;
};
MiRna.prototype.getId = function() {
return this._id;
};
MiRna.prototype.setTargets = function(targets) {
this._targets = [];
for (var i = 0; i < targets.length; i++) {
this._targets.push(new Target(targets[i]));
}
};
MiRna.prototype.getTargets = function() {
return this._targets;
};
module.exports = MiRna;
"use strict";
var logger = require('../../logger');
var Promise = require("bluebird");
var IdentifiedElement = require('../data/IdentifiedElement');
var AbstractTargettingDbOverlay = require('./AbstractTargettingDbOverlay');
var ServerConnector = require('../../ServerConnector');
function MiRnaDbOverlay(params) {
params.iconType= "target";
params.iconColorStart = 2;
// call super constructor
AbstractTargettingDbOverlay.call(this, params);
}
MiRnaDbOverlay.prototype = Object.create(AbstractTargettingDbOverlay.prototype);
MiRnaDbOverlay.prototype.constructor = MiRnaDbOverlay;
MiRnaDbOverlay.prototype.getNamesByTargetFromServer = function(param) {
return ServerConnector.getMiRnaNamesByTarget(param);
}
MiRnaDbOverlay.prototype.getElementsByQueryFromServer = function(param) {
return ServerConnector.getMiRnasByQuery(param);
}
module.exports = MiRnaDbOverlay;
......@@ -14,6 +14,7 @@ var IdentifiedElement = require("../../main/js/map/data/IdentifiedElement");
var LayoutAlias = require("../../main/js/map/data/LayoutAlias");
var LayoutData = require("../../main/js/map/data/LayoutData");
var LayoutReaction = require("../../main/js/map/data/LayoutReaction");
var MiRnaDbOverlay = require("../../main/js/map/overlay/MiRnaDbOverlay");
var Model = require("../../main/js/map/data/MapModel");
var OverlayCollection = require("../../main/js/map/overlay/OverlayCollection");
var Project = require("../../main/js/map/data/Project");
......@@ -36,6 +37,10 @@ Helper.prototype.createChemicalTab = function() {
return this.createPanelTab("chemicalTab");
};
Helper.prototype.createMiRnaTab = function() {
return this.createPanelTab("mirnaTab");
};
Helper.prototype.createPanelTab = function(id) {
var result = document.createElement("div");
result.id = id;
......@@ -115,6 +120,17 @@ Helper.prototype.createChemicalDbOverlay = function(map) {
return result;
};
Helper.prototype.createMiRnaDbOverlay = function(map) {
var result = new MiRnaDbOverlay({
map : map,
name : "mirna",
allowGeneralSearch : true,
allowSearchById : true,
});
map.registerSource(result);
return result;
};
Helper.prototype.createComment = function(element) {
var elementType = "ALIAS";
var elementId = this.idCounter++;
......
"use strict";
var Helper = require('../../Helper');
var logger = require('../../logger');
var IdentifiedElement = require('../../../../main/js/map/data/IdentifiedElement');
var MiRnaDbOverlay = require('../../../../main/js/map/overlay/MiRnaDbOverlay');
var assert = require('assert');
describe('MiRnaDbOverlay', function() {
var helper;
before(function() {
helper = new Helper();
});
it("constructor 1", function() {
var map = helper.createCustomMap();
var oc = new MiRnaDbOverlay({
map : map,
name : 'miRna'
});
assert.ok(oc);
assert.equal(oc.getName(), 'miRna');
assert.equal(logger.getWarnings.length, 0);
});
it("searchByQuery", function() {
var map = helper.createCustomMap();
map.getModel().setId(15781);
var searchDb = helper.createMiRnaDbOverlay(map);
return searchDb.searchByQuery("hsa-miR-125a-3p").then(function(miRnas) {
assert.equal(miRnas.length, 1);
assert.equal(searchDb.getQueries().length, 1);
return searchDb.getElementsByQuery(searchDb.getQueries()[0]);
}).then(function(elements) {
assert.equal(elements.length, 3);
return searchDb.getIdentifiedElements();
}).then(function(elements) {
assert.equal(elements.length, 0);
});
});
it("searchNamesByTarget", function() {
var map = helper.createCustomMap();
map.getModel().setId(15781);
var searchDb = helper.createMiRnaDbOverlay(map);
var target = new IdentifiedElement({
type : "ALIAS",
id : 329170,
modelId : 15781,
});
return searchDb.searchNamesByTarget(target).then(function(miRnaNames) {
assert.equal(miRnaNames.length, 0);
});
});
});
[{"name":"hsa-miR-125a-3p","id":"hsa-miR-125a-3p","targets":[{"targetElements":[],"references":[{"title":"microRNA-125a-3p reduces cell proliferation and migration by targeting Fyn.","authors":["Ninio-Many L"," Grossman H"," Shomron N"," Chuderland D"," Shalgi R."],"journal":"Journal of cell science","year":2013,"link":"http://www.ncbi.nlm.nih.gov/pubmed/23606749","id":"23606749","citationCount":6}],"name":"FYN","targetParticipants":[{"name":"FYN","type":"HGNC Symbol","link":"http://www.genenames.org/cgi-bin/gene_symbol_report?match\u003dFYN","idObject":0}]},{"targetElements":[],"references":[{"title":"MicroRNA-125a inhibits cell growth by targeting glypican-4.","authors":["Feng C"," Li J"," Ruan J"," Ding K."],"journal":"Glycoconjugate journal","year":2012,"link":"http://www.ncbi.nlm.nih.gov/pubmed/22644326","id":"22644326","citationCount":4}],"name":"GPC4","targetParticipants":[{"name":"GPC4","type":"HGNC Symbol","link":"http://www.genenames.org/cgi-bin/gene_symbol_report?match\u003dGPC4","idObject":0}]},{"targetElements":[],"references":[{"title":"MiRNA-125a-3p is a negative regulator of the RhoA-actomyosin pathway in A549 cells.","authors":["Huang B"," Luo W"," Sun L"," Zhang Q"," Jiang L"," Chang J"," Qiu X"," Wang E."],"journal":"International journal of oncology","year":2013,"link":"http://www.ncbi.nlm.nih.gov/pubmed/23525486","id":"23525486","citationCount":4}],"name":"RHOA","targetParticipants":[{"name":"RHOA","type":"HGNC Symbol","link":"http://www.genenames.org/cgi-bin/gene_symbol_report?match\u003dRHOA","idObject":0}]}]}]
\ No newline at end of file
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