From 770ad7ade6ec038d0fa6c8cdd760d67e106c67e8 Mon Sep 17 00:00:00 2001 From: "istemi.bahceci" Date: Wed, 14 Dec 2016 17:21:15 +0200 Subject: [PATCH] Handle color changed --- public/bin/base.min.js | 2 +- public/src/js/EdgeHandlesOptions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/bin/base.min.js b/public/bin/base.min.js index 7cd127ab..ba2d9204 100644 --- a/public/bin/base.min.js +++ b/public/bin/base.min.js @@ -41,7 +41,7 @@ if(this.child==null){return this.estimatedSize=Math.floor((this.rect.width+this. tempMemberGroups[p_id]=tempMemberGroups[p_id].concat(node)}for(var p_id in tempMemberGroups){if(tempMemberGroups[p_id].length>1){var dummyCompoundId="DummyCompound_"+p_id;memberGroups[dummyCompoundId]=tempMemberGroups[p_id];if(this.options.cy.getElementById(dummyCompoundId).empty()){this.options.cy.add({group:"nodes",data:{id:dummyCompoundId,parent:p_id}});var dummy=this.options.cy.nodes()[this.options.cy.nodes().length-1];this.options.eles=this.options.eles.union(dummy);dummy.hide();for(var i=0;i=0;i--){var id=_CoSELayout.compoundOrder[i].id();var lCompoundNode=_CoSELayout.idToLNode[id];var horizontalMargin=parseInt(_CoSELayout.compoundOrder[i].css("padding-left"));var verticalMargin=parseInt(_CoSELayout.compoundOrder[i].css("padding-top"));this.adjustLocations(tiledMemberPack[id],lCompoundNode.rect.x,lCompoundNode.rect.y,horizontalMargin,verticalMargin)}};_CoSELayout.prototype.repopulateZeroDegreeMembers=function(tiledPack){for(var i in tiledPack){var compound=this.cy.getElementById(i);var compoundNode=_CoSELayout.idToLNode[i];var horizontalMargin=parseInt(compound.css("padding-left"));var verticalMargin=parseInt(compound.css("padding-top"));this.adjustLocations(tiledPack[i],compoundNode.rect.x,compoundNode.rect.y,horizontalMargin,verticalMargin);var tempchildren=compound.scratch("coseBilkent").tempchildren;for(var i=0;imaxHeight)maxHeight=lnode.rect.height}y+=maxHeight+organization.verticalPadding}};_CoSELayout.prototype.tileCompoundMembers=function(childGraphMap){var tiledMemberPack=[];for(var id in childGraphMap){var compoundNode=_CoSELayout.idToLNode[id];tiledMemberPack[id]=this.tileNodes(childGraphMap[id]);compoundNode.rect.width=tiledMemberPack[id].width+20;compoundNode.rect.height=tiledMemberPack[id].height+20}return tiledMemberPack};_CoSELayout.prototype.tileNodes=function(nodes){var self=this;var verticalPadding=typeof self.options.tilingPaddingVertical==="function"?self.options.tilingPaddingVertical.call():self.options.tilingPaddingVertical;var horizontalPadding=typeof self.options.tilingPaddingHorizontal==="function"?self.options.tilingPaddingHorizontal.call():self.options.tilingPaddingHorizontal;var organization={rows:[],rowWidth:[],rowHeight:[],width:20,height:20,verticalPadding:verticalPadding,horizontalPadding:horizontalPadding};var layoutNodes=[];for(var i=0;in2.rect.width*n2.rect.height)return-1;if(n1.rect.width*n1.rect.height0){w+=organization.horizontalPadding}organization.rowWidth[rowIndex]=w;if(organization.width0)h+=organization.verticalPadding;var extraHeight=0;if(h>organization.rowHeight[rowIndex]){extraHeight=organization.rowHeight[rowIndex];organization.rowHeight[rowIndex]=h;extraHeight=organization.rowHeight[rowIndex]-extraHeight}organization.height+=extraHeight;organization.rows[rowIndex].push(node)};_CoSELayout.prototype.getShortestRowIndex=function(organization){var r=-1;var min=Number.MAX_VALUE;for(var i=0;imax){r=i;max=organization.rowWidth[i]}}return r};_CoSELayout.prototype.canAddHorizontal=function(organization,extraWidth,extraHeight){var sri=this.getShortestRowIndex(organization);if(sri<0){return true}var min=organization.rowWidth[sri];if(min+organization.horizontalPadding+extraWidth<=organization.width)return true;var hDiff=0;if(organization.rowHeight[sri]0)hDiff=extraHeight+organization.verticalPadding-organization.rowHeight[sri]}var add_to_row_ratio;if(organization.width-min>=extraWidth+organization.horizontalPadding){add_to_row_ratio=(organization.height+hDiff)/(min+extraWidth+organization.horizontalPadding)}else{add_to_row_ratio=(organization.height+hDiff)/organization.width}hDiff=extraHeight+organization.verticalPadding;var add_new_row_ratio;if(organization.widthdiff&&longest!=last){row.splice(-1,1);organization.rows[last].push(node);organization.rowWidth[longest]=organization.rowWidth[longest]-diff;organization.rowWidth[last]=organization.rowWidth[last]+diff;organization.width=organization.rowWidth[this.getLongestRowIndex(organization)];var maxHeight=Number.MIN_VALUE;for(var i=0;imaxHeight)maxHeight=row[i].height}if(longest>0)maxHeight+=organization.verticalPadding;var prevTotal=organization.rowHeight[longest]+organization.rowHeight[last];organization.rowHeight[longest]=maxHeight;if(organization.rowHeight[last]0){var theNewGraph;theNewGraph=_CoSELayout.layout.getGraphManager().add(_CoSELayout.layout.newGraph(),theNode);this.processChildrenList(theNewGraph,children_of_children)}}};module.exports=function get(cytoscape){Thread=cytoscape.Thread;return _CoSELayout}},{"./CoSEConstants":140,"./CoSEEdge":141,"./CoSEGraph":142,"./CoSEGraphManager":143,"./CoSELayout":144,"./CoSENode":145,"./DimensionD":146,"./FDLayout":147,"./FDLayoutConstants":148,"./FDLayoutEdge":149,"./FDLayoutNode":150,"./HashMap":151,"./HashSet":152,"./IGeometry":153,"./IMath":154,"./Integer":155,"./LEdge":156,"./LGraph":157,"./LGraphManager":158,"./LGraphObject":159,"./LNode":160,"./Layout":161,"./LayoutConstants":162,"./Point":163,"./PointD":164,"./RandomSeed":165,"./RectangleD":166,"./Transform":167,"./UniqueIDGeneretor":168}],170:[function(require,module,exports){"use strict";var getLayout=require("./Layout");var register=function(cytoscape){var Layout=getLayout(cytoscape);cytoscape("layout","cose-bilkent",Layout)};if(typeof cytoscape!=="undefined"){register(cytoscape)}module.exports=register},{"./Layout":169}],171:[function(require,module,exports){var cytoscape=window.cytoscape=require("cytoscape");var panzoom=require("cytoscape-panzoom");var navigator=require("cytoscape-navigator");var cyqtip=require("cytoscape-qtip");var regCose=require("../../lib/js/cose-bilkent/src/index.js");var grid_guide=require("cytoscape-grid-guide");var undoRedo=require("cytoscape-undo-redo");var contextMenus=require("cytoscape-context-menus");var panzoomOpts=require("./PanzoomOptions.js");var styleSheet=require("./GraphStyleSheet.js");var edgeHandleOpts=require("./EdgeHandlesOptions.js");var LayoutProperties=require("./BackboneViews/LayoutPropertiesView.js");var GenomicDataExplorerView=require("./BackboneViews/GenomicDataExplorerView.js");var PathwayDetailsView=require("./BackboneViews/PathwayDetailsView.js");var GridOptionsView=require("./BackboneViews/GridOptionsView.js");var CBioPortalAccessView=require("./BackboneViews/CbioPortalAccessView.js");require("./FileOperationsManager.js");require("./OtherMenuOperations.js");require("./GenomicMenuOperations.js");require("./ViewOperationsManager.js");require("./GraphUtilities.js");require("bootstrap-select");var QtipManager=require("./QtipManager.js");var ContextMenuManager=require("./ContextMenuManager.js");var DragDropNodeAddPlugin=require("./DragDropNodeAddPlugin.js");var EditorActionsManager=require("./EditorActionsManager.js");var SaveLoadUtilities=require("./SaveLoadUtility.js");var CBioPortalAccessor=require("./cBioPortalAccessor.js");module.exports=function(){function AppManager(isCollaborative,realTimeManager){this.isCollaborative=isCollaborative;this.realTimeManager=realTimeManager;this.init();this.createSampleMenu();this.createCBioPortalAccessModal()}AppManager.prototype.init=function(){this.initCyJS();this.initCyHandlers();var that=this;window.onresize=function(){that.placePanzoomAndOverlay()};if(!this.isCollaborative){$(document).keydown(function(e){if(e.which===89&&(e.ctrlKey||event.metaKey)){window.undoRedoManager.redo()}else if(e.which===90&&(e.ctrlKey||event.metaKey)){window.undoRedoManager.undo()}})}else{$('a[role="redo"]').hide();$('a[role="undo"]').hide()}window.appManager=this};AppManager.prototype.placePanzoomAndOverlay=function(){var offset=5;var topCy=$(".cyContainer").offset().top;var leftCy=$(".cyContainer").offset().left;var heightCy=$(".cyContainer").outerHeight();var widthCy=$(".cyContainer").outerWidth();var heightNavigator=$(".cytoscape-navigator-wrapper").outerHeight();var widthNavigator=$(".cytoscape-navigator-wrapper").outerWidth();var heightPanzoom=$(".cy-panzoom").outerHeight();var widthPanzoom=$(".cy-panzoom").outerWidth();$(".cytoscape-navigator-wrapper").css("top",heightCy+topCy-heightNavigator-offset);$(".cytoscape-navigator-wrapper").css("left",widthCy+leftCy-widthNavigator-offset);$(".cy-panzoom").css("top",topCy+5);$(".cy-panzoom").css("left",widthCy+leftCy-55)};AppManager.prototype.createSampleMenu=function(){var request=new XMLHttpRequest;request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE&&request.status===200){var templateData=JSON.parse(request.responseText);for(var key in templateData){if(templateData.hasOwnProperty(key)){var newTCGAMenu=$('");var newTCGAPathway=$('');for(var i in templateData[key]){var newPath=templateData[key][i];var pName=newPath.replace(/-/gi," ").substring(0,newPath.length-4);var sampleLink=$('
  • '+pName+"
  • ");sampleLink.on("click",sampleMenuClickHandler);if(key.includes("PanCancer")){$("#panCancerSubMenu").append(sampleLink)}else{newTCGAPathway.append(sampleLink);newTCGAMenu.append(newTCGAPathway)}}if(!key.includes("PanCancer")&&!key.includes("Creighton")){$("#sampleSubMenu").append(newTCGAMenu)}}}}};function sampleMenuClickHandler(event){var request=new XMLHttpRequest;request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE&&request.status===200){var allEles=SaveLoadUtilities.parseGraph(request.responseText);window.editorActionsManager.loadFile(allEles.nodes,allEles.edges);window.undoRedoManager.reset();window.appManager.pathwayDetailsView.updatePathwayProperties({fileName:allEles.title+".txt",pathwayTitle:allEles.title,pathwayDescription:allEles.description})}};var pathwayName=event.target.attributes[0].value;request.open("GET","/pathway?filename="+pathwayName);request.send()}request.open("GET","/getTemplateFileData");request.send()};AppManager.prototype.createCBioPortalAccessModal=function(){var portalAccessor=new CBioPortalAccessor;var self=this;this.portalAccessView=new CBioPortalAccessView({el:$("#cbioPortalAccessDiv")});portalAccessor.fetchCancerStudies(function(cancerStudies){self.portalAccessView.updateCancerStudies(cancerStudies)})};AppManager.prototype.initCyJS=function(){panzoom(cytoscape,$);cyqtip(cytoscape,$);regCose(cytoscape);navigator(cytoscape);grid_guide(cytoscape,$);undoRedo(cytoscape);contextMenus(cytoscape,$);window.edgeAddingMode=0;cy=window.cy=cytoscape({container:document.querySelector("#cy"),boxSelectionEnabled:true,autounselectify:false,wheelSensitivity:.1,style:styleSheet,ready:function(){},textureOnViewport:false,motionBlur:true,layout:{name:"preset"}});window.editorActionsManager=this.editorActionsManager=new EditorActionsManager(this.isCollaborative,this.realTimeManager,window.cy);this.qtipManager=new QtipManager(window.cy),this.editorActionsManager;this.cxtMenuManager=new ContextMenuManager(window.cy,this.editorActionsManager);this.dragDropNodeAddManager=new DragDropNodeAddPlugin(this.editorActionsManager);this.layoutPropertiesView=new LayoutProperties({el:$("#layoutPropertiesDiv"),editorActionsManager:this.editorActionsManager}).render();this.gridOptionsView=new GridOptionsView({el:$("#gridOptionsDiv")}).render();this.genomicDataExplorerView=new GenomicDataExplorerView({el:$("#genomicDataExplorerDiv"),editorActionsManager:this.editorActionsManager}).render();this.pathwayDetailsView=new PathwayDetailsView({el:$("#pathwayDetailsDiv")}).render();cy.panzoom(panzoomOpts);cy.nodeadd({components:[{container:$("#simpleNodeDiv"),nodeType:"Gene"},{container:$("#familyNodeDiv"),nodeType:"Family"},{container:$("#complexNodeDiv"),nodeType:"Complex",icon:"fa fa-square-o"},{container:$("#compartmentNodeDiv"),nodeType:"Compartment",icon:"fa fa-square-o"},{container:$("#processNodeDiv"),nodeType:"Process"}]});cy.edgehandles(edgeHandleOpts);var navDefaults={container:".cytoscape-navigator-wrapper",viewLiveFramerate:0,thumbnailEventFramerate:10,thumbnailLiveFramerate:false,dblClickDelay:200,removeCustomContainer:true,rerenderDelay:100};var nav=cy.navigator(navDefaults);this.placePanzoomAndOverlay()};AppManager.prototype.initCyHandlers=function(){var that=this;var tappedBefore;var tappedTimeout;cy.on("tap",function(event){var tappedNow=event.cyTarget;if(tappedTimeout&&tappedBefore){clearTimeout(tappedTimeout)}if(tappedBefore===tappedNow){tappedNow.trigger("doubleTap");tappedBefore=null}else{tappedTimeout=setTimeout(function(){tappedBefore=null},300);tappedBefore=tappedNow}});cy.on("doubleTap","node",function(e){var eventIsDirect=e.cyTarget===this;if(eventIsDirect){$(".qtip").remove();that.qtipManager.addQtipToElements(e.cyTarget);var api=this.qtip("api");if(api){api.show()}}});cy.on("select","node",function(e){window.editorActionsManager.pushSelectedNodeStack(e.cyTarget)});cy.on("unselect","node",function(e){window.editorActionsManager.removeElementFromSelectedNodeStack(e.cyTarget)});cy.on("free","node",function(e){var selectedNodes=cy.nodes(":selected");var nodes=e.cyTarget;nodes=nodes.union(nodes.descendants());nodes=nodes.union(selectedNodes);that.editorActionsManager.moveElements(nodes)});cy.on("layoutstop",function(event){that.editorActionsManager.postLayout()});cy.on("add","node",function(event){cy.style().update();cy.forceRender()})};return AppManager}()},{"../../lib/js/cose-bilkent/src/index.js":170,"./BackboneViews/CbioPortalAccessView.js":173,"./BackboneViews/GenomicDataExplorerView.js":174,"./BackboneViews/GridOptionsView.js":175,"./BackboneViews/LayoutPropertiesView.js":176,"./BackboneViews/PathwayDetailsView.js":177,"./ContextMenuManager.js":179,"./DragDropNodeAddPlugin.js":180,"./EdgeHandlesOptions.js":181,"./EditorActionsManager.js":182,"./FileOperationsManager.js":183,"./GenomicMenuOperations.js":185,"./GraphStyleSheet.js":186,"./GraphUtilities.js":187,"./OtherMenuOperations.js":188,"./PanzoomOptions.js":189,"./QtipManager.js":190,"./SaveLoadUtility.js":194,"./ViewOperationsManager.js":195,"./cBioPortalAccessor.js":196,"bootstrap-select":2,cytoscape:112,"cytoscape-context-menus":16,"cytoscape-grid-guide":23,"cytoscape-navigator":27,"cytoscape-panzoom":28,"cytoscape-qtip":29,"cytoscape-undo-redo":30}],172:[function(require,module,exports){var BioGeneView=Backbone.View.extend({render:function(){var variables={geneDescription:this.model.geneDescription,geneAliases:this.parseDelimitedInfo(this.model.geneAliases,":",",",null),geneDesignations:this.parseDelimitedInfo(this.model.geneDesignations,":",",",null),geneLocation:this.model.geneLocation,geneMim:this.model.geneMim,geneId:this.model.geneId,geneUniprotId:this.extractFirstUniprotId(this.model.geneUniprotMapping),geneUniprotLinks:this.generateUniprotLinks(this.model.geneUniprotMapping),geneSummary:this.model.geneSummary};var template=_.template($("#biogene-template").html());template=template(variables);this.$el.html(template);this.format(this.model);return this.$el},format:function(){if(this.model.geneDescription==undefined)this.$el.find(".biogene-description").hide();if(this.model.geneAliases==undefined)this.$el.find(".biogene-aliases").hide();if(this.model.geneDesignations==undefined)this.$el.find(".biogene-designations").hide();if(this.model.geneChromosome==undefined)this.$el.find(".biogene-chromosome").hide();if(this.model.geneLocation==undefined)this.$el.find(".biogene-location").hide();if(this.model.geneMim==undefined)this.$el.find(".biogene-mim").hide();if(this.model.geneId==undefined)this.$el.find(".biogene-id").hide();if(this.model.geneUniprotMapping==undefined)this.$el.find(".biogene-uniprot-links").hide();if(this.model.geneSummary==undefined)this.$el.find(".node-details-summary").hide();var expanderOpts={slicePoint:100,expandPrefix:" ",expandText:" (...)",userCollapseText:" (show less)",moreClass:"expander-read-more",lessClass:"expander-read-less",detailClass:"expander-details",expandEffect:"fadeIn",collapseEffect:"fadeOut"};expanderOpts.slicePoint=2;expanderOpts.widow=0},generateUniprotLinks:function(mapping){var formatter=function(id){var tpl=_.template($("#uniprot-link-template").html());tpl=tpl({id:id});return tpl};if(mapping==undefined||mapping==null){return""}if(mapping.indexOf(":")<0){return""}else{mapping=mapping.substring(mapping.indexOf(":")+1);return", "+this.parseDelimitedInfo(mapping,":",",",formatter)}},extractFirstUniprotId:function(mapping){if(mapping==undefined||mapping==null){return""}var parts=mapping.split(":");if(parts.length>0){return parts[0]}return""},parseDelimitedInfo:function(info,delimiter,separator,formatter){if(info==undefined||info==null){return info}var text="";var parts=info.split(delimiter);if(parts.length>0){if(formatter){text=formatter(parts[0])}else{text=parts[0]}}for(var i=1;iPlease Wait Loading Cancer Studies");this.$el.find("#cancerDropDown").append(this.cachedLoadingTemplate)},updateCancerStudies:function(cancerStudies){this.cancerStudies=cancerStudies;this.updateView()},updateView:function(){var self=this;this.$el.find("#cancerDropDown").empty();this.$el.find("#dataTypeSelection").empty();this.$el.find("#cancerDropDown").append("

    Select Cancer Study

    ");var cancerStudiesDropDown=$('');for(var cancerName in this.cancerStudies){cancerStudiesDropDown.append("")}$("#cancerDropDown").append(cancerStudiesDropDown);cancerStudiesDropDown.selectpicker({liveSearch:true,container:"body",liveSearchPlaceholder:"Search Cancer Study"});$("#cancerSelectBox").change(function(){self.$el.find("#dataTypeSelection").empty();self.$el.find("#dataTypeSelection").append(self.cachedLoadingTemplate);var key=$(this).find("option:selected").attr("key");self.currenCancerStudy=self.cancerStudies[key];var createDataTypeSelectionCallback=function(cancerData){self.$el.find("#dataTypeSelection").empty();var dataTypes={};for(var obj in cancerData){var dataType=self.portalAccessor.getDataType(obj);dataTypes[dataType]=cancerData[obj]}self.$el.find("#dataTypeSelection").append("

    Data Types

    ");for(var obj in dataTypes){var newCheckbox=$('
    '+""+"
    ");newCheckbox.find('input[type="checkbox"]').on("click",function(evt){var checkedNum=self.$el.find('input[type="checkbox"]:checked').length;if(checkedNum>=1)self.showSubmitButton();else if(checkedNum==0)self.hideSubmitButton()});self.$el.find("#dataTypeSelection").append(newCheckbox)}};self.portalAccessor.getSupportedGeneticProfiles(key,createDataTypeSelectionCallback)})},render:function(){this.hideSubmitButton();if(!this.cancerStudies){this.$el.modal("show");return}this.updateView();this.$el.modal("show")},hideSubmitButton:function(){$("#getProfileData").hide()},showSubmitButton:function(){$("#getProfileData").show()},fetchProfileData:function(){var checkedDataTypes=this.$el.find('input[type="checkbox"]:checked');var geneSymbols=window.editorActionsManager.getGeneSymbols();var self=this;for(var i=0;iThere is currently no data to show');this.$el.find("#save-genomic").hide()},saveHandler:function(event){var dataMap={};this.$el.find(".genomicDataContentDiv label").each(function(){var jqEl=$(this);var cancerType=jqEl.text();var isChecked=jqEl.find("input").is(":checked");dataMap[cancerType]=isChecked});this.editorActionsManagerRef.updateGenomicDataVisibility(dataMap);this.$el.modal("toggle")},notify:function(data){this.$el.find(".genomicDataContentDiv").empty();var cancerTypes=this.editorActionsManagerRef.genomicDataOverlayManager.visibleGenomicDataMapByType;if(cancerTypes&&Object.keys(cancerTypes).length===0){this.renderEmptyView()}else{this.$el.find(".genomicDataContentDiv").append('');var checkboxDiv=$('
    ');for(var cancerType in cancerTypes){var checkboxContent=$('");checkboxContent.find("input").attr("checked",cancerTypes[cancerType]);checkboxDiv.append(checkboxContent)}this.$el.find(".genomicDataContentDiv").append(checkboxDiv);this.$el.find("#save-genomic").show()}}});module.exports=genomicDataExplorer},{}],175:[function(require,module,exports){var gridOptionsView=Backbone.View.extend({currentProperties:null,events:{"click #applyGridOptions":"saveProperties"},initialize:function(options){this.defaultGridGuideOptions={snapToGrid:false,discreteDrag:false,guidelines:true,resize:false,gridSpacing:20,parentPadding:false,drawGrid:false,guidelinesStackOrder:4,guidelinesTolerance:2,guidelinesStyle:{lineWidth:2,strokeStyle:"#000000",lineDash:[7,15]}};this.copyProperties(this.defaultGridGuideOptions);cy.gridGuide(this.currentProperties)},copyProperties:function(params){this.currentProperties=_.clone(params)},render:function(){var templateProperties=_.clone(this.currentProperties);this.template=_.template($("#gridOptionsTemplate").html());var tplContent=this.template(templateProperties);this.$el.empty();this.$el.append(tplContent);this.$el.find("#colorPickerDiv").colorpicker();this.delegateEvents()},saveProperties:function(event){this.currentProperties.gridSpacing=Number(this.$el.find("#gridSize").val());this.currentProperties.drawGrid=this.$el.find("#showGrid").is(":checked");this.currentProperties.guidelines=this.$el.find("#showGuides").is(":checked");this.currentProperties.snapToGrid=this.$el.find("#snapToGrid").is(":checked");this.currentProperties.guidelinesStyle.strokeStyle=this.$el.find("#colorPickerInput").val();cy.gridGuide(this.currentProperties);this.$el.modal("toggle")},changeParameters:function(){this.$el.find("#gridSize").val(this.currentProperties.gridSize);this.$el.find("#showGrid")[0].checked=this.currentProperties.showGrid;this.$el.find("#showGuides")[0].checked=this.currentProperties.showGuides;this.$el.find("#colorPickerInput").val(this.currentProperties.guidelinesStyle.strokeStyle)},defaultLayoutHandler:function(event){},notify:function(){}});module.exports=gridOptionsView},{}],176:[function(require,module,exports){var layoutProps=Backbone.View.extend({currentLayoutProperties:null,events:{"click #save-layout":"saveLayoutHandler","click #default-layout":"defaultLayoutHandler"},initialize:function(options){this.editorActionsManagerRef=options.editorActionsManager;this.copyProperties(this.editorActionsManagerRef.layoutProperties);this.editorActionsManagerRef.registerObserver(this)},copyProperties:function(params){this.currentLayoutProperties=_.clone(params)},render:function(){var templateProperties=_.clone(this.currentLayoutProperties);this.template=_.template($("#layoutPropertiesTemplate").html());var tplContent=this.template(templateProperties);this.$el.empty();this.$el.append(tplContent);this.delegateEvents()},saveLayoutHandler:function(event){this.currentLayoutProperties.nodeRepulsion=Number(this.$el.find("#node-repulsion").val());this.currentLayoutProperties.nodeOverlap=Number(this.$el.find("#node-overlap").val());this.currentLayoutProperties.idealEdgeLength=Number(this.$el.find("#ideal-edge-length").val());this.currentLayoutProperties.edgeElasticity=Number(this.$el.find("#edge-elasticity").val());this.currentLayoutProperties.nestingFactor=Number(this.$el.find("#nesting-factor").val());this.currentLayoutProperties.gravity=Number(this.$el.find("#gravity").val());this.currentLayoutProperties.numIter=Number(this.$el.find("#num-iter").val());this.currentLayoutProperties.gravityRangeCompound=Number(this.$el.find("#comp-gravRange").val());this.currentLayoutProperties.gravityCompound=Number(this.$el.find("#comp-grav").val());this.currentLayoutProperties.gravityRange=Number(this.$el.find("#grav-range").val());this.currentLayoutProperties.tile=this.$el.find("#tile").is(":checked");this.currentLayoutProperties.animate=this.$el.find("#animate").is(":checked");this.currentLayoutProperties.randomize=!this.$el.find("#randomize").is(":checked");this.editorActionsManagerRef.saveLayoutProperties(this.currentLayoutProperties);this.$el.modal("toggle")},changeParameters:function(){this.$el.find("#node-repulsion").val(this.currentLayoutProperties.nodeRepulsion);this.$el.find("#node-overlap").val(this.currentLayoutProperties.nodeOverlap);this.$el.find("#ideal-edge-length").val(this.currentLayoutProperties.idealEdgeLength);this.$el.find("#edge-elasticity").val(this.currentLayoutProperties.edgeElasticity); -this.$el.find("#nesting-factor").val(this.currentLayoutProperties.nestingFactor);this.$el.find("#gravity").val(this.currentLayoutProperties.gravity);this.$el.find("#comp-gravRange").val(this.currentLayoutProperties.gravityRangeCompound);this.$el.find("#comp-grav").val(this.currentLayoutProperties.gravityCompound);this.$el.find("#grav-range").val(this.currentLayoutProperties.gravityRange);this.$el.find("#num-iter").val(this.currentLayoutProperties.numIter);this.$el.find("#tile")[0].checked=this.currentLayoutProperties.tile;this.$el.find("#animate")[0].checked=this.currentLayoutProperties.animate;this.$el.find("#randomize")[0].checked=!this.currentLayoutProperties.randomize},defaultLayoutHandler:function(event){this.copyProperties(this.editorActionsManagerRef.defaultLayoutProperties);this.changeParameters()},notify:function(){this.copyProperties(this.editorActionsManagerRef.layoutProperties);this.changeParameters()}});module.exports=layoutProps},{}],177:[function(require,module,exports){var pathwayDetails=Backbone.View.extend({currentLayoutProperties:null,events:{"click #savePathwayDetails":"saveHandler"},initialize:function(options){this.properties={pathwayName:"pathway.txt",pathwayTitle:"New Pathway",pathwayDescription:""}},saveHandler:function(event){this.properties.pathwayName=this.$el.find("#pName").val();this.properties.pathwayTitle=this.$el.find("#pTitle").val();this.properties.pathwayDescription=this.$el.find("#pDesc").val();this.$el.modal("toggle")},updatePathwayProperties:function(data){this.properties.pathwayName=data.fileName;this.properties.pathwayTitle=data.pathwayTitle;this.properties.pathwayDescription=data.pathwayDescription},copyProperties:function(params){this.currentLayoutProperties=_.clone(params)},render:function(){this.template=_.template($("#pathwayDetailsTemplate").html());var tplContent=this.template(this.properties);this.$el.empty();this.$el.append(tplContent);this.delegateEvents();this.$el.find("input").on("keypress",function(e){if(e.keyCode==13){e.preventDefault()}});return this}});module.exports=pathwayDetails},{}],178:[function(require,module,exports){var WelcomePageView=Backbone.View.extend({cachedTpl:_.template($("#welcomePageTemplate").html()),events:{"click #localUsage":"localUsageHandler","click #collaborativeUsage":"collaborativeUsageHandler","click .continueButton":"continueButtonHandler"},initialize:function(options){this.localUsageCallback=options.localUsageCallback;this.collaborativeUsageCallback=options.collaborativeUsageCallback;this.modelSelectionMap={NONE:-1,LOCAL:0,COLLAB:1};this.modelSelection=this.modelSelectionMap.NONE},render:function(){this.$el.empty();this.$el.append(this.cachedTpl());this.$el.find("#localUsage").popover({container:"body",content:"Create a pathway individually",placement:"left",delay:100,trigger:"manual"});this.$el.find("#collaborativeUsage").popover({container:"body",html:true,content:function(){return $("#collaborativePopoverContent").html()},placement:"right",delay:200,trigger:"manual"})},localUsageHandler:function(event){if(this.modelSelection==this.modelSelectionMap.LOCAL)return;$(".popover").popover("hide");this.$el.find(".welcomePageCheckable").removeClass("active");$(event.currentTarget).addClass("active");this.$el.find("#localUsage").popover("show");this.$el.find(".continueRow").css("visibility","visible");this.modelSelection=this.modelSelectionMap.LOCAL},collaborativeUsageHandler:function(event){if(this.modelSelection==this.modelSelectionMap.COLLAB)return;$(".popover").popover("hide");this.$el.find(".welcomePageCheckable").removeClass("active");$(event.currentTarget).addClass("active");this.$el.find("#collaborativeUsage").popover("show");this.$el.find(".continueRow").css("visibility","visible");this.modelSelection=this.modelSelectionMap.COLLAB},continueButtonHandler:function(event){$(".popover").hide();var self=this;this.$el.find(".welcomePageLoading").show();function postHandler(){self.postSuccess()}if(this.modelSelection!=this.modelSelectionMap.NONE){if(this.modelSelection==this.modelSelectionMap.LOCAL){this.localUsageCallback(postHandler)}else if(this.modelSelection==this.modelSelectionMap.COLLAB){this.collaborativeUsageCallback(postHandler)}}},postSuccess:function(){this.$el.empty();this.$el.fadeOut(800)}});module.exports=WelcomePageView},{}],179:[function(require,module,exports){module.exports=function(){"use strict";var CxtMenu=function(cy,editorActionsManager){this.cy=cy;this.editorActionsManager=editorActionsManager;this.init()};CxtMenu.prototype.init=function(){var classRef=this;var options={menuItems:[{id:"remove",title:"Delete",selector:"node, edge",onClickFunction:function(event){var ele=event.cyTarget;var selectedElements=cy.nodes(":selected").union(ele);classRef.editorActionsManager.removeElement(selectedElements)},disabled:false,hasTrailingDivider:true,coreAsWell:false},{id:"addSelected",title:"Add selected into this",selector:"node",onClickFunction:function(event){var ele=event.cyTarget;var selectedNodes=cy.nodes(":selected");var containerType=ele.data("type");var validNodes=cy.collection();if(ele._private.data["type"]==="GENE"||selectedNodes.size()<1){return}else{var notValid=false;selectedNodes.forEach(function(tmpNode,i){if(ele.id()==tmpNode.id()){notValid=true;return false}if(tmpNode.isParent()){notValid=isChildren(tmpNode,ele);if(notValid){return false}}});if(notValid){return}}selectedNodes.forEach(function(tmpNode,i){if(containerType=="FAMILY"||containerType=="COMPLEX"){if(tmpNode.data("type")!="COMPARTMENT"&&tmpNode.data("type")!="PROCESS"){validNodes=validNodes.add(tmpNode)}}else{validNodes=validNodes.add(tmpNode)}});var compId=ele.id();classRef.editorActionsManager.changeParents(validNodes,compId)},disabled:false,hasTrailingDivider:true,coreAsWell:false},{id:"removeSelected",title:"Remove selected from parent",selector:"node",onClickFunction:function(event){var ele=event.cyTarget;var selectedNodes=cy.nodes(":selected").union(ele);var notValid=false;selectedNodes.forEach(function(tmpNode,i){if(tmpNode.isParent()){notValid=isChildren(tmpNode,ele);if(notValid){return false}}});if(notValid){return}classRef.editorActionsManager.changeParents(selectedNodes,null)},disabled:false,hasTrailingDivider:true,coreAsWell:false},{id:"performLayout",title:"Perform Layout",coreAsWell:true,onClickFunction:function(event){classRef.editorActionsManager.performLayout()},disabled:false,hasTrailingDivider:true}],menuItemClasses:[],contextMenuClasses:[]};this.cy.contextMenus(options)};window.edgeAddingMode=false;function isChildren(node,queryNode){var parent=queryNode.parent()[0];while(parent){if(parent.id()==node.id()){return true}parent=parent.parent()[0]}return false}return CxtMenu}()},{}],180:[function(require,module,exports){module.exports=function($,$$){"use strict";var NodeAdd=function(editorActionsManager){this.editorActionsManager=editorActionsManager;this.initNodeAdd()};NodeAdd.prototype.initNodeAdd=function(){var nodeAddClass=this;var defaults={height:30,width:30,padding:5,backgroundColorDiv:"#fbfbfb",borderColorDiv:"#fff",borderWidthDiv:"0px",borderRadiusDiv:"5px",icon:"",nodeParams:function(){return{}}};$.fn.cytoscapeNodeadd=function(params){var options=$.extend(true,{},defaults,params);var fn=params;var functions={destroy:function(){var $this=$(this);$this.find(".ui-cytoscape-nodeadd").remove()},init:function(){return $(this).each(function(){var components=options.components;for(var index in components){var component=components[index];var dragContainer=component.container;var explanationText=component.explanationText;var $nodeadd=$('
    ');dragContainer.append($nodeadd);var $nodeDragHandle=$('
    ');$nodeadd.append($nodeDragHandle);$nodeDragHandle.bind("mousedown",function(e){e.stopPropagation();e.preventDefault()});dragContainer.find(".ui-cytoscape-nodeadd-nodediv").css({background:options.backgroundColorDiv,border:options.borderWidthDiv+" solid "+options.borderColorDiv,"border-radius":options.borderRadiusDiv});dragContainer.find("#ui-cytoscape-nodeadd-icon").draggable({helper:"clone",cursor:"pointer"})}var $container=$(this);$container.droppable({activeClass:"ui-state-highlight",drop:function(event,ui){$container.removeClass("ui-state-highlight");var currentOffset=$container.offset();var relX=event.pageX-currentOffset.left;var relY=event.pageY-currentOffset.top;var nodeType=$(ui.helper).attr("nodeType").toUpperCase();var cy=$container.cytoscape("get");var nodeMap={};var parentMap={};cy.nodes().forEach(function(node,i){var nodeBbox=node.renderedBoundingBox();if(relX<=nodeBbox.x2&&relX>=nodeBbox.x1&&(relY<=nodeBbox.y2&&relY>=nodeBbox.y1)&&node.data().type!="GENE"){if(node.children().length>0){parentMap[node.id()]=true}if(parentMap[node._private.data.parent]){delete nodeMap[node._private.data.parent]}nodeMap[node.id()]=node}});var parent=nodeMap[Object.keys(nodeMap)[0]];var nodeData={type:nodeType,name:"New "+$(ui.helper).attr("nodeType")};if(parent){if(parent.data().type=="FAMILY"||parent.data().type=="COMPLEX"){if(nodeType!="COMPARTMENT"&&nodeType!="PROCESS"){nodeData.parent=parent.id()}}else{nodeData.parent=parent.id()}}relX=relX/cy.zoom()+cy.extent().x1;relY=relY/cy.zoom()+cy.extent().y1;nodeAddClass.editorActionsManager.addNode(nodeData,{x:relX,y:relY})}})})}};if(functions[fn]){return functions[fn].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof fn=="object"||!fn){return functions.init.apply(this,arguments)}else{$.error("No such function `"+fn+"` for jquery.cytoscapenodeadd")}return $(this)};$.fn.cynodeadd=$.fn.cytoscapeNodeadd;$$("core","nodeadd",function(options){var cy=this;$(cy.container()).cytoscapeNodeadd(options)})};return NodeAdd}(window.$,window.cytoscape)},{}],181:[function(require,module,exports){var edgeHandleDefaults={preview:true,stackOrder:4,handleSize:10,handleColor:"#ed3a3a",handleLineType:"ghost",handleLineWidth:1,handleNodes:"node",hoverDelay:1,cxt:false,enabled:false,toggleOffOnLeave:true,edgeType:function(sourceNode,targetNode){return"flat"},loopAllowed:function(node){return false},nodeLoopOffset:-50,nodeParams:function(sourceNode,targetNode){return{}},edgeParams:function(sourceNode,targetNode,i){return{}},start:function(sourceNode){var type=this.getGlobalEdgeType();cy.edgehandles("option","ghostEdgeType",type)},complete:function(sourceNode,targetNodes,addedEntities){cy.remove(addedEntities);window.editorActionsManager.addEdge({source:sourceNode.id(),target:targetNodes[0].id(),type:this.getGlobalEdgeType()})},stop:function(sourceNode){$(".edge-palette a").blur().removeClass("active");window.edgeAddingMode==-1;cy.edgehandles("disable")},getGlobalEdgeType:function(){var type="NONE";if(window.edgeAddingMode==1){type="ACTIVATES"}else if(window.edgeAddingMode==2){type="INHIBITS"}else if(window.edgeAddingMode==3){type="INDUCES"}else if(window.edgeAddingMode==4){type="REPRESSES"}else if(window.edgeAddingMode==5){type="BINDS"}return type}};module.exports=edgeHandleDefaults},{}],182:[function(require,module,exports){var GenomicDataOverlayManager=require("./GenomicDataOverlayManager.js");var SVGExporter=require("./SVGExporter.js");module.exports=function(){"use strict";var EditorActionsManager=function(isCollaborative,realtimeManager,cyInst){this.cy=cyInst;this.isCollaborative=isCollaborative;if(this.isCollaborative&&realtimeManager)this.realTimeManager=realtimeManager;this.defaultLayoutProperties={name:"cose-bilkent",nodeRepulsion:4500,nodeOverlap:10,idealEdgeLength:50,edgeElasticity:.45,nestingFactor:.1,gravity:.15,numIter:2500,tile:true,animate:"end",randomize:false,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:1.5};this.FIT_CONSTANT=50;this.layoutProperties=_.clone(this.defaultLayoutProperties);this.observers=[];this.genomicDataOverlayManager=new GenomicDataOverlayManager;this.svgExporter=new SVGExporter;this.selecteNodeStack={};window.undoRedoManager=cy.undoRedo();window.undoRedoManager.action("changePositions",this.doChangePosition,this.undoChangePosition);window.undoRedoManager.action("changeName",this.doChangename,this.undoChangeName)};EditorActionsManager.prototype.doChangename=function(args){var currentName=args.node.data("name");var newArgs={node:args.node,newName:args.newName,oldName:currentName};args.node.data("name",args.newName);args.node.css("content",args.newName);return newArgs};EditorActionsManager.prototype.undoChangeName=function(args){var currentName=args.node.data("name");var newArgs={node:args.node,newName:args.oldName,oldName:currentName};args.node.data("name",args.oldName);args.node.css("content",args.oldName);return newArgs};EditorActionsManager.prototype.doChangePosition=function(movedNodes){var newMovedNodes=[];for(var i=0;i0){children.forEach(function(childNode,i){lockedNodes[childNode.id()]=true});removedEles=removedEles.union(removeNodes(children))}removedEles=removedEles.union(nodes.remove());self.cy.nodes().updateCompoundBounds();return removedEles}var removedEles=removeNodes(eles);window.undoRedoManager.do("remove",removedEles);for(var i=0;i0){ele.data.source=cySourceNode.id()}if(cyTargetNode.length>0){ele.data.target=cyTargetNode.id()}if(cyTargetNode.length<0&&cySourceNode.length<0){continue}var edgesBtw=cy.filter('edge[source = "'+cySourceNode.id()+'"][target = "'+cyTargetNode.id()+'"]');var isFound=false;edgesBtw.forEach(function(edge,i){if(edge.data().type==ele.data.type){isFound=true;return false}});if(!isFound){delete ele.data.id;edgesToBeAdded.push(ele)}}cy.add(edgesToBeAdded)};EditorActionsManager.prototype.fitGraph=function(){if(this.isCollaborative){cy.fit(this.FIT_CONSTANT);var newState={zoomLevel:cy.zoom(),panLevel:cy.pan()};this.updateGlobalOptions(newState)}else{cy.fit(this.FIT_CONSTANT)}};EditorActionsManager.prototype.loadFile=function(nodes,edges){if(this.isCollaborative){this.loadfileRealTime(nodes,edges)}else{this.loadFileCy(nodes,edges)}this.fitGraph()};EditorActionsManager.prototype.loadFileCy=function(nodes,edges){this.removeElementCy(cy.elements());this.addNodesCy(nodes);this.addEdgesCy(edges)};EditorActionsManager.prototype.loadfileRealTime=function(nodes,edges){this.realTimeManager.loadGraph(nodes,edges)};EditorActionsManager.prototype.removeAllElements=function(){if(this.isCollaborative){this.realTimeManager.removeAllElements()}else{cy.remove(cy.elements())}};EditorActionsManager.prototype.changeName=function(ele,newName){if(this.isCollaborative){this.realTimeManager.changeName(ele,newName)}else{this.changeNameCy(ele,newName)}};EditorActionsManager.prototype.changeNameCy=function(ele,newName){var currentName=ele.data("name");var args={node:ele,oldName:currentName,newName:newName};window.undoRedoManager.do("changeName",args)};EditorActionsManager.prototype.updateElementCallback=function(ele,id){var nodeID=id;var cyEle=this.cy.$("#"+nodeID);cyEle.position({x:ele.x,y:ele.y});this.changeNameCy(cyEle,ele.name)};EditorActionsManager.prototype.getGenomicDataSVG=function(node){return this.genomicDataOverlayManager.generateSVGForNode(node)};EditorActionsManager.prototype.removeGenomicData=function(){if(this.isCollaborative){this.realTimeManager.clearGenomicData();this.realTimeManager.clearGenomicVisData()}else{this.genomicDataOverlayManager.removeGenomicData();this.genomicDataOverlayManager.removeGenomicVisData();this.genomicDataOverlayManager.hideGenomicData();this.genomicDataOverlayManager.notifyObservers()}};EditorActionsManager.prototype.addGenomicData=function(genomicData){if(this.isCollaborative){this.removeGenomicData();var parsedGenomicData=this.genomicDataOverlayManager.prepareGenomicDataRealTime(genomicData);var genomicDataMap=parsedGenomicData.genomicDataMap;var visibilityMap=parsedGenomicData.visibilityMap;this.realTimeManager.addGenomicData("genomicData",genomicDataMap);this.realTimeManager.addGenomicVisibilityData("visMap",visibilityMap)}else{this.genomicDataOverlayManager.addGenomicDataLocally(genomicData)}};EditorActionsManager.prototype.addPortalGenomicData=function(genomicData){if(this.isCollaborative){this.genomicDataOverlayManager.addPortalGenomicData(genomicData);this.realTimeManager.addGenomicData("genomicData",this.genomicDataOverlayManager.genomicDataMap);this.realTimeManager.addGenomicVisibilityData("visMap",this.genomicDataOverlayManager.visibleGenomicDataMapByType)}else{this.genomicDataOverlayManager.addPortalGenomicData(genomicData)}};EditorActionsManager.prototype.realTimeGenomicDataHandler=function(event){var newData=event.newValue;var geneSymbol=event.property;if(newData){this.genomicDataOverlayManager.addGenomicData(newData)}else{this.genomicDataOverlayManager.removeGenomicData(geneSymbol)}};EditorActionsManager.prototype.realTimeGenomicDataVsibilityHandler=function(event){var data=event.newValue;if(data){this.genomicDataOverlayManager.addGenomicVisData(data)}else{this.genomicDataOverlayManager.removeGenomicVisData(data)}this.genomicDataOverlayManager.showGenomicData();this.genomicDataOverlayManager.notifyObservers()};return EditorActionsManager}()},{"./GenomicDataOverlayManager.js":184,"./SVGExporter.js":193}],183:[function(require,module,exports){var SaveLoadUtilities=require("./SaveLoadUtility.js");module.exports=function($){"use strict";function b64toBlob(b64Data,contentType,sliceSize){contentType=contentType||"";sliceSize=sliceSize||512;var byteCharacters=atob(b64Data);var byteArrays=[];for(var offset=0;offset');dragContainer.append($nodeadd);var $nodeDragHandle=$('
    ');$nodeadd.append($nodeDragHandle);$nodeDragHandle.bind("mousedown",function(e){e.stopPropagation();e.preventDefault()});dragContainer.find(".ui-cytoscape-nodeadd-nodediv").css({background:options.backgroundColorDiv,border:options.borderWidthDiv+" solid "+options.borderColorDiv,"border-radius":options.borderRadiusDiv});dragContainer.find("#ui-cytoscape-nodeadd-icon").draggable({helper:"clone",cursor:"pointer"})}var $container=$(this);$container.droppable({activeClass:"ui-state-highlight",drop:function(event,ui){$container.removeClass("ui-state-highlight");var currentOffset=$container.offset();var relX=event.pageX-currentOffset.left;var relY=event.pageY-currentOffset.top;var nodeType=$(ui.helper).attr("nodeType").toUpperCase();var cy=$container.cytoscape("get");var nodeMap={};var parentMap={};cy.nodes().forEach(function(node,i){var nodeBbox=node.renderedBoundingBox();if(relX<=nodeBbox.x2&&relX>=nodeBbox.x1&&(relY<=nodeBbox.y2&&relY>=nodeBbox.y1)&&node.data().type!="GENE"){if(node.children().length>0){parentMap[node.id()]=true}if(parentMap[node._private.data.parent]){delete nodeMap[node._private.data.parent]}nodeMap[node.id()]=node}});var parent=nodeMap[Object.keys(nodeMap)[0]];var nodeData={type:nodeType,name:"New "+$(ui.helper).attr("nodeType")};if(parent){if(parent.data().type=="FAMILY"||parent.data().type=="COMPLEX"){if(nodeType!="COMPARTMENT"&&nodeType!="PROCESS"){nodeData.parent=parent.id()}}else{nodeData.parent=parent.id()}}relX=relX/cy.zoom()+cy.extent().x1;relY=relY/cy.zoom()+cy.extent().y1;nodeAddClass.editorActionsManager.addNode(nodeData,{x:relX,y:relY})}})})}};if(functions[fn]){return functions[fn].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof fn=="object"||!fn){return functions.init.apply(this,arguments)}else{$.error("No such function `"+fn+"` for jquery.cytoscapenodeadd")}return $(this)};$.fn.cynodeadd=$.fn.cytoscapeNodeadd;$$("core","nodeadd",function(options){var cy=this;$(cy.container()).cytoscapeNodeadd(options)})};return NodeAdd}(window.$,window.cytoscape)},{}],181:[function(require,module,exports){var edgeHandleDefaults={preview:true,stackOrder:4,handleSize:10,handleColor:"#1abc9c",handleLineType:"ghost",handleLineWidth:1,handleNodes:"node",hoverDelay:1,cxt:false,enabled:false,toggleOffOnLeave:true,edgeType:function(sourceNode,targetNode){return"flat"},loopAllowed:function(node){return false},nodeLoopOffset:-50,nodeParams:function(sourceNode,targetNode){return{}},edgeParams:function(sourceNode,targetNode,i){return{}},start:function(sourceNode){var type=this.getGlobalEdgeType();cy.edgehandles("option","ghostEdgeType",type)},complete:function(sourceNode,targetNodes,addedEntities){cy.remove(addedEntities);window.editorActionsManager.addEdge({source:sourceNode.id(),target:targetNodes[0].id(),type:this.getGlobalEdgeType()})},stop:function(sourceNode){$(".edge-palette a").blur().removeClass("active");window.edgeAddingMode==-1;cy.edgehandles("disable")},getGlobalEdgeType:function(){var type="NONE";if(window.edgeAddingMode==1){type="ACTIVATES"}else if(window.edgeAddingMode==2){type="INHIBITS"}else if(window.edgeAddingMode==3){type="INDUCES"}else if(window.edgeAddingMode==4){type="REPRESSES"}else if(window.edgeAddingMode==5){type="BINDS"}return type}};module.exports=edgeHandleDefaults},{}],182:[function(require,module,exports){var GenomicDataOverlayManager=require("./GenomicDataOverlayManager.js");var SVGExporter=require("./SVGExporter.js");module.exports=function(){"use strict";var EditorActionsManager=function(isCollaborative,realtimeManager,cyInst){this.cy=cyInst;this.isCollaborative=isCollaborative;if(this.isCollaborative&&realtimeManager)this.realTimeManager=realtimeManager;this.defaultLayoutProperties={name:"cose-bilkent",nodeRepulsion:4500,nodeOverlap:10,idealEdgeLength:50,edgeElasticity:.45,nestingFactor:.1,gravity:.15,numIter:2500,tile:true,animate:"end",randomize:false,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:1.5};this.FIT_CONSTANT=50;this.layoutProperties=_.clone(this.defaultLayoutProperties);this.observers=[];this.genomicDataOverlayManager=new GenomicDataOverlayManager;this.svgExporter=new SVGExporter;this.selecteNodeStack={};window.undoRedoManager=cy.undoRedo();window.undoRedoManager.action("changePositions",this.doChangePosition,this.undoChangePosition);window.undoRedoManager.action("changeName",this.doChangename,this.undoChangeName)};EditorActionsManager.prototype.doChangename=function(args){var currentName=args.node.data("name");var newArgs={node:args.node,newName:args.newName,oldName:currentName};args.node.data("name",args.newName);args.node.css("content",args.newName);return newArgs};EditorActionsManager.prototype.undoChangeName=function(args){var currentName=args.node.data("name");var newArgs={node:args.node,newName:args.oldName,oldName:currentName};args.node.data("name",args.oldName);args.node.css("content",args.oldName);return newArgs};EditorActionsManager.prototype.doChangePosition=function(movedNodes){var newMovedNodes=[];for(var i=0;i0){children.forEach(function(childNode,i){lockedNodes[childNode.id()]=true});removedEles=removedEles.union(removeNodes(children))}removedEles=removedEles.union(nodes.remove());self.cy.nodes().updateCompoundBounds();return removedEles}var removedEles=removeNodes(eles);window.undoRedoManager.do("remove",removedEles);for(var i=0;i0){ele.data.source=cySourceNode.id()}if(cyTargetNode.length>0){ele.data.target=cyTargetNode.id()}if(cyTargetNode.length<0&&cySourceNode.length<0){continue}var edgesBtw=cy.filter('edge[source = "'+cySourceNode.id()+'"][target = "'+cyTargetNode.id()+'"]');var isFound=false;edgesBtw.forEach(function(edge,i){if(edge.data().type==ele.data.type){isFound=true;return false}});if(!isFound){delete ele.data.id;edgesToBeAdded.push(ele)}}cy.add(edgesToBeAdded)};EditorActionsManager.prototype.fitGraph=function(){if(this.isCollaborative){cy.fit(this.FIT_CONSTANT);var newState={zoomLevel:cy.zoom(),panLevel:cy.pan()};this.updateGlobalOptions(newState)}else{cy.fit(this.FIT_CONSTANT)}};EditorActionsManager.prototype.loadFile=function(nodes,edges){if(this.isCollaborative){this.loadfileRealTime(nodes,edges)}else{this.loadFileCy(nodes,edges)}this.fitGraph()};EditorActionsManager.prototype.loadFileCy=function(nodes,edges){this.removeElementCy(cy.elements());this.addNodesCy(nodes);this.addEdgesCy(edges)};EditorActionsManager.prototype.loadfileRealTime=function(nodes,edges){this.realTimeManager.loadGraph(nodes,edges)};EditorActionsManager.prototype.removeAllElements=function(){if(this.isCollaborative){this.realTimeManager.removeAllElements()}else{cy.remove(cy.elements())}};EditorActionsManager.prototype.changeName=function(ele,newName){if(this.isCollaborative){this.realTimeManager.changeName(ele,newName)}else{this.changeNameCy(ele,newName)}};EditorActionsManager.prototype.changeNameCy=function(ele,newName){var currentName=ele.data("name");var args={node:ele,oldName:currentName,newName:newName};window.undoRedoManager.do("changeName",args)};EditorActionsManager.prototype.updateElementCallback=function(ele,id){var nodeID=id;var cyEle=this.cy.$("#"+nodeID);cyEle.position({x:ele.x,y:ele.y});this.changeNameCy(cyEle,ele.name)};EditorActionsManager.prototype.getGenomicDataSVG=function(node){return this.genomicDataOverlayManager.generateSVGForNode(node)};EditorActionsManager.prototype.removeGenomicData=function(){if(this.isCollaborative){this.realTimeManager.clearGenomicData();this.realTimeManager.clearGenomicVisData()}else{this.genomicDataOverlayManager.removeGenomicData();this.genomicDataOverlayManager.removeGenomicVisData();this.genomicDataOverlayManager.hideGenomicData();this.genomicDataOverlayManager.notifyObservers()}};EditorActionsManager.prototype.addGenomicData=function(genomicData){if(this.isCollaborative){this.removeGenomicData();var parsedGenomicData=this.genomicDataOverlayManager.prepareGenomicDataRealTime(genomicData);var genomicDataMap=parsedGenomicData.genomicDataMap;var visibilityMap=parsedGenomicData.visibilityMap;this.realTimeManager.addGenomicData("genomicData",genomicDataMap);this.realTimeManager.addGenomicVisibilityData("visMap",visibilityMap)}else{this.genomicDataOverlayManager.addGenomicDataLocally(genomicData)}};EditorActionsManager.prototype.addPortalGenomicData=function(genomicData){if(this.isCollaborative){this.genomicDataOverlayManager.addPortalGenomicData(genomicData);this.realTimeManager.addGenomicData("genomicData",this.genomicDataOverlayManager.genomicDataMap);this.realTimeManager.addGenomicVisibilityData("visMap",this.genomicDataOverlayManager.visibleGenomicDataMapByType)}else{this.genomicDataOverlayManager.addPortalGenomicData(genomicData)}};EditorActionsManager.prototype.realTimeGenomicDataHandler=function(event){var newData=event.newValue;var geneSymbol=event.property;if(newData){this.genomicDataOverlayManager.addGenomicData(newData)}else{this.genomicDataOverlayManager.removeGenomicData(geneSymbol)}};EditorActionsManager.prototype.realTimeGenomicDataVsibilityHandler=function(event){var data=event.newValue;if(data){this.genomicDataOverlayManager.addGenomicVisData(data)}else{this.genomicDataOverlayManager.removeGenomicVisData(data)}this.genomicDataOverlayManager.showGenomicData();this.genomicDataOverlayManager.notifyObservers()};return EditorActionsManager}()},{"./GenomicDataOverlayManager.js":184,"./SVGExporter.js":193}],183:[function(require,module,exports){var SaveLoadUtilities=require("./SaveLoadUtility.js");module.exports=function($){"use strict";function b64toBlob(b64Data,contentType,sliceSize){contentType=contentType||"";sliceSize=sliceSize||512;var byteCharacters=atob(b64Data);var byteArrays=[];for(var offset=0;offset0?"<0.5":Math.round(percent);var text=textPercent+"%";var fontSize=14;var textLength=text.length;var xOffset=w/2-textLength*4;var yOffset=fontSize/3;var svgText=document.createElementNS(svgNameSpace,"text");svgText.setAttribute("x",x+xOffset);svgText.setAttribute("y",y+h/2+yOffset);svgText.setAttribute("font-family","Arial");svgText.setAttribute("font-size",fontSize);svgText.innerHTML=text;parentSVG.appendChild(overlayRect);parentSVG.appendChild(svgText)}return svg};function getRequiredWidthForGenomicData(genomicDataBoxCount){var term=genomicDataBoxCount>3?genomicDataBoxCount-3:0;return 150+term*35}GenomicDataOverlayManager.prototype.showGenomicData=function(){var self=this;var genomicDataBoxCount=this.countVisibleGenomicDataByType();if(genomicDataBoxCount<1){this.hideGenomicData();return}cy.style().selector('node[type="GENE"]').style("width",function(ele){return getRequiredWidthForGenomicData(genomicDataBoxCount)}).style("text-margin-y",function(ele){var nodeLabel=ele.data("name");if(!(nodeLabel in self.genomicDataMap))return 0;return-15}).style("background-image",function(ele){var dataURI="data:image/svg+xml,";return dataURI+self.generateSVGForNode(ele).outerHTML}).update()};GenomicDataOverlayManager.prototype.parseGenomicData=function(genomicData){this.genomicDataMap={};this.cancerTypes=[];this.visibleGenomicDataMapByType={};var lines=genomicData.split("\n");var metaLineColumns=lines[0].split(" ");for(var i=1;i0){mappedArr[mappedElem.parent().id()].childNodes.push(mappedElem)}else{tree.push(mappedElem)}}return tree};GraphUtilities.prototype.createGraphHierarchyRealTime=function(nodes){var tree=[];var mappedArr={};for(var i=0,len=nodes.length;i');textInput.change(function(){var nodeID=$(this).find("input").attr("nodeid");var cyNode=self.cy.$("#"+nodeID)[0];var newName=$(this).find("input").val();window.editorActionsManager.changeName(cyNode,newName)});var wrapper=$("
    ");var row=$('
    Name:
    ');row.append(textInput);wrapper.append(row);if(ele.data().type==="GENE"){var entrezGeneButton=$('
    ');entrezGeneButton.find("button").on("click",function(event){event.preventDefault();var nodeID=$(this).attr("nodeid");var nodeSymbol=self.cy.$("#"+nodeID)[0]._private.data["name"];var parent=$(this).parent();parent.empty().append('');var formData=new FormData;formData.append("query",nodeSymbol);var request=new XMLHttpRequest;request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE){if(request.status===200){var jsonData=JSON.parse(request.responseText);if(jsonData.count>0){var backboneView=new BackboneView({model:jsonData.geneInfo[0]}).render().html();parent.empty().append(backboneView)}else{parent.empty().append("There is no extra information for this gene")}}else{parent.empty().append("An error occured while retrieving the data")}}};request.open("POST","/getBioGeneData");request.send(formData)});wrapper.append(entrezGeneButton)}return wrapper};QtipManager.prototype.addQtipToElements=function(eles){var self=this;eles.forEach(function(node,i){var qTipOpts={content:{text:function(){return self.generateQtipContentHTML(this)},title:function(){return capitalizeFirstLetter(node.data().type.toLowerCase())+" Details"}},position:{my:"top center",at:"bottom center"},style:{classes:"qtip-tipsy qtip-rounded",width:400}};node.qtip(qTipOpts)})};function capitalizeFirstLetter(string){return string.charAt(0).toUpperCase()+string.slice(1)}return QtipManager}(window.$)},{"./BackboneViews/BioGeneView.js":172}],191:[function(require,module,exports){module.exports=function(){"use strict";var RealTimeManager=function(postFileLoadCallback){this.clientId="122039910543-b7u74aijsqne9iv5rk2tgm3529ped4d0.apps.googleusercontent.com";this.NODEMAP_NAME="nodes";this.EDGEMAP_NAME="edges";this.LAYOUT_PROPS_NAME="layoutProperties";this.GLOBAL_OPTS_NAME="globalOptions";this.GENOMIC_DATA_MAP_NAME="genomicDataMap";this.VISIBLE_GENOMIC_DATA_MAP_NAME="visibleGenomicDataMapByType";this.realtimeUtils=new utils.RealtimeUtils({clientId:this.clientId});this.postFileLoad=postFileLoadCallback};RealTimeManager.prototype.authorize=function(callbackFunction,isModal){this.realtimeUtils.authorize(function(response){callbackFunction(response)},isModal)};RealTimeManager.prototype.initRealTimeAPI=function(){var id=this.realtimeUtils.getParam("id");this.registerTypes();var self=this;var initFileCallback=function(model){self.onFileInitialize(model)};var loadFileCallback=function(model){self.onFileLoaded(model)};if(id){this.realtimeUtils.load(id.replace("/",""),loadFileCallback,initFileCallback)}else{this.realtimeUtils.createAppFile("New Graph",function(createResponse){var result=createResponse.result;window.history.pushState(null,null,"?id="+result.id);self.realtimeUtils.load(result.id,loadFileCallback,initFileCallback)})}};RealTimeManager.prototype.onFileInitialize=function(model){var root=model.getRoot();var nodeMap=model.createMap();var edgeMap=model.createMap();var layoutProperties=model.create(LayoutPropertiesR,window.editorActionsManager.layoutProperties);var globalOptions=model.create(GlobalOptionsR,window.editorActionsManager.getGlobalOptions());var genomicDataMap=model.createMap();var genomicDataVisibilityMap=model.createMap();root.set(this.NODEMAP_NAME,nodeMap);root.set(this.EDGEMAP_NAME,edgeMap);root.set(this.LAYOUT_PROPS_NAME,layoutProperties);root.set(this.GLOBAL_OPTS_NAME,globalOptions);root.set(this.GENOMIC_DATA_MAP_NAME,genomicDataMap);root.set(this.VISIBLE_GENOMIC_DATA_MAP_NAME,genomicDataVisibilityMap)};RealTimeManager.prototype.onFileLoaded=function(doc){var model=doc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var edgeMap=root.get(this.EDGEMAP_NAME);var realTimeLayoutProperties=root.get(this.LAYOUT_PROPS_NAME);var globalOptions=root.get(this.GLOBAL_OPTS_NAME);var genomicDataMap=root.get(this.GENOMIC_DATA_MAP_NAME);var visDataMap=root.get(this.VISIBLE_GENOMIC_DATA_MAP_NAME);var nodeMapEntries=nodeMap.values();var edgeMapEntries=edgeMap.values();window.editorActionsManager.addNewElementsLocally(nodeMapEntries,edgeMapEntries);window.editorActionsManager.updateLayoutPropertiesCallback(realTimeLayoutProperties);window.editorActionsManager.changeGlobalOptions(globalOptions);window.editorActionsManager.genomicDataOverlayManager.genomicDataMap=genomicDataMap.get("genomicData");window.editorActionsManager.genomicDataOverlayManager.visibleGenomicDataMapByType=visDataMap.get("visMap");window.editorActionsManager.genomicDataOverlayManager.showGenomicData();window.editorActionsManager.genomicDataOverlayManager.notifyObservers();cy.fit(50);this.realTimeDoc=doc;var nodeAddRemoveHandler=function(event){window.editorActionsManager.realTimeNodeAddRemoveEventCallBack(event)};var edgeAddRemoveHandler=function(event){window.editorActionsManager.realTimeEdgeAddRemoveEventCallBack(event)};var genomicDataAddRemoveHandler=function(event){window.editorActionsManager.realTimeGenomicDataHandler(event)};var genomicDataVisibilityChangeHandler=function(event){window.editorActionsManager.realTimeGenomicDataVsibilityHandler(event)};root.get(this.NODEMAP_NAME).addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED,nodeAddRemoveHandler);root.get(this.EDGEMAP_NAME).addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED,edgeAddRemoveHandler);root.get(this.GENOMIC_DATA_MAP_NAME).addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED,genomicDataAddRemoveHandler);root.get(this.VISIBLE_GENOMIC_DATA_MAP_NAME).addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED,genomicDataVisibilityChangeHandler);this.postFileLoad()};RealTimeManager.prototype.clearGenomicData=function(){var model=this.realTimeDoc.getModel();var root=model.getRoot();var genomicMap=root.get(this.GENOMIC_DATA_MAP_NAME);var genomicMapKeys=genomicMap.keys();model.beginCompoundOperation();for(var i in genomicMapKeys){genomicMap.delete(genomicMapKeys[i])}model.endCompoundOperation()};RealTimeManager.prototype.clearGenomicVisData=function(){var model=this.realTimeDoc.getModel();var root=model.getRoot();var map=root.get(this.VISIBLE_GENOMIC_DATA_MAP_NAME);var mapKeys=map.keys();model.beginCompoundOperation();for(var i in mapKeys){map.delete(mapKeys[i])}model.endCompoundOperation()};RealTimeManager.prototype.addGenomicData=function(_key,geneData){var model=this.realTimeDoc.getModel();var root=model.getRoot();var genomicMap=root.get(this.GENOMIC_DATA_MAP_NAME);genomicMap.set(_key,geneData)};RealTimeManager.prototype.addGenomicVisibilityData=function(cancerType,isVisible){var model=this.realTimeDoc.getModel();var root=model.getRoot();var map=root.get(this.VISIBLE_GENOMIC_DATA_MAP_NAME);map.set(cancerType,isVisible)};RealTimeManager.prototype.addNewNode=function(nodeData,posData){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var newNode=model.create(NodeR,{name:nodeData.name,type:nodeData.type,parent:nodeData.parent});if(posData){newNode.x=posData.x;newNode.y=posData.y}var realTimeGeneratedID=this.getCustomObjId(newNode);nodeMap.set(realTimeGeneratedID,newNode)};RealTimeManager.prototype.addNewEdge=function(edgeData){var model=this.realTimeDoc.getModel();var root=model.getRoot();var edgeMap=root.get(this.EDGEMAP_NAME);var newEdge=model.create(EdgeR,{type:edgeData.type,source:edgeData.source,target:edgeData.target});var realTimeGeneratedID=this.getCustomObjId(newEdge);edgeMap.set(realTimeGeneratedID,newEdge)};RealTimeManager.prototype.removeElement=function(elementID){var model=this.realTimeDoc.getModel();var root=model.getRoot();var edgeMap=root.get(this.EDGEMAP_NAME);var nodeMap=root.get(this.NODEMAP_NAME);if(nodeMap.has(elementID)){nodeMap.delete(elementID)}else if(edgeMap.has(elementID)){edgeMap.delete(elementID)}else{throw new Error("Element does not exists in Real Time")}};RealTimeManager.prototype.moveElement=function(ele){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var elementID=ele.id();var newPos=ele.position();if(nodeMap.has(elementID)){var tmpNode=nodeMap.get(elementID);model.beginCompoundOperation();tmpNode.x=newPos.x;tmpNode.y=newPos.y;model.endCompoundOperation()}else{throw new Error("Element does not exists in nodes !!! ")}};RealTimeManager.prototype.changeName=function(ele,newName){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var elementID=ele.id();if(nodeMap.has(elementID)){var tmpNode=nodeMap.get(elementID);model.beginCompoundOperation();tmpNode.name=newName;model.endCompoundOperation()}else{throw new Error("Element does not exists in nodes !!! ")}};RealTimeManager.prototype.changeParent=function(rootNode,newParentId,connectedEdges){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var nodeLookupTable={};var self=this;function traverseFromRoot(rootNode,parId){var refNode=rootNode.nodeRef;var children=rootNode.children;var newParentId=parId;if(refNode){var refNodeId=refNode.id();var nodeData=refNode.data();var posData=refNode.position();var newNodeData={name:nodeData.name,type:nodeData.type,x:posData.x,y:posData.y};if(parId){newNodeData.parent=parId}self.removeElement(refNodeId);var newNode=model.create(NodeR,newNodeData);var newNodeId=self.getCustomObjId(newNode);nodeMap.set(newNodeId,newNode);newParentId=newNodeId;nodeLookupTable[refNodeId]=newNodeId}for(var i in children){var childNode=children[i];traverseFromRoot(childNode,newParentId)}}traverseFromRoot(rootNode,newParentId);connectedEdges.forEach(function(edge,index){var edgeData=edge.data();self.removeElement(edge.id());var newSource=nodeLookupTable[edgeData.source];var newTarget=nodeLookupTable[edgeData.target];if(newSource){edgeData.source=newSource}if(newTarget){edgeData.target=newTarget}self.addNewEdge(edgeData)})};RealTimeManager.prototype.removeAllElements=function(){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var edgeMap=root.get(this.EDGEMAP_NAME);var nodeMapKeys=nodeMap.keys();var edgeMapKeys=edgeMap.keys();for(var index in nodeMapKeys){this.removeElement(nodeMapKeys[index])}for(var index in edgeMapKeys){this.removeElement(edgeMapKeys[index])}};RealTimeManager.prototype.loadGraph=function(nodes,edges){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var edgeMap=root.get(this.EDGEMAP_NAME);this.removeAllElements();var that=this;var oldIdNewIdMap={};function traverseTree(node,newParentId){node.data.x=node.position.x;node.data.y=node.position.y;if(newParentId){var parent=node.data.parent;if(parent){node.data.parent=newParentId}}var newNode=model.create(NodeR,node.data);var newNodeId=that.getCustomObjId(newNode);oldIdNewIdMap[node.data.id]=newNodeId;nodeMap.set(newNodeId,newNode);if(node.children.length>0){for(var i in node.children){var tmpNode=node.children[i];traverseTree(tmpNode,newNodeId)}}}var tree=window.GraphUtilities.createGraphHierarchyRealTime(nodes);for(var i in tree){var rootLevelNode=tree[i];traverseTree(rootLevelNode)}for(var i in edges){var edge=edges[i];edge.data.source=oldIdNewIdMap[edge.data.source];edge.data.target=oldIdNewIdMap[edge.data.target];var newEdge=model.create(EdgeR,edge.data);var newEdgeID=this.getCustomObjId(newEdge);edgeMap.set(newEdgeID,newEdge)}};RealTimeManager.prototype.mergeGraph=function(nodes,edges){var model=this.realTimeDoc.getModel();var root=model.getRoot();var nodeMap=root.get(this.NODEMAP_NAME);var edgeMap=root.get(this.EDGEMAP_NAME);var realTimeNodeMap=nodeMap.items();var realTimeNodeLookupTable={};var realTimeNodeNameLookupTable={};var oldIdNewIdMap={};var that=this;for(var i in realTimeNodeMap){var nodeMapItem=realTimeNodeMap[i];realTimeNodeLookupTable[nodeMapItem[0]]=nodeMapItem[1];realTimeNodeNameLookupTable[nodeMapItem[1].name]=nodeMapItem[1]}function traverseTree(node,newParentId){if(!(node.data.name in realTimeNodeNameLookupTable)){node.data.x=node.position.x;node.data.y=node.position.y;if(newParentId){var parent=node.data.parent;if(parent){node.data.parent=newParentId}}var newNode=model.create(NodeR,node.data);var newNodeId=that.getCustomObjId(newNode);oldIdNewIdMap[node.data.id]=newNodeId;nodeMap.set(newNodeId,newNode);if(node.children.length>0){for(var i in node.children){var tmpNode=node.children[i];traverseTree(tmpNode,newNodeId)}}}else{var sameNameNode=realTimeNodeNameLookupTable[node.data.name];var sameNodeId=that.getCustomObjId(sameNameNode);oldIdNewIdMap[node.data.id]=sameNodeId;if(node.children.length>0){for(var i in node.children){var tmpNode=node.children[i];traverseTree(tmpNode,sameNodeId)}}}}var tree=window.GraphUtilities.createGraphHierarchyRealTime(nodes);for(var i in tree){var rootLevelNode=tree[i];traverseTree(rootLevelNode,rootLevelNode.data.id)}for(var i in edges){var edge=edges[i];edge.data.source=oldIdNewIdMap[edge.data.source];edge.data.target=oldIdNewIdMap[edge.data.target];var newEdge=model.create(EdgeR,edge.data);var newEdgeID=this.getCustomObjId(newEdge);edgeMap.set(newEdgeID,newEdge)}};RealTimeManager.prototype.updateLayoutProperties=function(newLayoutProperties){ var model=this.realTimeDoc.getModel();var root=model.getRoot();var layoutPropertiesR=root.get(this.LAYOUT_PROPS_NAME);model.beginCompoundOperation();for(var property in newLayoutProperties){if(newLayoutProperties.hasOwnProperty(property)){layoutPropertiesR[property]=newLayoutProperties[property]}}model.endCompoundOperation()};RealTimeManager.prototype.updateGlobalOptions=function(newOptions){var model=this.realTimeDoc.getModel();var root=model.getRoot();var globalOptions=root.get(this.GLOBAL_OPTS_NAME);model.beginCompoundOperation();for(var property in globalOptions){if(newOptions.hasOwnProperty(property)){globalOptions[property]=newOptions[property]}}model.endCompoundOperation()};RealTimeManager.prototype.getCustomObjId=function(object){return gapi.drive.realtime.custom.getId(object)};RealTimeManager.prototype.registerTypes=function(){this.createRealTimeObjectDefinitions()};RealTimeManager.prototype.createGraphHierarchy=function(nodes){var tree=[];var mappedArr={};for(var i=0,len=nodes.length;i0){var id=files[0].id;successHandler(id)}else{var createProps={resource:{name:appFName,mimeType:"application/vnd.google-apps.folder"}};driveAPI.files.create(createProps).then(function(resp){var newFolderId=resp.result.id;successHandler(newFolderId)},function(err){console.log(err)})}},function(err){console.log(err)})}},shareRealTimeFile:function(fileId){window.gapi.client.drive.permissions.create({resource:{type:"anyone",role:"writer",allowFileDiscovery:false},fileId:fileId}).then(function(resp){console.log("File shared succesfully !")},function(reason){console.log("An Error happened: "+reason.result.error.message)})},load:function(documentId,onFileLoaded,initializeModel){var that=this;window.gapi.drive.realtime.load(documentId,function(doc){onFileLoaded(doc)},initializeModel,this.onError.bind(this))},onError:function(error){if(error.type==window.gapi.drive.realtime.ErrorType.TOKEN_REFRESH_REQUIRED){this.authorizer.authorize(function(){console.log("Error, auth refreshed")},false)}else if(error.type==window.gapi.drive.realtime.ErrorType.CLIENT_ERROR){alert("An Error happened: "+error.message);window.location.href="/"}else if(error.type==window.gapi.drive.realtime.ErrorType.NOT_FOUND){alert("The file was not found. It does not exist or you do not have "+"read access to the file.");window.location.href="/"}else if(error.type==window.gapi.drive.realtime.ErrorType.FORBIDDEN){alert("You do not have access to this file. Try having the owner share"+"it with you from Google Drive.");window.location.href="/"}}};utils.RealtimeAuthorizer=function(realtimeUtil){this.util=realtimeUtil;this.handleAuthResult=this.handleAuthResult.bind(this);this.token=null};utils.RealtimeAuthorizer.prototype={start:function(onAuthComplete,usePopup){var that=this;window.gapi.load("auth:client,drive-realtime,drive-share",{callback:function(){that.authorize(onAuthComplete,usePopup)}});if(this.authTimer){window.clearTimeout(this.authTimer)}this.refreshAuth()},authorize:function(onAuthComplete,usePopup){this.onAuthComplete=onAuthComplete;window.gapi.auth.authorize({client_id:this.util.clientId,scope:this.util.scopes,immediate:!usePopup},this.handleAuthResult)},handleAuthResult:function(authResult){if(authResult&&!authResult.error){this.token=authResult.access_token}this.onAuthComplete(authResult)},refreshAuth:function(){var that=this;this.authTimer=setTimeout(function(){that.authorize(function(){console.log("Refreshed Auth Token")},false);that.refreshAuth()},this.util.refreshInterval)}}}()},{}],193:[function(require,module,exports){var SaveLoadUtilities=require("./SaveLoadUtility.js");module.exports=function(){var SVGExporter=function(){this.SVGNameSpace="http://www.w3.org/2000/svg";this.svg=document.createElementNS(this.SVGNameSpace,"svg");this.NODE_FILL_COLOR="rgb(255,255,255)";this.FAMILY_FILL_COLOR="rgb(255,255,255)";this.FAMILY_STROKE_COLOR="rgb(204,204,204)";this.NODE_STROKE_COLOR="rgb(0,0,0)";this.COMPARTMENT_STROKE_WIDTH=2;this.NODE_STROKE_WIDTH=1;this.NODE_OPACITY=.5;this.ROUNDING_FACTOR=6;this.GENOMICDATA_LABEL_Y_OFFSET=-15;this.EDGE_WIDTH=1;this.T_WIDTH=2;this.T_HEIGHT=8;this.T_ARROW_HEAD_OFFSET=2;this.TRIANGLE_ARROW_HEAD_HEIGHT=8;this.TRIANGLE_ARROW_HEAD_WIDTH=8;this.DASH_PARAMETERS="5, 3";this.COMPOUND_MARGIN=8;this.NODE_FONT_SIZE=14};SVGExporter.prototype.resetSVG=function(){this.svg=document.createElementNS(this.SVGNameSpace,"svg")};SVGExporter.prototype.exportGraph=function(nodes,edges){this.resetSVG();var cyBounds=cy.extent();this.svg.setAttribute("viewBox",cyBounds.x1+" "+cyBounds.y1+" "+cyBounds.w+" "+cyBounds.h);var that=this;var nodeMap={};var nodeTree=window.GraphUtilities.createGraphHierarchy(nodes);var traverseFunction=function(node){nodeMap[node.id()]=node;var genomicDataSVG=window.editorActionsManager.getGenomicDataSVG(node).children;that.svg.appendChild(that.createRect(node));var labelOffset=genomicDataSVG&&genomicDataSVG.length>0?that.GENOMICDATA_LABEL_Y_OFFSET:0;that.svg.appendChild(that.createText(node,labelOffset));if(genomicDataSVG){while(genomicDataSVG.length>0){var elemSVG=genomicDataSVG[0];var nodePosition=node.position();var svgX=elemSVG.getAttribute("x");var svgY=elemSVG.getAttribute("y");elemSVG.setAttribute("x",nodePosition.x-node.width()/2+parseFloat(svgX));elemSVG.setAttribute("y",nodePosition.y-node.height()/2+parseFloat(svgY));that.svg.appendChild(elemSVG)}}if(node.childNodes){for(var i in node.childNodes){traverseFunction(node.childNodes[i])}}};for(var i in nodeTree){var rootLevelNode=nodeTree[i];traverseFunction(rootLevelNode)}edges.forEach(function(edge){var source=nodeMap[edge.source().id()];var target=nodeMap[edge.target().id()];that.drawEdge(edge,source,target)});return this.svg.outerHTML};SVGExporter.prototype.drawEdge=function(edge,source,target){var edgeType=edge.data().type;var sourceRectangle={x:source.position().x,y:source.position().y,width:source.width(),height:source.height()};var targetRectangle={x:target.position().x,y:target.position().y,width:target.width(),height:target.height()};if(source.isParent()){sourceRectangle.width+=this.COMPOUND_MARGIN;sourceRectangle.height+=this.COMPOUND_MARGIN}if(target.isParent()){targetRectangle.width+=this.COMPOUND_MARGIN;targetRectangle.height+=this.COMPOUND_MARGIN}var clipPoints=this.findClippingPoints(sourceRectangle,targetRectangle);var unitV=unitVector({x:clipPoints.targetClipPoints.x-clipPoints.sourceClipPoints.x,y:clipPoints.targetClipPoints.y-clipPoints.sourceClipPoints.y});var inverseUnitV=scale(unitV,-1);var targetX=clipPoints.targetClipPoints.x;var targetY=clipPoints.targetClipPoints.y;if(edgeType=="ACTIVATES"||edgeType=="INDUCES"){targetX=clipPoints.targetClipPoints.x+this.TRIANGLE_ARROW_HEAD_HEIGHT*inverseUnitV.x;targetY=clipPoints.targetClipPoints.y+this.TRIANGLE_ARROW_HEAD_HEIGHT*inverseUnitV.y;var point1Vector=rotateVector(unitV,Math.PI/2);var point2Vector=rotateVector(unitV,-Math.PI/2);point1Vector=scale(point1Vector,this.TRIANGLE_ARROW_HEAD_WIDTH/2);point2Vector=scale(point2Vector,this.TRIANGLE_ARROW_HEAD_WIDTH/2);var point1X=targetX+point1Vector.x;var point1Y=targetY+point1Vector.y;var point2X=targetX+point2Vector.x;var point2Y=targetY+point2Vector.y;var polySVG=document.createElementNS(this.SVGNameSpace,"polygon");polySVG.setAttribute("points",point1X+","+point1Y+","+point2X+","+point2Y+","+clipPoints.targetClipPoints.x+","+clipPoints.targetClipPoints.y);this.svg.appendChild(polySVG)}else if(edgeType=="INHIBITS"||edgeType=="REPRESSES"){targetX=clipPoints.targetClipPoints.x+this.T_ARROW_HEAD_OFFSET*inverseUnitV.x;targetY=clipPoints.targetClipPoints.y+this.T_ARROW_HEAD_OFFSET*inverseUnitV.y;var point1Vector=rotateVector(unitV,Math.PI/2);var point2Vector=rotateVector(unitV,-Math.PI/2);point1Vector=scale(point1Vector,this.T_HEIGHT/2);point2Vector=scale(point2Vector,this.T_HEIGHT/2);var point1X=targetX+point1Vector.x;var point1Y=targetY+point1Vector.y;var point2X=targetX+point2Vector.x;var point2Y=targetY+point2Vector.y;var lineSVG=document.createElementNS(this.SVGNameSpace,"line");lineSVG.setAttribute("x1",point1X);lineSVG.setAttribute("y1",point1Y);lineSVG.setAttribute("x2",point2X);lineSVG.setAttribute("y2",point2Y);lineSVG.setAttribute("stroke-width",this.T_WIDTH);lineSVG.setAttribute("stroke","black");this.svg.appendChild(lineSVG)}var lineSVG=document.createElementNS(this.SVGNameSpace,"line");lineSVG.setAttribute("x1",clipPoints.sourceClipPoints.x);lineSVG.setAttribute("y1",clipPoints.sourceClipPoints.y);lineSVG.setAttribute("x2",targetX);lineSVG.setAttribute("y2",targetY);lineSVG.setAttribute("stroke-width",this.EDGE_WIDTH);lineSVG.setAttribute("stroke","black");if(edgeType=="INDUCES"||edgeType=="REPRESSES"){lineSVG.setAttribute("stroke-dasharray",this.DASH_PARAMETERS)}this.svg.appendChild(lineSVG)};SVGExporter.prototype.findClippingPoints=function(sourceRectangle,targetRectangle){var sourceAABB={xMin:sourceRectangle.x-sourceRectangle.width/2,xMax:sourceRectangle.x+sourceRectangle.width/2,yMin:sourceRectangle.y-sourceRectangle.height/2,yMax:sourceRectangle.y+sourceRectangle.height/2};var targetAABB={xMin:targetRectangle.x-targetRectangle.width/2,xMax:targetRectangle.x+targetRectangle.width/2,yMin:targetRectangle.y-targetRectangle.height/2,yMax:targetRectangle.y+targetRectangle.height/2};var line1={x1:sourceRectangle.x,y1:sourceRectangle.y,x2:targetRectangle.x,y2:targetRectangle.y};var line2={x1:targetRectangle.x,y1:targetRectangle.y,x2:sourceRectangle.x,y2:sourceRectangle.y};var returnObj={sourceClipPoints:clipLine(line1,sourceAABB),targetClipPoints:clipLine(line2,targetAABB)};return returnObj};SVGExporter.prototype.createRect=function(node){var nodeRectangle=document.createElementNS(this.SVGNameSpace,"rect");var nodePosition=node.position();if(node.isParent()){nodeRectangle.setAttribute("x",nodePosition.x-node.width()/2-this.COMPOUND_MARGIN/2);nodeRectangle.setAttribute("y",nodePosition.y-node.height()/2-this.COMPOUND_MARGIN/2);nodeRectangle.setAttribute("width",node.width()+this.COMPOUND_MARGIN);nodeRectangle.setAttribute("height",node.height()+this.COMPOUND_MARGIN)}else{nodeRectangle.setAttribute("x",nodePosition.x-node.width()/2);nodeRectangle.setAttribute("y",nodePosition.y-node.height()/2);nodeRectangle.setAttribute("width",node.width());nodeRectangle.setAttribute("height",node.height())}nodeRectangle=this.createStyleForNodes(node,nodeRectangle);return nodeRectangle};SVGExporter.prototype.createText=function(node,genomicDataOffset){var verticalTextOffset=5;var nodePosition=node.position();var svgText=document.createElementNS(this.SVGNameSpace,"text");if(node.isParent()){verticalTextOffset=20;svgText.setAttribute("x",nodePosition.x);svgText.setAttribute("y",nodePosition.y+node.height()/2+verticalTextOffset)}else{svgText.setAttribute("x",nodePosition.x);svgText.setAttribute("y",nodePosition.y+verticalTextOffset+genomicDataOffset)}svgText.setAttribute("font-family","Arial");svgText.setAttribute("text-anchor","middle");svgText.setAttribute("font-size",this.NODE_FONT_SIZE);svgText.innerHTML=node.data().name;return svgText};SVGExporter.prototype.createStyleForNodes=function(node,nodeRectangle){var nodeType=node.data().type;var strokeWidth=this.NODE_STROKE_WIDTH;var strokeColor=this.NODE_STROKE_COLOR;var fillColor=this.NODE_FILL_COLOR;var opacity=this.NODE_OPACITY;var strokeOpacity=1;if(nodeType=="GENE"||nodeType=="COMPARTMENT"){nodeRectangle.setAttribute("rx",this.ROUNDING_FACTOR);nodeRectangle.setAttribute("ry",this.ROUNDING_FACTOR);if(nodeType=="COMPARTMENT")strokeWidth=this.COMPARTMENT_STROKE_WIDTH}if(nodeType=="PROCESS"){opacity=0;strokeOpacity=0}if(nodeType=="FAMILY"){fillColor=this.FAMILY_FILL_COLOR;strokeColor=this.FAMILY_STROKE_COLOR}var styleString="stroke-width:"+strokeWidth+";"+"stroke:"+strokeColor+";"+"fill-opacity:"+opacity+";"+"fill:"+fillColor+";"+"stroke-opacity:"+strokeOpacity+";";nodeRectangle.setAttribute("style",styleString);return nodeRectangle};function clipLine(line,rectangle){var INSIDE=0;var LEFT=1;var RIGHT=2;var BOTTOM=4;var TOP=8;function getOutCode(point,rectangle){var outcode=INSIDE;if(point.xrectangle.xMax)outcode=outcode|RIGHT;if(point.yrectangle.yMax)outcode=outcode|BOTTOM;return outcode}var outcode0=getOutCode({x:line.x1,y:line.y1},rectangle);var outcode1=getOutCode({x:line.x2,y:line.y2},rectangle);var slope=(line.y2-line.y1)/(line.x2-line.x1);var returnCoords={x:line.x1,y:line.y1,slope:slope};var accept=false;while(true){if(!(outcode0|outcode1)){accept=true;break}else if(outcode0&outcode1){break}else{var outCode=outcode0?outcode0:outcode1;if(outCode&TOP){returnCoords.x=line.x1+(rectangle.yMin-line.y1)/slope;returnCoords.y=rectangle.yMin}else if(outCode&BOTTOM){returnCoords.x=line.x1+(rectangle.yMax-line.y1)/slope;returnCoords.y=rectangle.yMax}else if(outCode&RIGHT){returnCoords.x=rectangle.xMax;returnCoords.y=line.y1+slope*(rectangle.xMax-line.x1)}else if(outCode&LEFT){returnCoords.x=rectangle.xMin;returnCoords.y=line.y1+slope*(rectangle.xMin-line.x1)}if(outCode==outcode0){outcode0=getOutCode({x:returnCoords.x,y:returnCoords.y},rectangle)}else{outcode1=getOutCode({x:returnCoords.x,y:returnCoords.y},rectangle)}}}return returnCoords}function dotProduct(v1,v2){var newX=v1.x*v2.x;var newY=v1.y*v2.y;return{x:newX,y:newY}}function unitVector(v){var inverseLength=1/Math.sqrt(v.x*v.x+v.y*v.y);return{x:v.x*inverseLength,y:v.y*inverseLength}}function rotateVector(v,radians){var newX=v.x*Math.cos(radians)-v.y*Math.sin(radians);var newY=v.x*Math.sin(radians)+v.y*Math.cos(radians);return{x:newX,y:newY}}function scale(v,scalar){var newX=v.x*scalar;var newY=v.y*scalar;return{x:newX,y:newY}}return SVGExporter}()},{"./SaveLoadUtility.js":194}],194:[function(require,module,exports){var SaveLoadUtils={exportGraph:function(pathwayDetails){var returnString=pathwayDetails.pathwayTitle+"\n\n";returnString+=pathwayDetails.pathwayDescription+"\n\n";var nodes=pathwayDetails.graphJSON.elements.nodes;var edges=pathwayDetails.graphJSON.elements.edges;returnString+="--NODE_NAME NODE_ID NODE_TYPE PARENT_ID POSX POSY--"+"\n";if(nodes){for(var i=0;i4?lineData[4]:"0";var posY=lineData.length>5?lineData[5]:"0";var newNode={group:"nodes",data:{id:nodeID,name:nodeName,type:nodeType},position:{x:parseInt(posX),y:parseInt(posY)}};if(parentID!="-1"){newNode.data.parent=parentID}nodes.push(newNode)}for(var i=edgesStartIndex;i0){var firstSelected=nodes[0];var firstBbox=firstSelected.boundingBox();nodes.forEach(function(node,index){if(index==0){return}if(nodeMap[node.parent().id()]==null){var newPosition=calculateNewPosition(param,node,firstBbox);changePosition(node,0,0,newPosition)}});window.editorActionsManager.handleChangePositionByAlignment(movedNodes)}}function calculateNewPosition(param,node,referenceBbox){var currentPos=node.position();var currentBbox=node.boundingBox();var newPosition;if(param==="vLeft"){newPosition={x:referenceBbox.x1+currentBbox.w/2,y:currentPos.y}}else if(param==="vCen"){newPosition={x:referenceBbox.x1+referenceBbox.w/2,y:currentPos.y}}else if(param==="vRight"){newPosition={x:referenceBbox.x2-currentBbox.w/2,y:currentPos.y}}else if(param==="hTop"){newPosition={x:currentPos.x,y:referenceBbox.y1+currentBbox.h/2}}else if(param==="hMid"){newPosition={x:currentPos.x,y:referenceBbox.y1+referenceBbox.h/2}}else if(param==="hBot"){newPosition={x:currentPos.x,y:referenceBbox.y2-currentBbox.h/2}}else{console.log("Error: wrong alignment name "+param);return}return newPosition}function changePosition(node,dx,dy,newPos){if(node.isParent()){var childNodes=node.children();var parentBbox=node.boundingBox();childNodes.forEach(function(childNode,index){var childBbox=childNode.boundingBox();var _dx=-(parentBbox.x1-childBbox.x1)-parentBbox.w/2+childBbox.w/2;var _dy=-(parentBbox.y1-childBbox.y1)-parentBbox.h/2+childBbox.h/2;if(childNode.isParent()){changePosition(childNode,0,0,{x:newPos.x+_dx,y:newPos.y+_dy})}else{changePosition(childNode,_dx,_dy,newPos)}})}else{var position={x:newPos.x+dx,y:newPos.y+dy};movedNodes.push({node:node,nextPosition:position,oldPosition:null})}}$(".viewDropdown li a").click(function(event){event.preventDefault();var dropdownLinkRole=$(event.target).attr("role");if(dropdownLinkRole=="grid"){$("#gridOptionsDiv").modal("show")}else{handleNodeAlignment(dropdownLinkRole)}})}(window.$)},{}],196:[function(require,module,exports){module.exports=function(){function CBioPortalAccessor(){this.GET_ALL_CANCER_STUDIES_URL="http://www.cbioportal.org/webservice.do?cmd=getCancerStudies";this.GET_GENETIC_PROFILES_URL="http://www.cbioportal.org/webservice.do?cmd=getGeneticProfiles&cancer_study_id=";this.GET_PROFILE_DATA_URL="http://www.cbioportal.org/webservice.do?cmd=getProfileData";this.MRNA_EXP_STUDY_NAME="_mrna_median_Zscores";this.CNA_EXP_STUDY_NAME="_gistic";this.MUTATION_EXP_STUDY_NAME="_mutations";this.CNA_DELETION=-2;this.CNA_GAIN=2;this.Z_SCORE_UPPER_THRESHOLD=2;this.Z_SCORE_LOWER_THRESHOLD=-2;this.MUTATION="Mutation";this.GENE_EXPRESSION="Gene Expression";this.CNA="Copy Number Alteration"}CBioPortalAccessor.prototype.fetchCancerStudies=function(callbackFunction){var cancerStudies={};var request=new XMLHttpRequest;request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE&&request.status===200){var seperator=/\r?\n|\r/;var lines=request.responseText.split(seperator);for(var i=1;i=this.Z_SCORE_UPPER_THRESHOLD||parseInt(lineData[j])<=this.Z_SCORE_LOWER_THRESHOLD))profileDataAlteration++}}outData[geneticProfileId][lineData[1]]=profileDataAlteration/numOfTumorSamples*100}callbackFunction(outData)};CBioPortalAccessor.prototype.getProfileData=function(params,callbackFunction){var outData={};var request=new XMLHttpRequest;var self=this;request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE&&request.status===200){self.calcAlterationPercentages(request.responseText,params.geneticProfileId,callbackFunction)}};var queryURL=this.GET_PROFILE_DATA_URL;queryURL+="&case_set_id="+params.caseSetId+"_sequenced";queryURL+="&genetic_profile_id="+params.geneticProfileId;queryURL+="&gene_list=";for(var i=0;i