Skip to content

Commit

Permalink
File conversion changes
Browse files Browse the repository at this point in the history
  Take URL parameters into account from Newt.
  • Loading branch information
msalihaltun committed Apr 8, 2021
1 parent 0466793 commit 9a02008
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/utilities/file-utilities-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ module.exports = function () {
fileUtilities.loadFile( file, convert, callback1, callback2, fileUtilities.collapseMarkedNodes );
};

fileUtilities.loadNwtFile = function(file, callback1, callback2) {
fileUtilities.loadNwtFile = function(file, callback1, callback2, urlParams) {
var convert = function( text ) {
return nwtToJson.convert(textToXmlObject(text));
return nwtToJson.convert(textToXmlObject(text), urlParams);
};

fileUtilities.loadFile( file, convert, callback1, callback2, fileUtilities.collapseMarkedNodes );
Expand Down Expand Up @@ -314,9 +314,10 @@ module.exports = function () {
reader.readAsText(file);
};

fileUtilities.loadSBGNMLText = function(textData, tileInfoBoxes){
fileUtilities.loadSBGNMLText = function(textData, tileInfoBoxes, filename, cy, urlParams){
setTimeout(function () {
updateGraph(sbgnmlToJson.convert(textToXmlObject(textData)), undefined, undefined, tileInfoBoxes);
updateGraph(sbgnmlToJson.convert(textToXmlObject(textData), urlParams), undefined, undefined, tileInfoBoxes);
$(document).trigger("sbgnvizLoadFileEnd", [filename, cy]);
uiUtilities.endSpinner("load-file-spinner");
}, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/utilities/main-utilities-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ module.exports = function () {

// Converts given sbgnml data to a json object in a special format
// (http://js.cytoscape.org/#notation/elements-json) and returns it.
mainUtilities.convertSbgnmlToJson = function(data) {
return sbgnmlToJson.convert(data);
mainUtilities.convertSbgnmlToJson = function(data, urlParams) {
return sbgnmlToJson.convert(data, urlParams);
};

mainUtilities.convertNwtToJson = function(data) {
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/nwt-to-json-converter-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ module.exports = function() {
} );
}

nwtToJson.convert = function(xmlObject) {
var graphData = sbgnmlToJson.convert(xmlObject);
nwtToJson.convert = function(xmlObject, urlParams) {
var graphData = sbgnmlToJson.convert(xmlObject, urlParams);
var mapType = elementUtilities.mapType;

if (mapType !== 'PD' && mapType !== 'AF' && elementUtilities.mapType !== 'HybridSbgn') {
Expand Down
10 changes: 7 additions & 3 deletions src/utilities/sbgnml-to-json-converter-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ module.exports = function () {

};

sbgnmlToJson.convert = function (xmlObject) {
sbgnmlToJson.convert = function (xmlObject, urlParams) {
var self = this;
var cytoscapeJsNodes = [];
var cytoscapeJsEdges = [];
Expand Down Expand Up @@ -1129,8 +1129,12 @@ module.exports = function () {
}
}

var minDistanceToChildren = Number.MAX_SAFE_INTEGER ;
if (!map.extension) {
var minDistanceToChildren = Number.MAX_SAFE_INTEGER;

if(urlParams && urlParams.compoundPadding) {
mainUtilities.setCompoundPadding(Number(urlParams.compoundPadding));
}
else if (!map.extension) {
for (var i = 0; i < glyphs.length; i++) {
var glyph = glyphs[i];
// if(glyph.class_ == "complex")continue;
Expand Down

0 comments on commit 9a02008

Please sign in to comment.