Commit 88d8e224 authored by Jean-Clement Gallardo's avatar Jean-Clement Gallardo
Browse files

Finish hotfix/MappingInJSON

parents d580f11e 67c4f86e
......@@ -305,35 +305,35 @@ metExploreD3.GraphMapping = {
switch (mapping.getTargetLabel()) {
case "reactionDBIdentifier":
mapping.getData().forEach(function (map) {
if (typeof map.getNode() == "object")
node = networkData.getNodeByDbIdentifier(map.getNode().getDbIdentifier());
if (typeof map == "object")
node = networkData.getNodeByDbIdentifier(map.node);
else
node = networkData.getNodeByDbIdentifier(map.getNode());
node = networkData.getNodeByDbIdentifier(map);
if (node != undefined) {
var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
var mapNode = new MappingData(node, map.mappingName, map.conditionName, map.mapValue);
node.addMappingData(mapNode);
links = networkData.getLinkByDBIdReaction(node.getDbIdentifier());
links = networkData.getLinkByDBIdReaction(map.node);
links.forEach(function (link) {
link.addMappingData(mapNode);
})
});
}
});
break;
case "reactionId":
mapping.getData().forEach(function (map) {
if (typeof map.getNode() == "object")
var node = networkData.getNodeById(map.getNode().getId());
if (typeof map == "object")
var node = networkData.getNodeById(map.node);
else
var node = networkData.getNodeById(map.getNode());
var node = networkData.getNodeById(map);
if (node != undefined) {
var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
var mapNode = new MappingData(node, map.mappingName, map.conditionName, map.mapValue);
node.addMappingData(mapNode);
links = networkData.getLinkByDBIdReaction(node.getDbIdentifier());
links = networkData.getLinkByDBIdReaction(map.node);
links.forEach(function (link) {
link.addMappingData(mapNode);
})
......@@ -343,13 +343,13 @@ metExploreD3.GraphMapping = {
case "metaboliteId":
mapping.getData().forEach(function (map) {
if (typeof map.getNode() == "object")
var node = networkData.getNodeById(map.getNode().getId());
if (typeof map == "object")
var node = networkData.getNodeById(map.node);
else
var node = networkData.getNodeById(map.getNode());
var node = networkData.getNodeById(map);
if (node != undefined) {
var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
var mapNode = new MappingData(node, map.mappingName, map.conditionName, map.mapValue);
node.addMappingData(mapNode);
}
});
......@@ -357,13 +357,13 @@ metExploreD3.GraphMapping = {
case "metaboliteDBIdentifier":
mapping.getData().forEach(function (map) {
if (typeof map.getNode() == "object")
var node = networkData.getNodeByDbIdentifier(map.getNode().getDbIdentifier());
if (typeof map == "object")
var node = networkData.getNodeByDbIdentifier(map.node);
else
var node = networkData.getNodeByDbIdentifier(map.getNode());
var node = networkData.getNodeByDbIdentifier(map);
if (node != undefined) {
var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
var mapNode = new MappingData(node, map.mappingName, map.conditionName, map.mapValue);
node.addMappingData(mapNode);
}
});
......@@ -400,6 +400,124 @@ metExploreD3.GraphMapping = {
}, 1);
}
},
// Initial function reloadMapping
// reloadMapping : function(mapping) {
//
// var session = _metExploreViz.getSessionById('viz');
// var force = session.getForce();
// force.stop();
// var myMask = metExploreD3.createLoadMask("Mapping in progress...", 'graphPanel');
// if(myMask!= undefined){
//
// metExploreD3.showMask(myMask);
// setTimeout(
// function() {
// try {
// var session = _metExploreViz.getSessionById('viz');
// var networkData = session.getD3Data();
// var conditions = mapping.getConditions().filter(function (c) {
// return c !== "PathwayCoverage" && c !== "PathwayEnrichment"
// });
// var node = undefined;
// var links = undefined;
// switch (mapping.getTargetLabel()) {
// case "reactionDBIdentifier":
// mapping.getData().forEach(function (map) {
// if (typeof map.getNode() == "object")
// node = networkData.getNodeByDbIdentifier(map.getNode().getDbIdentifier());
// else
// node = networkData.getNodeByDbIdentifier(map.getNode());
//
// if (node != undefined) {
// var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
// node.addMappingData(mapNode);
//
// links = networkData.getLinkByDBIdReaction(node.getDbIdentifier());
// links.forEach(function (link) {
// link.addMappingData(mapNode);
// })
// }
// });
// break;
//
// case "reactionId":
// mapping.getData().forEach(function (map) {
// if (typeof map.getNode() == "object")
// var node = networkData.getNodeById(map.getNode().getId());
// else
// var node = networkData.getNodeById(map.getNode());
//
// if (node != undefined) {
// var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
// node.addMappingData(mapNode);
//
// links = networkData.getLinkByDBIdReaction(node.getDbIdentifier());
// links.forEach(function (link) {
// link.addMappingData(mapNode);
// })
// }
// });
// break;
//
// case "metaboliteId":
// mapping.getData().forEach(function (map) {
// if (typeof map.getNode() == "object")
// var node = networkData.getNodeById(map.getNode().getId());
// else
// var node = networkData.getNodeById(map.getNode());
//
// if (node != undefined) {
// var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
// node.addMappingData(mapNode);
// }
// });
// break;
//
// case "metaboliteDBIdentifier":
// mapping.getData().forEach(function (map) {
// if (typeof map.getNode() == "object")
// var node = networkData.getNodeByDbIdentifier(map.getNode().getDbIdentifier());
// else
// var node = networkData.getNodeByDbIdentifier(map.getNode());
//
// if (node != undefined) {
// var mapNode = new MappingData(node, mapping.getName(), map.getConditionName(), map.getMapValue());
// node.addMappingData(mapNode);
// }
// });
// break;
// case "inchi":
// // Blah
// break;
// default:
// metExploreD3.displayMessage("Warning", 'The type of node "' + mapping.getTargetLabel() + '" isn\'t know.')
// }
//
// metExploreD3.hideMask(myMask);
//
// var anim = session.isAnimated("viz");
// if (anim) {
// var force = session.getForce();
//
// force.alpha(force.alpha()).restart();
// }
// }
// catch (e) {
// e.functionUsed="reloadMapping";
// metExploreD3.hideMask(myMask);
//
// var anim=session.isAnimated("viz");
// if (anim) {
// var session = _metExploreViz.getSessionById('viz');
// var force = session.getForce();
//
// force.alpha(force.alpha()).restart();
// }
// throw e;
// }
// }, 1);
// }
// },
/***********************************************
* Mapping to discrete data
* This function will look at metabolites that have data
......
......@@ -348,7 +348,8 @@ metExploreD3.GraphPanel = {
if(jsonParsed.mappings)
{
jsonParsed.mappings.forEach(function(mapping){
var mapping = new Mapping(mapping.name, mapping.conditions, mapping.targetLabel);
var mapping = new Mapping(mapping.name, mapping.conditions, mapping.targetLabel, mapping.data);
mapping.data = mapping.id;
_metExploreViz.addMapping(mapping);
});
}
......
......@@ -1356,6 +1356,7 @@ metExploreD3.GraphUtils = {
networkJSON+=",\n\"metaboliteStyle\":"+JSON.stringify(metExploreD3.getMetaboliteStyle());
networkJSON+=",\n\"comparedPanels\":"+JSON.stringify(_metExploreViz.comparedPanels);
networkJSON+=",\n\"linkedByTypeOfMetabolite\":"+JSON.stringify(_metExploreViz.linkedByTypeOfMetabolite);
networkJSON+=",\n\"mappings\":"+JSON.stringify(_metExploreViz.mappings);
networkJSON+=",\n\"sessions\":{";
......
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