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

full reactions have information about products, reactants and modifiers

parent cefd78ce
......@@ -194,18 +194,10 @@ MapModel.prototype.getCompleteReactionById = function(id) {
return Promise.resolve(self._reactions[id]);
} else {
var result;
return ServerConnector.getReactions({
ids : [ id ]
}).then(
function(reactions) {
if (self._reactions[id] === undefined) {
self._reactions[id] = reactions[0];
} else {
self._reactions[id].update(reactions[0]);
}
return self.getReactionById(id).then(
function(result) {
var ids = [];
var i;
result = self._reactions[id];
for (i = 0; i < result.getReactants().length; i++) {
if (!(result.getReactants()[i] instanceof Alias)) {
if (self._aliases[result.getReactants()[i]] === undefined
......@@ -304,7 +296,8 @@ MapModel.prototype.getMissingElements = function(elements) {
var reactionPromise = null;
if (reactionIds.length > 0) {
reactionPromise = ServerConnector.getReactions({
ids : reactionIds
ids : reactionIds,
complete : elements.complete
});
}
......@@ -674,7 +667,7 @@ MapModel.prototype.getByIdentifiedElements = function(identifiedElements, comple
}).then(function() {
var promises = [];
for (var i = 0; i < identifiedElements.length; i++) {
promises.push(self.getByIdentifiedElement(identifiedElements[i]));
promises.push(self.getByIdentifiedElement(identifiedElements[i], complete));
}
return Promise.all(promises);
});
......
"use strict";
var Alias = require('./Alias');
/**
* Class representing reaction data.
*
......@@ -106,7 +108,7 @@ Reaction.prototype.update = function(javaObject) {
this.setDescription(javaObject.notes);
this.setOther(javaObject.other);
this.setReferences(javaObject.references);
if (javaObject.reactants !== "") {
this.setReactants(javaObject.reactants.split(","));
} else {
......@@ -122,13 +124,23 @@ Reaction.prototype.update = function(javaObject) {
} else {
this.setModifiers([]);
}
this.setHierarchyVisibilityLevel(javaObject.hierarchyVisibilityLevel);
this.setIsComplete(true);
};
Reaction.prototype.isComplete = function() {
return this._complete;
var self = this;
var result = self._complete;
var reactants = self.getReactants();
if (reactants.length === 0) {
result = false;
} else {
if (!(self.getReactants()[0] instanceof Alias)) {
result = false;
}
}
return result;
};
Reaction.prototype.setIsComplete = function(complete) {
......@@ -151,15 +163,15 @@ Reaction.prototype.setSymbol = function(symbol) {
this._symbol = symbol;
};
Reaction.prototype.getAbbreviation= function() {
Reaction.prototype.getAbbreviation = function() {
return this._abbreviation;
};
Reaction.prototype.setAbbreviation= function(abbreviation) {
Reaction.prototype.setAbbreviation = function(abbreviation) {
this._abbreviation = abbreviation;
};
Reaction.prototype.getFormula= function() {
Reaction.prototype.getFormula = function() {
return this._formula;
};
......@@ -167,7 +179,7 @@ Reaction.prototype.setFormula = function(formula) {
this._formula = formula;
};
Reaction.prototype.getMechanicalConfidenceScore= function() {
Reaction.prototype.getMechanicalConfidenceScore = function() {
return this._mechanicalConfidenceScore;
};
......@@ -175,7 +187,7 @@ Reaction.prototype.setMechanicalConfidenceScore = function(mechanicalConfidenceS
this._mechanicalConfidenceScore = mechanicalConfidenceScore;
};
Reaction.prototype.getLowerBound= function() {
Reaction.prototype.getLowerBound = function() {
return this._lowerBound;
};
......@@ -183,7 +195,7 @@ Reaction.prototype.setLowerBound = function(lowerBound) {
this._lowerBound = lowerBound;
};
Reaction.prototype.getUpperBound= function() {
Reaction.prototype.getUpperBound = function() {
return this._upperBound;
};
......@@ -195,7 +207,7 @@ Reaction.prototype.setGeneProteinReaction = function(geneProteinReaction) {
this._geneProteinReaction = geneProteinReaction;
};
Reaction.prototype.getGeneProteinReaction= function() {
Reaction.prototype.getGeneProteinReaction = function() {
return this._geneProteinReaction;
};
......@@ -203,7 +215,7 @@ Reaction.prototype.setSubsystem = function(subsystem) {
this._subsystem = subsystem;
};
Reaction.prototype.getSubsystem= function() {
Reaction.prototype.getSubsystem = function() {
return this._subsystem;
};
......@@ -211,7 +223,7 @@ Reaction.prototype.setSynonyms = function(synonyms) {
this._synonyms = synonyms;
};
Reaction.prototype.getSynonyms= function() {
Reaction.prototype.getSynonyms = function() {
return this._synonyms;
};
......@@ -219,7 +231,7 @@ Reaction.prototype.setDescription = function(description) {
this._description = description;
};
Reaction.prototype.getDescription= function() {
Reaction.prototype.getDescription = function() {
return this._description;
};
......
......@@ -4,6 +4,7 @@ var Helper = require('./helper');
require("./mocha-config.js");
var Alias = require('../../main/js/map/data/Alias');
var minerva = require('../../main/js/minerva');
var Project = require('../../main/js/map/data/Project');
var GuiConnectorMock = require('./GuiConnector-mock');
......@@ -281,6 +282,27 @@ describe('minerva global', function() {
});
});
it("getBioEntityById for reaction", function() {
var options = {
projectId : "sample",
element : testDiv
};
var globalResult;
return minerva.create(options).then(function(result) {
globalResult = result;
return result.getBioEntityById({
id : 153508,
modelId : 15781,
type : "REACTION"
});
}).then(function(result) {
assert.ok(result);
assert.ok(result.getReactants()[0] instanceof Alias);
}).then(function() {
globalResult.destroy();
});
});
it("showElement", function() {
var options = {
projectId : "sample",
......
[{"symbol":null,"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","fullName":null,"complexId":null,"type":"Antisense RNA","abbreviation":null,"compartmentId":null,"name":"s6","bounds":{"x":101.0,"width":90.0,"y":129.5,"height":25.0},"formula":null,"id":329167,"hierarchyVisibilityLevel":0},{"symbol":null,"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","fullName":null,"complexId":null,"type":"RNA","abbreviation":null,"compartmentId":null,"name":"s5","bounds":{"x":0.0,"width":90.0,"y":118.5,"height":25.0},"formula":null,"id":329168,"hierarchyVisibilityLevel":0}]
\ No newline at end of file
[{"symbol":null,"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","fullName":null,"complexId":null,"type":"Antisense RNA","abbreviation":null,"compartmentId":null,"name":"s6","bounds":{"x":101.0,"width":90.0,"y":129.5,"height":25.0},"formula":null,"id":329167,"hierarchyVisibilityLevel":0},{"symbol":null,"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","fullName":null,"complexId":null,"type":"Unknown","abbreviation":null,"compartmentId":null,"name":"s11","bounds":{"x":105.0,"width":70.0,"y":203.5,"height":25.0},"formula":null,"id":329169,"hierarchyVisibilityLevel":0}]
\ No newline at end of file
[{"symbol":null,"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","fullName":null,"complexId":null,"type":"Antisense RNA","abbreviation":null,"compartmentId":null,"name":"s6","bounds":{"x":101.0,"width":90.0,"y":129.5,"height":25.0},"formula":null,"id":329167,"hierarchyVisibilityLevel":0},{"symbol":null,"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","fullName":null,"complexId":null,"type":"Phenotype","abbreviation":null,"compartmentId":null,"name":"s7","bounds":{"x":213.0,"width":80.0,"y":128.0,"height":30.0},"formula":null,"id":329172,"hierarchyVisibilityLevel":0}]
\ No newline at end of file
Supports Markdown
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