From 9a0200875867e9f63414a94f6f32c66d0d7085be Mon Sep 17 00:00:00 2001 From: Salih Altun Date: Thu, 8 Apr 2021 14:22:08 +0300 Subject: [PATCH] File conversion changes Take URL parameters into account from Newt. --- src/utilities/file-utilities-factory.js | 9 +++++---- src/utilities/main-utilities-factory.js | 4 ++-- src/utilities/nwt-to-json-converter-factory.js | 4 ++-- src/utilities/sbgnml-to-json-converter-factory.js | 10 +++++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/utilities/file-utilities-factory.js b/src/utilities/file-utilities-factory.js index 42e1d024..eeda7866 100644 --- a/src/utilities/file-utilities-factory.js +++ b/src/utilities/file-utilities-factory.js @@ -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 ); @@ -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); diff --git a/src/utilities/main-utilities-factory.js b/src/utilities/main-utilities-factory.js index a3c769c3..37b8f7f3 100644 --- a/src/utilities/main-utilities-factory.js +++ b/src/utilities/main-utilities-factory.js @@ -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) { diff --git a/src/utilities/nwt-to-json-converter-factory.js b/src/utilities/nwt-to-json-converter-factory.js index bc692bdb..b4d9f6aa 100644 --- a/src/utilities/nwt-to-json-converter-factory.js +++ b/src/utilities/nwt-to-json-converter-factory.js @@ -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') { diff --git a/src/utilities/sbgnml-to-json-converter-factory.js b/src/utilities/sbgnml-to-json-converter-factory.js index 22aba8da..27380848 100644 --- a/src/utilities/sbgnml-to-json-converter-factory.js +++ b/src/utilities/sbgnml-to-json-converter-factory.js @@ -1073,7 +1073,7 @@ module.exports = function () { }; - sbgnmlToJson.convert = function (xmlObject) { + sbgnmlToJson.convert = function (xmlObject, urlParams) { var self = this; var cytoscapeJsNodes = []; var cytoscapeJsEdges = []; @@ -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;