K.numRows[0]}function L(t){lt=t;var e=F(t);J.selectAll(".pdb-selection-rectangle-group").remove();var n=J.append("g").attr("class","pdb-selection-rectangle-group").attr("opacity",0),i=n.append("rect").attr("fill","none").attr("stroke",K.highlightBorderColor).attr("stroke-width",K.highlightBorderWidth).attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height);n.transition().duration(K.animationDuration).attr("opacity",1),i.datum({initPos:{x:e.x,y:e.y}}),W.trigger(MutationDetailsEvents.PANEL_CHAIN_SELECTED,t)}function F(t){var e=1/0,n=-1,i=-1,a=-1;return t.selectAll("rect").each(function(t,o){var r=d3.select(this);i=parseFloat(r.attr("y")),a=parseFloat(r.attr("height"));var l=parseFloat(r.attr("x")),s=parseFloat(r.attr("width"));e>l&&(e=l),l+s>n&&(n=l+s)}),{x:e,y:i,width:n-e,height:a}}function k(t){null!=lt&&V(lt,t)}function V(t,e){var n=K.animationDuration;N(t,e),t==lt&&N(J.selectAll(".pdb-selection-rectangle-group")),B(t);var i=m(1),a=J.attr("height");j(i,a),J.transition().duration(n).attr("height",i).each("end",function(){G(i,a)})}function N(t,e){var n=K.animationDuration,i=K.marginTop,a=K.chainHeight;t.selectAll("line").transition().duration(n).attr("y1",i+a/2).attr("y2",i+a/2),t.selectAll("rect").transition().duration(n).attr("y",i).each("end",function(){_.isFunction(e)&&e()})}function B(t,e){var n=K.animationDuration,i=t.datum(),a=PdbDataUtil.chainKey(i.pdbId,i.chain.chainId);J.selectAll(".pdb-chain-group").transition().duration(n).attr("opacity",function(t){return PdbDataUtil.chainKey(t.pdbId,t.chain.chainId)===a?1:0}),J.selectAll(".pdb-selection-rectangle-group").transition().duration(n).attr("opacity",function(e){return lt==t?1:0}),J.select(".pdb-panel-y-axis-label-group").transition().duration(n).attr("opacity",0).each("end",function(){_.isFunction(e)&&e()})}function O(t,e,n){J.selectAll(t).transition().duration(n).attr("y1",function(t){return e(this,t,"y1")}).attr("y2",function(t){return e(this,t,"y2")})}function R(t,e,n){J.selectAll(t).transition().duration(n).attr("y",function(t){return e(this,t,"y")})}function U(t){var e=K.animationDuration;q(),z();var n=J.attr("height");j(rt,n),J.transition().duration(e).attr("height",rt).each("end",function(){_.isFunction(t)&&t(),G(rt,n)})}function q(t){var e=K.animationDuration,n=function(t,e,n){return e.initPos.y};R(".pdb-chain-group rect",n,e),O(".pdb-chain-group line",n,e),R(".pdb-selection-rectangle-group rect",n,e),setTimeout(t,e+50)}function z(t){var e=K.animationDuration;J.selectAll(".pdb-chain-group").transition().duration(e).attr("opacity",1),J.selectAll(".pdb-selection-rectangle-group").transition().duration(e).attr("opacity",1),J.selectAll(".pdb-panel-y-axis-label-group").transition().duration(e).attr("opacity",1).each("end",function(){_.isFunction(t)&&t()})}function H(){return lt}function j(t,e){W.trigger(MutationDetailsEvents.PDB_PANEL_RESIZE_STARTED,t,e,K.maxHeight)}function G(t,e){W.trigger(MutationDetailsEvents.PDB_PANEL_RESIZE_ENDED,t,e,K.maxHeight)}var Y={el:"#mutation_pdb_panel_d3",elWidth:740,elHeight:"auto",maxHeight:200,numRows:[1/0],
-marginLeft:45,marginRight:30,marginTop:2,marginBottom:0,chainHeight:6,chainPadding:3,labelY:["PDB","Chains"],labelYFont:"sans-serif",labelYFontColor:"#2E3436",labelYFontSize:"12px",labelYFontWeight:"normal",labelYPaddingRightH:45,labelYPaddingTopH:7,labelYPaddingRightV:25,labelYPaddingTopV:20,labelAlignThreshold:5,chainBorderColor:"#666666",chainBorderWidth:.5,highlightBorderColor:"#FF9900",highlightBorderWidth:2,colors:["#3366cc"],animationDuration:1e3,chainTipFn:function(t){var e=t.datum();n.getPdbInfo(e.pdbId,function(n){var i=null;n&&(i=PdbDataUtil.generatePdbInfoSummary(n[e.pdbId],e.chain.chainId));var a=new PdbChainTipView({model:{pdbId:e.pdbId,pdbInfo:i.title,molInfo:i.molecule,chain:e.chain}}),o=a.compileTemplate(),r={content:{text:o},hide:{fixed:!0,delay:100},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-lightyellow"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,r)})},yHelpTipFn:function(t){var e=BackboneTemplateCache.getTemplateFn("mutation_details_pdb_help_tip_template"),n=e({}),i={content:{text:n},hide:{fixed:!0,delay:100},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-lightyellow qtip-wide"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,i)}},Q={},W={};_.extend(W,Backbone.Events);var K=jQuery.extend(!0,{},Y,t),J=null,Z=null,X=null,tt=0,et=null,nt=0,it=[],at={},ot={},rt=0,lt=null;return{init:v,addListener:b,removeListener:T,getChainGroup:c,getDefaultChainGroup:u,show:D,hide:w,toggleHeight:M,expandToChainLevel:I,minimizeToChain:V,minimizeToHighlighted:k,restoreToFull:U,restoreChainPositions:q,fadeInAll:z,hasMoreChains:E,highlight:L,getHighlighted:H,dispatcher:W}}function MutationPdbTable(t){function e(t,e,n,i,a,o,r,l){var u=DataTableUtil.getColumnOptions(n,a),c={aaData:e,aoColumns:u,aoColumnDefs:[{bVisible:!1,aTargets:o},{bSearchable:!1,aTargets:l}],oColVis:{aiExclude:r},fnDrawCallback:function(t){s._addColumnTooltips()},fnHeaderCallback:function(t,e,n,i,a){$(t).find("th").addClass("mutation-pdb-table-header")},fnRowCallback:function(t,e,n,i){var o=e[a.datum],r=PdbDataUtil.chainKey(o.pdbId,o.chain.chainId);p[r]=t,$(t).addClass("pdb-chain-table-data-row")},fnInitComplete:function(t,e){d.trigger(MutationDetailsEvents.PDB_TABLE_READY)}};return c}function n(t){var e=c.columnVisibility[t],n=e;return e?_.isFunction(e)&&(n=e()):n="hidden",n}function i(t){var e=c.columnSearch[t],n=e;return null==e?n=!1:_.isFunction(e)&&(n=e()),n}function a(){s.getDataTable().fnFilter("")}function o(t,e){var n=PdbDataUtil.chainKey(t,e);r();var i=p[n];$(i).addClass("row_selected"),m=i}function r(){$(c.el).find("tr").removeClass("row_selected")}function l(){return m}var s=this,u={el:"#mutation_pdb_table_d3",elWidth:740,columns:{datum:{sTitle:"datum",tip:""},pdbId:{sTitle:"PDB Id",tip:"",sType:"string"},chain:{sTitle:"Chain",tip:"",sType:"string"},uniprotPos:{sTitle:"Uniprot Positions",tip:"",sType:"numeric"},identityPercent:{sTitle:"Identity Percent",tip:"",sType:"numeric"},organism:{sTitle:"Organism",tip:"",sType:"string"},summary:{sTitle:"Summary",tip:"",sType:"string",sWidth:"65%"}},columnOrder:["datum","pdbId","chain","uniprotPos","identityPercent","organism","summary"],columnVisibility:{pdbId:"visible",chain:"visible",uniprotPos:"visible",identityPercent:"hidden",organism:"visible",summary:"visible",datum:"excluded"},columnSearch:{pdbId:!0,organism:!0,summary:!0},columnRender:{identityPercent:function(t){return Math.round(100*t.chain.mergedAlignment.identityPerc)},pdbId:function(t){var e=BackboneTemplateCache.getTemplateFn("mutation_pdb_table_pdb_cell_template");return e({pdbId:t.pdbId})},chain:function(t){var e=BackboneTemplateCache.getTemplateFn("mutation_pdb_table_chain_cell_template");return e({chainId:t.chain.chainId})},organism:function(t){return t.organism},summary:function(t){var e={summary:t.summary.title,molecule:t.summary.molecule},n=BackboneTemplateCache.getTemplateFn("mutation_pdb_table_summary_cell_template");return n(e)},uniprotPos:function(t){return t.chain.mergedAlignment.uniprotFrom+"-"+t.chain.mergedAlignment.uniprotTo}},columnTooltips:{simple:function(e){MutationViewsUtil.defaultTableTooltipOpts();cbio.util.addTargetedQTip($(e).find(".simple-tip"),t)}},eventListeners:{pdbLink:function(t,e,n){$(t).on("click",".pbd-chain-table-chain-cell a",function(i){i.preventDefault(),r();var a=$(i.target).closest("tr.pdb-chain-table-data-row");a.addClass("row_selected");var o=t.fnGetData(a[0]),l=o[n.datum];e.trigger(MutationDetailsEvents.TABLE_CHAIN_SELECTED,l.pdbId,l.chain.chainId)})}},columnSort:{identityPercent:function(t){return MutationDetailsTableFormatter.assignFloatValue(Math.round(100*t.chain.mergedAlignment.identityPerc))},pdbId:function(t){return t.pdbId},chain:function(t){return t.chain.chainId},organism:function(t){return t.organism},summary:function(t){return t.summary.title+t.summary.molecule},uniprotPos:function(t){return MutationDetailsTableFormatter.assignIntValue(t.chain.mergedAlignment.uniprotFrom)}},columnFilter:{identityPercent:function(t){return Math.round(100*t.chain.mergedAlignment.identityPerc)},summary:function(t){return t.summary.title+" "+t.summary.molecule},uniprotPos:function(t){return t.chain.mergedAlignment.uniprotFrom+"-"+t.chain.mergedAlignment.uniprotTo}},filteringDelay:0,dataTableOpts:{sDom:'<"H"<"mutation_pdb_datatable_info"i><"mutation_pdb_datatable_filter"f>>t',bJQueryUI:!0,bPaginate:!1,bFilter:!0,sScrollY:"200px",bScrollCollapse:!0,oLanguage:{sInfo:"Showing _TOTAL_ PDB chain(s)",sInfoFiltered:"(out of _MAX_ total chains)",sInfoEmpty:"No chains to show"}}},c=jQuery.extend(!0,{},u,t);AdvancedDataTable.call(this,c),c=s._options;var d=s._dispatcher,p={},m=null;this._initDataTableOpts=e,this._visibilityValue=n,this._searchValue=i,this.selectRow=o,this.cleanFilters=a,this.getSelectedRow=l,this.dispatcher=this._dispatcher}function PancanMutationHistogram(t,e,n,i,a){function o(t){return t.map(_.clone)}function r(t){return _.reduce(t,function(t,e){return t[e.cancer_study]=e,t},{})}function l(t){var e=v[t.cancer_study].num_sequenced_samples;return t.num_sequenced_samples=e,t.frequency=t.count/e,t}function s(t){var e=_.reduce(t,function(t,e){return t+e.frequency},0);return-1*e}function u(t){var e=t[0].cancer_type;if(!_.every(t,function(t){return t.cancer_type===e}))throw new Error("not all data in a group have the same cancer type");return e}function c(t){function e(t){return{cancer_study:t,count:0,cancer_type:v[t].cancer_type,num_sequenced_samples:v[t].num_sequenced_samples}}var n=r(t);return _.chain(y).reduce(function(t,e){return _.has(n,e)||t.push(e),t},[]).map(e).value()}function d(t){return t.concat(c(t))}function p(){var t,e=_.find(x[0],function(t){return t.cancer_study===a.this_cancer_study});try{t=e.cancer_type}catch(n){throw new Error(n+": could not find this the corresponding datum for this cancer study, ["+a.this_cancer_study+"]")}var i=function(t){return _.find(t,function(t){return t.cancer_study===a.this_cancer_study})},o=_.zip.apply(null,x);o=_.find(o,i);var r=s(o);L.append("text").text("*").attr("id","star").attr("x",V(a.this_cancer_study)).attr("y",O(-1*r)+10).style("font-family","Helvetica Neue, Helvetica, Arial, sans-serif").style("font-size",3*V.rangeBand()+"px")}function m(t){var e=d3.select(t).selectAll(".mouseOver").data(y).enter().append("rect").attr("class","mouseOver").attr("y",a.margin.top).attr("x",function(t){return V(t)+a.margin.left}).attr("opacity","0").attr("height",E+5).attr("width",V.rangeBand()).on("mouseover",function(){d3.select(this).attr("opacity","0.25")}).on("mouseout",function(){d3.select(this).attr("opacity","0")});e.each(function(t){$(this).qtip({content:{text:"mouseover failed"},position:{my:"left top",at:"center right",viewport:$(window)},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-wide"},hide:{fixed:!0,delay:100},events:{render:function(e,n){var i=g(t).map(function(t){return t[0].__data__}),a=i.filter(function(t){return _.has(t,"keyword")})[0]||{},o=i.filter(function(t){return!_.has(t,"keyword")})[0]||{},r=o.cancer_study,l=v[r].num_sequenced_samples,s=""+r+"
"+f(a,o,l);n.set("content.text",s)}}})})}function h(t,e){var n=t.count||0;"frequency"in t||(t.frequency=n/e);var i=(100*t.frequency).toFixed(1)+"%";return _.template("{{percent}} ({{count}} of {{total}} sequenced samples)")({percent:i,count:n,total:e})}function f(t,e,n){return""+C+": "+h(t,n)+"
Other "+Y+" mutations: "+h(e,n)+"
"}function g(t){return z.filter(function(e){return e.cancer_study===t})}a=a||{},a=a.sparkline?_.extend({margin:{top:-12,right:0,bottom:0,left:0},width:30,height:12,this_cancer_study:void 0},a):_.extend({margin:{top:6,right:10,bottom:20,left:40},width:600,height:300,this_cancer_study:void 0},a);var v=r(n),y=_.keys(v),b=o(t),T=o(e),C=b[0].hugo+" "+b[0].protein_pos_start;b=d(b).map(function(t){return t.keyword=C,t}),T=d(T);var P={bykeyword:r(b),bygene:r(T)},D=_.intersection(_.keys(P.bykeyword),_.keys(P.bygene));if(b=[],T=[],_.each(D,function(t){b.push(P.bykeyword[t]),T.push(P.bygene[t])}),T.length!==b.length)throw new Error("must be same length");if(T.length!==y.length)throw new Error("there must be a datum for every cancer study and visa versa");T.forEach(function(t){var e=P.bykeyword[t.cancer_study],n=t.count-e.count;if(0>n)throw new Error("more mutations for a particular keyword than for all keywords of a particular gene");t.count=n});var w=_.reduce(T,function(t,e){return t+e.count},0),S=_.reduce(b,function(t,e){return t+e.count},0),M=_.reduce(v,function(t,e){return t+e.num_sequenced_samples},0);_.mixin({unzip:function(t){return _.zip.apply(_,t)}});var x=b.concat(T);try{x=_.chain(x).map(l).groupBy(function(t){return t.cancer_study}).map(_.identity).sortBy(u).unzip().value()}catch(A){throw new Error(A)}var I=a.width-a.margin.left-a.margin.left,E=a.height-a.margin.top-a.margin.bottom,L=d3.select(i).append("svg").attr("width",a.width).attr("height",a.height).append("g").attr("transform","translate("+a.margin.left+","+a.margin.top+")"),F=d3.layout.stack().x(function(t){return t.cancer_study}).y(function(t){return t.frequency}),k=F(x),V=d3.scale.ordinal().domain(x[0].map(function(t){return t.cancer_study})).rangeBands([0,I],.1),N=.2,B=a.sparkline?N:d3.max(k,function(t){return d3.max(t,function(t){return t.y0+t.y})}),O=d3.scale.linear().domain([0,B]).range([E,0]).clamp(!0),R="LimeGreen",U="Green",q=L.selectAll(".layer").data(k).enter().append("g").attr("class","layer").style("fill",function(t,e){return[U,R][e]}),z=q.selectAll("rect").data(function(t){return t}).enter().append("rect").attr("x",function(t){return V(t.cancer_study)}).attr("y",function(t){return O(t.y0+t.y)}).attr("width",function(t){return V.rangeBand()}).attr("height",function(t){return O(t.y0)-O(t.y0+t.y)});if(a.sparkline)return{el:i,qtip:function(){throw new Error("don't qtip a sparkline")}};var H=d3.format(B>.1?".0%":".1%"),j=d3.svg.axis().scale(O).tickFormat(H).orient("left");j.tickSize(j.tickSize(),0,0);var G=function(){function t(t){return{cancer_type:t.cancer_type,start:t.cancer_study,end:t.cancer_study,color:v[t.cancer_study].color}}var e=x[0][0];return _.chain(x[0]).reduce(function(e,n){var i=_.last(e);return i.cancer_type!==n.cancer_type?e.concat(t(n)):i.cancer_type===n.cancer_type?(i.end=n.cancer_study,e):void 0},[t(e)]).value()}();L.selectAll("line").data(G).enter().append("line").attr("x1",function(t){return V(t.start)}).attr("x2",function(t){return V(t.end)+V.rangeBand()}).attr("y1",E+a.margin.bottom/3).attr("y2",E+a.margin.bottom/3).style("stroke-width",5).style("stroke",function(t){return t.color});var Y=(L.append("g").call(j).attr("stroke","#000").attr("shape-rendering","crispEdges"),_.find(k[0],function(t){return void 0!==t.hugo}).hugo),C=_.find(k[0],function(t){return void 0!==t.keyword}).keyword;return _.isUndefined(a.this_cancer_study)||p(),{el:i,qtip:m,overallCountText:function(){return f({count:S},{count:w},M)}}}function MainMutationController(t){function e(){t.diagramView?n(t.diagramView.mutationDiagram):t.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,n),t.addResetCallback(i)}function n(t){s=t,t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,o),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,r),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,l),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED,a)}function i(e){s&&s.resetPlot(),t.hideFilterInfo()}function a(){s&&s.isFiltered()?t.showFilterInfo():t.hideFilterInfo()}function o(){s&&!s.isFiltered()&&t.hideFilterInfo()}function r(t,e){s&&0==s.getSelectedElements().length&&o()}function l(e,n){t.showFilterInfo()}var s=null;e()}function Mutation3dController(t,e,n,i,a,o,r){function l(){e.diagramView?s(e.diagramView.mutationDiagram):e.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,s),e.tableView&&e.tableView.mutationTable&&(e.tableView.mutationTable.dispatcher.on(MutationDetailsEvents.PDB_LINK_CLICKED,L),e.tableView.mutationTable.dispatcher.on(MutationDetailsEvents.PROTEIN_CHANGE_LINK_CLICKED,E)),i.addInitCallback(p),t.dispatcher.on(MutationDetailsEvents.GENE_TAB_SELECTED,c),n?u(n):t.dispatcher.on(MutationDetailsEvents.VIS_3D_PANEL_CREATED,u)}function s(t){z=t,t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,S),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,M),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,x),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOVER,A),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOUT,I),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED,w),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_RESET,D)}function u(t){t&&(U=t,q=t.options.mut3dVis,U.dispatcher.on(MutationDetailsEvents.VIEW_3D_PANEL_CLOSED,d),U.dispatcher.on(MutationDetailsEvents.VIEW_3D_STRUCTURE_RELOADED,g))}function c(t){U&&(U.resetPanelPosition(),U.hideView())}function d(){$&&$.hideView()}function p(t){B(),null!=U&&(U.resetPanelPosition(),U.maximizeView())}function m(t,e,n){t>n&&$.toggleScrollBar(n)}function h(t,e,n){n>=t&&$.toggleScrollBar(-1),e!=t&&$.scrollToSelected()}function f(t){H&&$.scrollToSelected();var e=t.datum();null!=U&&(U.maximizeView(),U.updateView(r,e.pdbId,e.chain)),H||null==R||(R.resetFilters(),R.selectChain(e.pdbId,e.chain.chainId),R.scrollToSelected()),H=!1}function g(){i.isVisible()&&z&&z.isHighlighted()&&V()}function v(t,e){t&&e&&($.selectChain(t,e),H=!0)}function y(){$.pdbPanel.minimizeToHighlighted()}function b(t,e){t&&e&&$.pdbPanel.minimizeToChain($.pdbPanel.getChainGroup(t,e))}function T(t){null==$&&($=e.initPdbPanelView(t),$.pdbPanel&&($.pdbPanel.dispatcher.on(MutationDetailsEvents.PANEL_CHAIN_SELECTED,f),$.pdbPanel.dispatcher.on(MutationDetailsEvents.PDB_PANEL_RESIZE_STARTED,m),$.pdbPanel.dispatcher.on(MutationDetailsEvents.PDB_PANEL_RESIZE_ENDED,h)),$.addInitCallback(function(e){C(t)}))}function C(t){null==R&&null!=$&&t.length>0&&(R=$.initPdbTableView(t,function(t,e){e.dispatcher.on(MutationDetailsEvents.PDB_TABLE_READY,P),R=t}),R.pdbTable.dispatcher.on(MutationDetailsEvents.TABLE_CHAIN_SELECTED,v),R.pdbTable.dispatcher.on(MutationDetailsEvents.TABLE_CHAIN_MOUSEOUT,y),R.pdbTable.dispatcher.on(MutationDetailsEvents.TABLE_CHAIN_MOUSEOVER,b)),null!=$&&null!=R&&($.toggleTableControls(),R.toggleView())}function P(){if(null!=$){var t=$.getSelectedChain();if(null!=t){var e=t.datum();R.selectChain(e.pdbId,e.chain.chainId),R.scrollToSelected()}}}function D(){U&&U.isVisible()&&U.refreshView()}function w(){U&&U.isVisible()&&U.refreshView()}function S(){U&&U.isVisible()&&(U.resetHighlight(),U.hideResidueWarning())}function M(t,e){z&&z.isHighlighted()?x():S()}function x(t,e){U&&U.isVisible()&&V()}function A(t,e){if(U&&U.isVisible()){var n=k();n.push(t),N(n,!0)}}function I(t,e){M(t,e)}function E(t){var e=F(t);e&&U&&U.isVisible()&&V()}function L(t){var e=F(t);e&&B(e.get("pdbMatch").pdbId,e.get("pdbMatch").chainId)}function F(t){var e=o.getMutationIdMap(),n=e[t];return n&&z&&(z.clearHighlights(),z.highlightMutation(n.get("mutationSid"))),n}function k(){var t=[];return z&&_.each(z.getSelectedElements(),function(e,n){t=t.concat(e.datum())}),t}function V(){var t=k();N(t)}function N(t,e){var n=U.highlightView(t,!0),i=t.length-n;e||(i>0?U.showResidueWarning(i,t.length):U.hideResidueWarning())}function B(e,n){var o=i.model.uniprotId;t.is3dPanelInitialized()||t.init3dPanel();var r=function(t){null==$&&T(t),null!=U&&null!=$&&t.length>0&&(O(),$.showView(),e&&n?$.selectChain(e,n):$.selectDefaultChain(),$.autoCollapse())};a.getPdbData(o,r)}function O(){if(z){var t=function(t,e,n){return z.mutationColorMap[t]};q.updateOptions({mutationColorMapper:t})}}var $=null,R=null,U=null,q=null,z=null,H=!1;l()}function MutationDetailsController(t,e,n,i){function a(){t.dispatcher.on(MutationDetailsEvents.GENE_TAB_SELECTED,r),t.dispatcher.on(MutationDetailsEvents.GENE_TABS_CREATED,l),t.dispatcher.on(MutationDetailsEvents.VIS_3D_PANEL_INIT,o)}function o(t){var e=p.vis3d;if(e){var n={appOptions:{el:t||"#mutation_details"}},i=jQuery.extend(!0,{},n,e),a=new Mutation3dVis("default3dView",i);a.init(),s(a)}}function r(t){null==v[t]&&u(t,d,p)}function l(){t.$el.find(".mutation-3d-container").hide();var e=h.getGeneList();u(e[0],d,p)}function s(e){var n=t.$el.find(".mutation-3d-container");if(e){var i=new Mutation3dVisView({el:n,config:m.mutation3dVis,mut3dVis:e,pdbProxy:g,mutationProxy:h});i.render(),_=i,t.dispatcher.trigger(MutationDetailsEvents.VIS_3D_PANEL_CREATED,i)}else $(n).hide()}function u(i,a,o){var r=function(r,l){var s=h.getMutationUtil(),u={geneSymbol:i,mutationData:l,dataProxies:n,dataManager:e,uniprotId:r.metadata.identifier,sampleArray:a},d=new MainMutationView({el:"#mutation_details_"+cbio.util.safeProperty(i),config:m.mainMutation,model:u});t.dispatcher.trigger(MutationDetailsEvents.MAIN_VIEW_INIT,d),d.render(),v[i].mainMutationView=d,e.addView(i,d),null==l||0==l.length?d.showNoDataInfo():c(d,i,s,r,o)};h.getMutationData(i,function(t){v[i]={},null==t&&(t=[]);var n=h.getMutationUtil().dataFieldCount(i,"uniprotAcc",["NA"]),a=null,o={geneSymbol:i};n.length>0&&(a=n[0].uniprotAcc),a&&(o.uniprotAcc=a),f.getPfamData(o,function(n){if(null==n)return void console.log("[warning] no pfam data found: %o",o);var i=n[0];e.getData("variantAnnotation",{mutations:t},function(t,e){r(i,t.mutations)})})})}function c(n,i,a,o,r){function l(){if(s){f=n.initMutationDiagramView(s,o);var t=null;m&&(t=m.mutationTable);var e=null;d&&(e=n.initMutationInfoView(d),new MutationInfoController(n)),new MutationDiagramController(f.mutationDiagram,t,e,a)}}var s=r.mutationDiagram,u=r.mutationTable,c=r.vis3d,d=r.infoPanel,p=r.mutationSummary,m=null;u&&(m=n.initMutationTableView(u),new MutationDetailsTableController(n,t));var h=null;p&&(h=n.initSummaryView(u));var f=null;if(a.containsProteinChange(i)?l():e.getData("variantAnnotation",{mutations:n.model.mutationData},function(t,e){l()}),new MainMutationController(n),c){var v=n.init3dView(null);new Mutation3dController(t,n,_,v,g,a,i)}}var d=i.data.sampleList,p=i.view,m=i.render,h=n.mutationProxy,f=n.pfamProxy,g=n.pdbProxy,v={},_=null;a(),this.getMainView=function(t){return v[t]},this.get3dVisView=function(){return _},this.getMainViews=function(){return v},this.getDataManager=function(){return e},this.getDataProxies=function(){return n}}function MutationDetailsTableController(t,e){function n(){t.diagramView?i(t.diagramView.mutationDiagram):t.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,i),t.infoView?a(t.infoView):t.dispatcher.on(MutationDetailsEvents.INFO_PANEL_INIT,a),e.dispatcher.on(MutationDetailsEvents.GENE_TAB_SELECTED,p)}function i(t){m=t,t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,r),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,l),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,s),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOVER,c),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOUT,d),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_RESET,o)}function a(t){t&&t.dispatcher.on(MutationDetailsEvents.INFO_PANEL_MUTATION_TYPE_SELECTED,u)}function o(){t.tableView&&t.tableView.resetFilters()}function r(){t.tableView&&(t.tableView.clearHighlights(),t.tableView.filter(PileupUtil.getPileupMutations(m.pileups)))}function l(e,n){if(t.tableView){t.tableView.clearHighlights();var i=[];m&&_.each(m.getSelectedElements(),function(t,e){i=i.concat(t.datum().mutations)}),i.length>0?t.tableView.filter(i):t.tableView.filter(PileupUtil.getPileupMutations(m.pileups))}}function s(e,n){if(t.tableView){t.tableView.clearHighlights();var i=[];m&&_.each(m.getSelectedElements(),function(t,e){i=i.concat(t.datum().mutations)}),t.tableView.filter(i)}}function u(e){if(null!==t.tableView){var n=t.infoView.currentMapByType[e];_.size(n)>0?t.tableView.filter(n):(n=t.infoView.initialMapByType[e],t.tableView.filter(n),t.tableView.clearSearchBox())}}function c(e,n){t.tableView&&t.tableView.highlight(e.mutations)}function d(e,n){t.tableView&&t.tableView.clearHighlights()}function p(e){if(t.tableView){var n=t.tableView.mutationTable.getDataTable();n.is(":visible")&&n.fnAdjustColumnSizing()}}var m=null;n()}function MutationDiagramController(t,e,n,i){function a(){e&&e.dispatcher.on(MutationDetailsEvents.MUTATION_TABLE_FILTERED,o),n&&n.dispatcher.on(MutationDetailsEvents.INFO_PANEL_MUTATION_TYPE_SELECTED,r)}function o(e){var n=[],i=[];try{i=$(e).DataTable().rows({filter:"applied"}).data()}catch(a){i=$(e).dataTable()._("tr",{filter:"applied"})}if(_.each(i,function(t,e){var i=t[0].mutation;i&&n.push(i)}),null!==t){var o=new MutationCollection(n);t.updatePlot(PileupUtil.convertToPileups(o))}}function r(e){if(null!==t){var i=n.currentMapByType[e];_.size(i)>0?t.updatePlot(PileupUtil.convertToPileups(new MutationCollection(i))):(i=n.initialMapByType[e],t.updatePlot(PileupUtil.convertToPileups(new MutationCollection(i))))}}a()}function MutationInfoController(t){function e(){t.diagramView?n(t.diagramView.mutationDiagram):t.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,n)}function n(t){s=t,t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_RESET,r),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED,l),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,o),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,a),t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,i)}function i(){l()}function a(e,n){if(t.infoView){var i=[];s&&_.each(s.getSelectedElements(),function(t,e){i=i.concat(t.datum())}),i.length>0?t.infoView.updateView(PileupUtil.getPileupMutations(i)):l()}}function o(t,e){a(t,e)}function r(){l()}function l(){t.infoView&&t.infoView.updateView(PileupUtil.getPileupMutations(s.pileups))}var s=null;e()}function MutationMapper(t){function e(){o.proxy.mutationProxy.options.geneList=o.data.geneList.join(" ");var t=DataProxyUtil.initDataProxies(o.proxy);o.dataManager=jQuery.extend(!0,{},o.dataManager,{dataProxies:t});var e=new MutationDataManager(o.dataManager),a={mutationProxy:t.mutationProxy},r={el:o.el,config:o.render.mutationDetails,model:a},l=new MutationDetailsView(r);n=l;var s=new MutationDetailsController(l,e,t,o);i=s,l.render()}var n=null,i=null,a={el:"#mutation_details",data:{geneList:[],sampleList:[]},view:{mutationDiagram:{},mutationTable:{},mutationSummary:{},pdbPanel:{},pdbTable:{},infoPanel:{},vis3d:{}},render:{mutationDetails:{init:null,format:null},mainMutation:{},mutation3dVis:{}},proxy:{pfamProxy:{instance:null,instanceClass:PfamDataProxy,options:{data:{}}},variantAnnotationProxy:{instance:null,instanceClass:VariantAnnotationDataProxy,options:{data:{}}},mutationProxy:{instance:null,instanceClass:MutationDataProxy,options:{data:{},params:{},geneList:""}},clinicalProxy:{instance:null,instanceClass:ClinicalDataProxy,options:{data:{}}},pdbProxy:{instance:null,instanceClass:PdbDataProxy,options:{data:{pdbData:{},infoData:{},summaryData:{},positionData:{}},mutationUtil:{}}},pancanProxy:{instance:null,instanceClass:PancanMutationDataProxy,options:{data:{byKeyword:{},byProteinChange:{},byProteinPosition:{},byGeneSymbol:{}}}},mutationAlignerProxy:{instance:null,instanceClass:MutationAlignerDataProxy,options:{data:{}}},portalProxy:{instance:null,instanceClass:PortalDataProxy,options:{data:{}}}},dataManager:{dataFn:{},dataProxies:{}}},o=jQuery.extend(!0,{},a,t);this.init=e,this.getView=function(){return n},this.getController=function(){return i}}var DataTableUtil=function(){function t(t){var e={};return _.each(t,function(t,n){null==e[t]&&(e[t]=n)}),e}function e(t){var e={};return _.each(_.pairs(t),function(t,n){var i=t[0],a=t[1];null!=a.sTitle&&a.sTitle.length>0&&(e[a.sTitle]=i)}),e}function n(t,e){var n={};return _.each(t,function(t,i){null==n[t]&&(_.isFunction(e)?n[t]=e(t):n[t]="hidden")}),n}function i(t,e){var n={};return _.each(t,function(t,i){null==n[t]&&(n[t]=_.isFunction(e)&&e(t))}),n}function a(t,e,n){var i=[];return _.each(t,function(t,a){"visible"!=n[t]&&i.push(e[t])}),i}function o(t,e,n){var i=[];return _.each(t,function(t,a){"excluded"==n[t]&&i.push(e[t])}),i}function r(t,e,n){var i=[];return _.each(t,function(t,a){n[t]===!1&&i.push(e[t])}),i}function l(t,e){var n=[];return _.each(_.pairs(t),function(t){var i=t[0],a=t[1],o=e[i];if(null!=o){var r={fnRender:function(t){var n=t.aData[e.datum];return a(t,n)},aTargets:[o]};n.push(r)}}),n}function s(t,e,n,i,a){var o={};return _.each(_.pairs(e),function(e){var a=e[0],r=e[1],l=n[a],s=i[a],u=t[a],c=function(t){return null!=l?l(t):r(t)};if(null!=u){var d={mData:function(e,n,i){var a=e[t.datum];return"set"===n?null:"display"===n?r(a):"sort"===n?c(a):"filter"===n?null!=s?s(a):c(a):e[u]},aTargets:[u]};o[a]=d}}),_.each(_.pairs(a),function(e){var n=e[0],i=e[1],a=t[n],r={mData:function(e,n,a){return i(e,n,a,t)},aTargets:[a]};o[n]=r}),_.values(o)}function u(t,e){var n=[];return _.each(_.pairs(t),function(t){var i=t[0],a=t[1],o=e[i];o>0&&(n[o]=a)}),n}function c(t){var e=$(t).attr("alt"),n=parseFloat(e);return isNaN(n)&&(n=""),n}function d(t){return-1!=t.indexOf("label")?$(t).find("label").text().trim()||$(t).text().trim():-1}function p(t){return-1!=t.indexOf("label")?parseInt($(t).text()):-1}function m(t){return-1!=t.indexOf("label")?parseFloat($(t).text()):-1}function h(t,e,n,i){return n>=0?i>=0?n==i?0:i>n?-1:1:-1:i>=0?1:t==e?0:e>t?1:-1}function f(t,e,n,i){return n>=0?i>=0?n==i?0:i>n?1:-1:-1:i>=0?1:t==e?0:e>t?-1:1}return{buildColumnIndexMap:t,buildColumnNameMap:e,buildColumnVisMap:n,buildColumnSearchMap:i,getHiddenColumns:a,getExcludedColumns:o,getNonSearchableColumns:r,getColumnOptions:u,getColumnRenderers:l,getColumnData:s,compareSortAsc:h,compareSortDesc:f,getAltTextValue:c,getLabelTextValue:d,getLabelTextIntValue:p,getLabelTextFloatValue:m}}(),MutationViewsUtil=function(){function t(t,e,n,i){var a=new MutationMapper(e),o=!1;return $(t).is(":visible")&&(a.init(),o=!0),$(n).bind("tabsactivate",function(t,e){e.newTab.text().trim().toLowerCase()==i.toLowerCase()&&(o?a.getView().refreshGenesTab():(a.init(),o=!0))}),a}function e(){return{mutationType:r,validationStatus:l,mutationStatus:s,omaScore:u,cna:c}}function n(){return{content:{attr:"alt"},show:{event:"mouseover"},hide:{fixed:!0,delay:100,event:"mouseout"},style:{classes:"mutation-details-tooltip qtip-shadow qtip-light qtip-rounded"},position:{my:"top left",at:"bottom right",viewport:$(window)}}}function i(t){t=t||"images/ajax-loader.gif";var e={loaderImage:t,width:15,height:15},n=BackboneTemplateCache.getTemplateFn("mutation_table_placeholder_template");return n(e)}function a(t,e,n){var i=t.fnGetData();_.each(i,function(i,a){t.fnUpdate(null,a,e[n],!1,!1)}),i.length>0&&t.fnUpdate(null,0,e[n])}var o={missense:{label:"Missense",longName:"Missense",style:"missense_mutation",mainType:"missense",priority:1},inframe:{label:"IF",longName:"In-frame",style:"inframe_mutation",mainType:"inframe",priority:2},truncating:{label:"Truncating",longName:"Truncating",style:"trunc_mutation",mainType:"truncating",priority:4},nonsense:{label:"Nonsense",longName:"Nonsense",style:"trunc_mutation",mainType:"truncating",priority:6},nonstop:{label:"Nonstop",longName:"Nonstop",style:"trunc_mutation",mainType:"truncating",priority:7},nonstart:{label:"Nonstart",longName:"Nonstart",style:"trunc_mutation",mainType:"truncating",priority:8},frameshift:{label:"FS",longName:"Frame Shift",style:"trunc_mutation",mainType:"truncating",priority:4},frame_shift_del:{label:"FS del",longName:"Frame Shift Deletion",style:"trunc_mutation",mainType:"truncating",priority:4},frame_shift_ins:{label:"FS ins",longName:"Frame Shift Insertion",style:"trunc_mutation",mainType:"truncating",priority:5},in_frame_ins:{label:"IF ins",longName:"In-frame Insertion",style:"inframe_mutation",mainType:"inframe",priority:3},in_frame_del:{label:"IF del",longName:"In-frame Deletion",style:"inframe_mutation",mainType:"inframe",priority:2},splice_site:{label:"Splice",longName:"Splice site",style:"trunc_mutation",mainType:"truncating",priority:9},fusion:{label:"Fusion",longName:"Fusion",style:"fusion",mainType:"other",priority:10},other:{style:"other_mutation",mainType:"other",priority:11}},r={missense_mutation:o.missense,missense:o.missense,missense_variant:o.missense,frame_shift_ins:o.frame_shift_ins,frame_shift_del:o.frame_shift_del,frameshift:o.frameshift,frameshift_deletion:o.frame_shift_del,frameshift_insertion:o.frame_shift_ins,de_novo_start_outofframe:o.frameshift,frameshift_variant:o.frameshift,nonsense_mutation:o.nonsense,nonsense:o.nonsense,stopgain_snv:o.nonsense,splice_site:o.splice_site,splice:o.splice_site,"splice site":o.splice_site,splicing:o.splice_site,splice_site_snp:o.splice_site,splice_site_del:o.splice_site,splice_site_indel:o.splice_site,translation_start_site:o.nonstart,start_codon_snp:o.nonstart,start_codon_del:o.nonstart,nonstop_mutation:o.nonstop,in_frame_del:o.in_frame_del,in_frame_ins:o.in_frame_ins,indel:o.in_frame_del,nonframeshift_deletion:o.inframe,nonframeshift:o.inframe,"nonframeshift insertion":o.inframe,nonframeshift_insertion:o.inframe,targeted_region:o.inframe,inframe:o.inframe,truncating:o.truncating,fusion:o.fusion,other:o.other},l={valid:{label:"V",style:"valid",tooltip:"Valid"},validated:{label:"V",style:"valid",tooltip:"Valid"},wildtype:{label:"W",style:"wildtype",tooltip:"Wildtype"},unknown:{label:"U",style:"unknown",tooltip:"Unknown"},not_tested:{label:"U",style:"unknown",tooltip:"Unknown"},none:{label:"U",style:"unknown",tooltip:"Unknown"},na:{label:"U",style:"unknown",tooltip:"Unknown"}},s={somatic:{label:"S",style:"somatic",tooltip:"Somatic"},germline:{label:"G",style:"germline",tooltip:"Germline"},unknown:{label:"U",style:"unknown",tooltip:"Unknown"},none:{label:"U",style:"unknown",tooltip:"Unknown"},na:{label:"U",style:"unknown",tooltip:"Unknown"}},u={h:{label:"High",style:"oma_high",tooltip:"High"},m:{label:"Medium",style:"oma_medium",tooltip:"Medium"},l:{label:"Low",style:"oma_low",tooltip:"Low"},n:{label:"Neutral",style:"oma_neutral",tooltip:"Neutral"}},c={"-2":{label:"DeepDel",style:"cna-homdel",tooltip:"Deep deletion"},"-1":{label:"ShallowDel",style:"cna-hetloss",tooltip:"Shallow deletion"},0:{label:"Diploid",style:"cna-diploid",tooltip:"Diploid / normal"},1:{label:"Gain",style:"cna-gain",tooltip:"Low-level gain"},2:{label:"AMP",style:"cna-amp",tooltip:"High-level amplification"},unknown:{label:"NA",style:"cna-unknown",tooltip:"CNA data is not available for this gene"}};return{initMutationMapper:t,renderTablePlaceHolder:i,refreshTableColumn:a,defaultTableTooltipOpts:n,getVisualStyleMaps:e}}(),MutationDetailsTableFormatter=function(){function t(t){return e(E,t)}function e(t,e){var n,i,a;return null!=t[e]?(n=t[e].style,i=t[e].label,a=t[e].tooltip):(n=t.unknown.style,i=t.unknown.label,a=t.unknown.tooltip),{style:n,tip:a,text:i}}function n(t){var e=16,n=t,i="",a=t;return null!=t&&t.length>e+2&&(n=t.substring(0,e)+"...",i="simple-tip"),{style:i,tip:a,text:n}}function i(t){return a(M,t)}function a(t,e){var n,i;return null!=e&&(e=e.toLowerCase()),null!=t[e]?(n=t[e].style,i=t[e].label):(n=t.other.style,i=e),{style:n,text:i}}function o(t){
-return r(A,t)}function r(t,e){var n="simple-tip",i=e,a="";return null!=e&&(e=e.toLowerCase()),null!=t[e]&&(n=t[e].style,i=t[e].label,a=t[e].tooltip),{style:n,tip:a,text:i}}function l(t){return s(x,t)}function s(t,e){var n,i,a;return null!=e&&(e=e.toLowerCase()),null!=t[e]?(n=t[e].style,i=t[e].label,a=t[e].tooltip):(n=t.unknown.style,i=t.unknown.label,a=t.unknown.tooltip),{style:n,tip:a,text:i}}function u(t,e){return c(I,t,e)}function c(t,e,n){var i="",a="",o="",r="";return null!=e&&(e=e.toLowerCase()),null!=t[e]&&(r=t[e].tooltip,null!=n&&(r=n.toFixed(2)),i=t[e].label,a=t[e].style,o="oma_link"),{fisClass:a,omaClass:o,value:r,text:i}}function d(t,e,n,i){var a="NA",o=e+n,r="",l="";return t&&(r="mutation_table_allele_freq",a=t.toFixed(2),l=i),{text:a,total:o,style:r,tipClass:l}}function p(t){return h(t.get("pdbMatch"))}function m(t){return h(t.get("igvLink"))}function h(t){return t?"#":""}function f(t){var e="mutation-table-protein-change",n="click to highlight the position on the diagram",i="";return null!=t.get("aminoAcidChange")&&t.get("aminoAcidChange").length>0&&"NA"!==t.get("aminoAcidChange")&&null!=t.get("cancerStudyShort")&&-1!=t.get("cancerStudyShort").toLowerCase().indexOf("msk-impact")&&g(t.get("proteinChange"),t.get("aminoAcidChange"))&&(i="The original annotation file indicates a different value: "+v(t.get("aminoAcidChange"))+""),{text:v(t.get("proteinChange")),style:e,tip:n,additionalTip:i}}function g(t,e){var n=!1;if(t=v(t),e=v(e),e!==t){var i=t.match(/[A-Z]/g),a=e.match(/[A-Z]/g),o=t.match(/[0-9]+/),r=e.match(/[0-9]+/),l=t.match(/([a-z]+)/),s=e.match(/([a-z]+)/);o&&r&&o.length>0&&r.length>0&&o[0]!=r[0]?n=!0:i&&a&&i.length>0&&a.length>0&&"X"!==i[0]&&"X"!==a[0]&&i[0]!==a[0]?n=!0:i&&a&&i.length>1&&a.length>1&&i[1]!==a[1]?n=!0:l&&s&&l.length>0&&s.length>0&&l[0]!==s[0]&&(n=!0)}return n}function v(t){var e="p.";return-1!=t.indexOf(e)&&(t=t.substr(t.indexOf(e)+e.length)),t}function _(t){var e="tumor_type",n="";return{text:t.get("tumorType"),style:e,tip:n}}function y(t){var e="",n="";return t>0&&(e="mutation_table_cosmic",n=t),{style:e,count:n}}function b(t){var e="",n="";return t>0&&(e="mutation_table_cbio_portal",n=t),{style:e,frequency:n}}function T(t){var e=t,n="mutation_table_int_value";return null==t&&(e="NA",n=""),{text:e,style:n}}function C(t){var e=t,n="mutation_table_allele_count";return null==t&&(e="NA",n=""),{text:e,style:n}}function P(t,e){var n;return null!=t&&(t=t.toLowerCase()),n="low"==t||"l"==t?2:"medium"==t||"m"==t?3:"high"==t||"h"==t?4:"neutral"==t||"n"==t?1:-1,n>0&&!isNaN(e)&&(n+=e/1e3),n}function D(t){var e=parseInt(t);return isNaN(e)&&(e=-(1/0)),e}function w(t){var e=parseFloat(t);return isNaN(e)&&(e=-(1/0)),e}var S=MutationViewsUtil.getVisualStyleMaps(),M=S.mutationType,x=S.validationStatus,A=S.mutationStatus,I=S.omaScore,E=S.cna;return{getCaseId:n,getProteinChange:f,getPdbMatchLink:p,getIgvLink:m,getAlleleCount:C,getAlleleFreq:d,getCNA:t,getMutationType:i,getMutationStatus:o,getValidationStatus:l,getFis:u,getTumorType:_,getCosmic:y,getCbioPortal:b,getIntValue:T,assignValueToPredictedImpact:P,assignIntValue:D,assignFloatValue:w}}(),PileupUtil=function(){function t(t){var e=t.mutations,n={};return _.each(e,function(t){var e=t.get("mutationType")||"";e=e.trim().toLowerCase(),void 0==n[e]&&(n[e]=[]),n[e].push(t)}),n}function e(e){var n=t(e),i=[];return _.each(_.keys(n),function(t){i.push({type:t,count:n[t].length})}),i.sort(function(t,e){return e.count-t.count}),i}function n(e){var n=MutationViewsUtil.getVisualStyleMaps().mutationType,i=t(e),a=[],o={};return _.each(_.keys(i),function(t){var e=void 0;null!=n[t]&&(e=n[t].mainType),void 0==e&&(e=n.other.mainType),void 0==o[e]&&(o[e]=0),o[e]+=i[t].length}),_.each(_.keys(o),function(t){a.push({type:t,count:o[t],priority:n[t].priority})}),a.sort(function(t,e){return e.count===t.count?e.priority-t.priority:e.count-t.count}),a}function i(){return c++,"pileup_"+c}function a(t){var e={};return _.each(t,function(t){_.each(t.mutations,function(n){e[n.get("mutationSid")]=t.pileupId})}),e}function o(t){t=r(t);for(var e={},n=0;n0&&(e[t.get("proteinChange")]=t.get("proteinChange"))});var n=_.keys(e).sort(),i="";n.length>1&&(i=cbio.util.lcss(n[0],n[n.length-1]));var a=i;return _.each(n,function(t){a+=t.substring(i.length)+"/"}),a.substring(0,a.length-1)}function s(t){var e=0;return _.each(t,function(t){e+=t.count}),e}function u(t){var e=[];return _.each(t,function(t){e=e.concat(t.get("mutations")||[])}),e}var c=0;return{nextId:i,mapToMutations:a,convertToPileups:o,countMutations:s,getPileupMutations:u,getMutationTypeMap:t,groupMutationsByType:e,groupMutationsByMainType:n}}(),BackboneTemplateCache=function(){function t(t){return _.template($("#"+t).html())}function e(e){var i=n[e];return null==i&&(i=t(e),n[e]=i),i}var n={};return{getTemplateFn:e}}(),DataProxyUtil=function(){function t(t){var n={};return _.each(_.keys(t).sort(),function(i){var a=t[i],o=null;o="pdbProxy"==i?e(a,function(t){var e=n.mutationProxy;return null!=e&&e.hasData()?(t.options.mutationUtil=e.getMutationUtil(),!0):!1}):e(a),n[i]=o}),n}function e(t,e){var n=t.instance;if(null==n){if(null!=e&&_.isFunction(e)&&!e(t))return null;var i=t.instanceClass;n=new i(t.options),n.init()}return n}return{initDataProxies:t,initDataProxy:e}}();JmolScriptGenerator.prototype=new MolScriptGenerator,JmolScriptGenerator.prototype.constructor=JmolScriptGenerator,Mol3DScriptGenerator.prototype=new MolScriptGenerator,Mol3DScriptGenerator.prototype.constructor=Mol3DScriptGenerator;var MutationDetailsUtil=function(t){var e="germline",n="valid",i={},a={},o={},r={},l={},s={},u=[];this.getMutationGeneMap=function(){return i},this.getMutationCaseMap=function(){return a},this.getMutationIdMap=function(){return o},this.getMutations=function(){return u},this.processMutationData=function(t){i=this._updateGeneMap(t),a=this._updateCaseMap(t),o=this._updateIdMap(t),r=this._updateKeywordMap(t),l=this._updateProteinChangeMap(t),s=this._updateProteinPosStartMap(t),u=u.concat(t.models)},this.getProteinPositions=function(t){var e=i[t],n=[];if(null!=e)for(var a=0;a0&&(void 0!==t.numGermlineCases&&t.numGermlineCases>0&&(i=t.numGermlineCases),e=t.numGermline/i*100,n+="Germline Mutation Rate: "+e.toFixed(1)+"%, "),e=t.numSomatic/t.numCases*100,n+="Somatic Mutation Rate: "+e.toFixed(1)+"%]"},this.countMutations=function(t,n){for(var i=n.length,o=0,r=0,l=0,s=0;s0})},this.containsRefAllele=function(t){return this._contains(t,function(t){return t.get("referenceAllele")&&"NA"!=t.get("referenceAllele")})},this.containsVarAllele=function(t){return this._contains(t,function(t){return t.get("variantAllele")&&"NA"!=t.get("variantAllele")})},this.containsEndPos=function(t){return this._contains(t,function(t){return t.get("endPos")&&t.get("endPos")>0})},this.containsFis=function(t){return this._contains(t,function(t){return t.get("functionalImpactScore")&&"NA"!=t.get("functionalImpactScore")})},this.containsCosmic=function(t){return this._contains(t,function(t){return t.get("cosmic")&&t.getCosmicCount()&&t.getCosmicCount()>0})},this.containsMutationType=function(t){return this._contains(t,function(t){return t.get("mutationType")&&"NA"!=t.get("mutationType")})},this.containsMutationCount=function(t){return this._contains(t,function(t){return t.get("mutationCount")&&t.get("mutationCount")>0})},this.containsKeyword=function(t){return this._contains(t,function(t){return t.get("keyword")&&"NA"!=t.get("keyword")})},this.containsMutationEventId=function(t){return this._contains(t,function(t){return t.get("mutationEventId")&&"NA"!=t.get("mutationEventId")})},this.distinctTumorTypeCount=function(t){t=t.toUpperCase();var e=i[t],n={};if(null!=e)for(var a=0;ae.pdbId?-1:1),n});var e=null,n=[],i={};return _.each(t,function(t,n){e=new PdbAlignmentModel(t),void 0==i[e.pdbId]&&(i[e.pdbId]={}),void 0==i[e.pdbId][e.chain]&&(i[e.pdbId][e.chain]=[]),i[e.pdbId][e.chain].push(e)}),_.each(_.keys(i),function(t){var e=[];_.each(_.keys(i[t]),function(n){var a=new PdbChainModel({chainId:n,alignments:i[t][n]});e.push(a)});var a=new PdbModel({pdbId:t,chains:e});n.push(a)}),new PdbCollection(n)}function e(t){var e=[],n=t.midlineAlign,i=t.uniprotAlign,a=t.pdbAlign;if(n.length===i.length&&n.length===a.length)for(var o=0;o0?(i+=t[0].alignmentString,a=t[0].uniprotTo,e=t[0],_.each(t,function(t,n){var o=t.uniprotFrom-a-1,r=t.alignmentString;if(0==o)i+=r;else if(o>0){for(var l=[],s=0;o>s;s++)l.push(C);l.push(r),i+=l.join("")}else{var u=[],c=Math.min(-1*o,r.length);u.push(i.substr(i.length+o,c)),u.push(r.substr(0,c)),u[0]!=u[1]&&(console.log("[warning] alignment mismatch: "+e.alignmentId+" & "+t.alignmentId),console.log(u[0]),console.log(u[1])),i+=r.substr(-1*o)}a=Math.max(a,t.uniprotTo),a==t.uniprotTo&&(e=t)}),n.uniprotFrom=t[0].uniprotFrom,n.uniprotTo=n.uniprotFrom+i.length,n.pdbFrom=t[0].pdbFrom,n.mergedString=i,n.identityPerc=u(i),n.identity=c(i),n):n}function r(t,e){var n=null,i=t.getProteinStartPos(),a=t.get("mutationType")||"";if(a=a.trim().toLowerCase(),null==i||"fusion"===a)return n;for(var o=0;o=c.uniprotFrom&&i<=c.uniprotTo;if(d&&s(c,i)){n={pdbId:u.pdbId,chainId:u.chain.chainId};break}}if(n)break}return n}function l(t,e){return e?(_.each(t,function(t,n){if(null==t)return void console.log("warning [processMutationData]: mutation (at index %d) is null.",n);var i=PdbDataUtil.mutationToPdb(t,e);t.set({pdbMatch:i})}),t):t}function s(t,e){var n=e-t.uniprotFrom,i=t.mergedString[n],a=i==C;return!a}function u(t){for(var e=0,n=0,i=0;i0){for(var a=!1,o=0;o0&&n[0].sort(function(t,e){return e.chain.mergedAlignment.mergedString.length-t.chain.mergedAlignment.mergedString.length}),n}function p(t,e){var n=!0;return(t.mergedAlignment.uniprotFrom>=e.mergedAlignment.uniprotTo||e.mergedAlignment.uniprotFrom>=t.mergedAlignment.uniprotTo)&&(n=!1),n}function m(t){var e=[];return t.each(function(t,n){t.chains.each(function(n,i){var a={pdbId:t.pdbId,chain:n};e.push(a)})}),h(e,[g,y,v,b,T]),e}function h(t,e){t.sort(function(t,n){for(var i=0,a=0;at.pdbId?-1:e.pdbIdt.chain.chainId?-1:e.chain.chainId0&&(r=r.substring(n.length),l=l.substring(n.length),t+=n.length,e+=n.length,a=t.toString(),o=e.toString())}}var n=void 0,i=t.chr,a=t.startPos,o=t.endPos,r=t.referenceAllele,l=t.variantAllele;return _.isFunction(t.get)&&(i=t.get("chr"),a=t.get("startPos"),o=t.get("endPos"),r=t.get("referenceAllele"),l=t.get("variantAllele")),null!=r&&r===l&&console.log("[VariantAnnotationUtil.generateVariantKey] Warning: Reference allele ("+r+") for "+i+":"+a+"-"+o+" is the same as variant allele"),i&&a&&r&&l&&(e(),n=i+":g."+a+r+">"+l,o&&("-"===r||0===r.length?n=i+":g."+o+"_"+a+"ins"+l:("-"===l||0===l.length)&&(n=i+":g."+a+"_"+o+"del"+r))),n}return{generateVariantKey:i,addAnnotationData:t}}(),VepParser=function(){function t(t){var i={};if(!t)return console.log("[warning] VEP parser error"),{};if(t.error)return console.log("[warning] VEP parser error: "+t.error),{};var o=t.allele_string,l=o.split("/",-1);2===l.length&&(i.referenceAllele=l[0],i.variantType=a(l[0],l[1])),i.ncbiBuildNo=t.assembly_name,i.chr=t.seq_region_name,i.startPos=t.start,i.endPos=t.end,i.strand=r(t.strand);var s=t.transcript_consequences,u=t.most_severe_consequence;i.transcripts=[],_.each(s,function(t,n){i.transcripts.push(e(t,u,i.variantType))});var c=n(s,u);return c&&i.transcripts[c.index]&&(i.canonicalTranscript=i.transcripts[c.index]),i.rawData=t,i}function e(t,e,n,i){i=i||{},i.geneSymbol=t.gene_symbol;var a=t.consequence_terms;if(null!=a&&a.length>0){var r=o(a[0]);"Frame_Shift"===r&&(null!=n&&"INS"===n?r+="_Ins":"DEL"===n&&(r+="_Del")),i.variantClassification=r}var s=t.refseq_transcript_ids;null!=s&&s.length>0&&(i.refseqIds=s);var u=t.hgvsc;null!=u&&(i.hgvsc=u.substr(u.indexOf(":")+1));var c=t.hgvsp;null!=c&&(i.hgvsp=c.substr(c.indexOf(":")+1)),i.transcriptId=t.transcript_id,i.proteinPosStart=t.protein_start,i.proteinPosEnd=t.protein_end,i.codons=t.codons;var d;if(null!=c&&(d=c.substr(c.indexOf(":")+1),_.each(_.pairs(l),function(t,e){d=d.replace(new RegExp(t[0],"g"),t[1])}),i.hgvspShort=d),("splice_acceptor_variant"===e||"splice_donor_variant"===e)&&i.hgvsc){var p=/c\.([0-9]+)*/.exec(i.hgvsc);if(p&&2==p.length){var m=parseInt(p[1]);1>m&&(m=1);var h=m+m%3/3;i.hgvspShort="p.X"+h+"_splice"}}return"synonymous_variant"===e&&(d="p."+t.amino_acids+t.protein_start+t.amino_acids,i.hgvspShort=d),i.mutationType=i.variantClassification,i.proteinChange=i.hgvspShort,i.refseqIds&&i.refseqIds.length>0&&(i.refseqMrnaId=i.refseqIds[0]),i}function n(t,e){var n=[];return _.each(t,function(t,e){1==t.canonical&&n.push({index:e,transcript:t})}),1===n.length?n[0]:n.length>1?i(n,e):(_.each(t,function(t,e){n.push({index:e,transcript:t})}),i(n,e))}function i(t,e){var n=null;return _.each(t,function(t,i){var a=t.transcript.consequence_terms;null==n&&null!=a&&null!=e&&_.each(a,function(i,a){i.trim().toLowerCase()===e.trim().toLowerCase()&&(n=t)})}),n}function a(t,e){var n=t.length,i=e.length;if(n="-"===t?0:n,i="-"===e?0:i,n===i){var a=["SNP","DNP","TNP"];return 3>n?a[n-1]:"ONP"}return i>n?"INS":"DEL"}function o(t){return s[t.toLowerCase()]}function r(t){var e;return e=null==t||"+"===t||"-"===t?t:0>t?"-":t>0?"+":t}var l={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Asx:"B",Cys:"C",Glu:"E",Gln:"Q",Glx:"Z",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V",Xxx:"X",Ter:"*"},s={splice_acceptor_variant:"Splice_Site",splice_donor_variant:"Splice_Site",transcript_ablation:"Splice_Site",stop_gained:"Nonsense_Mutation",frameshift_variant:"Frame_Shift",stop_lost:"Nonstop_Mutation",initiator_codon_variant:"Translation_Start_Site",start_lost:"Translation_Start_Site",inframe_insertion:"In_Frame_Ins",inframe_deletion:"In_Frame_Del",missense_variant:"Missense_Mutation",protein_altering_variant:"Missense_Mutation",coding_sequence_variant:"Missense_Mutation",conservative_missense_variant:"Missense_Mutation",rare_amino_acid_variant:"Missense_Mutation",transcript_amplification:"Intron",splice_region_variant:"Intron",intron_variant:"Intron",INTRAGENIC:"Intron",intragenic_variant:"Intron",incomplete_terminal_codon_variant:"Silent",synonymous_variant:"Silent",stop_retained_variant:"Silent",NMD_transcript_variant:"Silent",mature_miRNA_variant:"RNA",non_coding_exon_variant:"RNA",non_coding_transcript_exon_variant:"RNA",non_coding_transcript_variant:"RNA",nc_transcript_variant:"RNA","5_prime_UTR_variant":"5'UTR","5_prime_UTR_premature_start_codon_gain_variant":"5'UTR","3_prime_UTR_variant":"3'UTR",TF_binding_site_variant:"IGR",regulatory_region_variant:"IGR",regulatory_region:"IGR",intergenic_variant:"IGR",intergenic_region:"IGR",upstream_gene_variant:"5'Flank",downstream_gene_variant:"3'Flank",TFBS_ablation:"Targeted_Region",TFBS_amplification:"Targeted_Region",regulatory_region_ablation:"Targeted_Region",regulatory_region_amplification:"Targeted_Region",feature_elongation:"Targeted_Region",feature_truncation:"Targeted_Region"};return{parseJSON:t}}(),MutationModel=Backbone.Model.extend({_initialize:function(t){this.mutationId=t.mutationId,this.mutationSid=t.mutationSid,this.geneticProfileId=t.geneticProfileId,this.mutationEventId=t.mutationEventId,this.caseId=t.caseId,this.geneSymbol=t.geneSymbol,this.linkToPatientView=t.linkToPatientView,this.cancerType=t.cancerType,this.cancerStudy=t.cancerStudy,this.cancerStudyShort=t.cancerStudyShort,this.cancerStudyLink=t.cancerStudyLink,this.tumorType=t.tumorType,this.proteinChange=t.proteinChange,this.aminoAcidChange=t.aminoAcidChange,this.mutationType=t.mutationType,this.cosmic=t.cosmic,this.cosmicCount=this.calcCosmicCount(t.cosmic),this.functionalImpactScore=t.functionalImpactScore,this.fisValue=t.fisValue,this.msaLink=t.msaLink,this.xVarLink=t.xVarLink,this.pdbLink=t.pdbLink,this.pdbMatch=t.pdbMatch,this.igvLink=t.igvLink,this.mutationStatus=t.mutationStatus,this.validationStatus=t.validationStatus,this.sequencingCenter=t.sequencingCenter,this.ncbiBuildNo=t.ncbiBuildNo,this.chr=t.chr,this.startPos=t.startPos,this.endPos=t.endPos,this.referenceAllele=t.referenceAllele,this.variantAllele=t.variantAllele,this.tumorFreq=t.tumorFreq,this.normalFreq=t.normalFreq,this.tumorRefCount=t.tumorRefCount,this.tumorAltCount=t.tumorAltCount,this.normalRefCount=t.normalRefCount,this.normalAltCount=t.normalAltCount,this.canonicalTranscript=t.canonicalTranscript,this.refseqMrnaId=t.refseqMrnaId,this.codonChange=t.codonChange,this.uniprotId=t.uniprotId,this.uniprotAcc=t.uniprotAcc,this.proteinPosStart=t.proteinPosStart,this.proteinPosEnd=t.proteinPosEnd,this.mutationCount=t.mutationCount,this.specialGeneData=t.specialGeneData,this.keyword=t.keyword,this.cna=t.cna,this.myCancerGenome=t.myCancerGenome,this.isHotspot=t.isHotspot},url:function(){},getProteinStartPos:function(){var t=this.get("proteinPosStart");return(null==t||0==t.length||"NA"==t||0>t)&&(t=this.getProteinChangeLocation()),t},getProteinChangeLocation:function(){var t=null,e=null,n=this.get("proteinChange");return null!=n&&(e=n.match(/[0-9]+/)),e&&e.length>0&&(t=e[0]),t},getCosmicCount:function(){if(this.get("cosmicCount"))return this.get("cosmicCount");if(this.get("cosmic")){var t=this.calcCosmicCount(this.get("cosmic"));return this.set({cosmicCount:t}),t}return null},calcCosmicCount:function(t){var e=0;return t&&t.forEach(function(t){e+=t[2]}),e}}),MutationCollection=Backbone.Collection.extend({model:MutationModel,initialize:function(t){},parse:function(t){},url:function(){}}),PdbAlignmentModel=Backbone.Model.extend({initialize:function(t){this.alignmentId=t.alignmentId,this.pdbId=t.pdbId,this.chain=t.chain,this.uniprotId=t.uniprotId,this.pdbFrom=t.pdbFrom,this.pdbTo=t.pdbTo,this.uniprotFrom=t.uniprotFrom,this.uniprotTo=t.uniprotTo,this.alignmentString=t.alignmentString||PdbDataUtil.alignmentString(t),this.eValue=t.eValue,this.identityPerc=t.identityPerc}}),PdbAlignmentCollection=Backbone.Collection.extend({model:PdbAlignmentModel,initialize:function(t){}}),PdbChainModel=Backbone.Model.extend({initialize:function(t){this.chainId=t.chainId,this.positionMap=t.positionMap,this.alignments=new PdbAlignmentCollection(t.alignments),this.mergedAlignment=PdbDataUtil.mergeAlignments(t.alignments)}}),PdbChainCollection=Backbone.Collection.extend({model:PdbChainModel,initialize:function(t){}}),PdbModel=Backbone.Model.extend({initialize:function(t){this.pdbId=t.pdbId,this.chains=new PdbChainCollection(t.chains)}}),PdbCollection=Backbone.Collection.extend({model:PdbModel,initialize:function(t){}}),Pileup=Backbone.Model.extend({initialize:function(t){this.pileupId=t.pileupId,this.mutations=t.mutations,this.count=t.count,this.location=t.location,this.label=t.label,this.stats=t.stats}}),CosmicTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){this.$el.find(".cosmic-details-table").dataTable({aaSorting:[[2,"desc"]],sDom:"pt",aoColumnDefs:[{mRender:function(t,e,n){return''+t+""},aTargets:[0]},{sType:"aa-change-col",sClass:"left-align-td",aTargets:[1]},{sType:"numeric",sClass:"left-align-td",aTargets:[2]}],bDestroy:!1,bPaginate:!0,bJQueryUI:!0,bFilter:!1})},_parseCosmic:function(t){var e=[];return t.forEach(function(t){e.push(t[0]+""+t[1]+" | "+t[2])})," | "+e.join(" |
")+" |
"},compileTemplate:function(){var t=this._parseCosmic(this.model.cosmic),e={cosmicDataRows:t,cosmicTotal:this.model.total,mutationKeyword:this.model.keyword},n=BackboneTemplateCache.getTemplateFn("mutation_details_cosmic_tip_template");return n(e)}}),LollipopTipStatsView=Backbone.View.extend({initialize:function(){},render:function(){var t=BackboneTemplateCache.getTemplateFn("mutation_details_lollipop_tip_stats_template"),e=this.$el.find("table tbody");return _.each(this.model,function(n){e.append(t(n))}),this}}),LollipopTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){},showStats:!1,setShowStats:function(t){this.showStats=t},getShowStats:function(t){return this.showStats},compileTemplate:function(){var t=this.model,e=t.count>1?"mutations":"mutation",n={count:t.count,mutationStr:e,label:t.label},i=BackboneTemplateCache.getTemplateFn("mutation_details_lollipop_tip_template"),a=$(i(n)),o=a.find(".lollipop-stats");return this.showStats?(new LollipopTipStatsView({el:o,model:t.stats}).render(),o.find("table").dataTable({sDom:"t",bJQueryUI:!0,bDestroy:!0,aaSorting:[[1,"desc"]],aoColumns:[{bSortable:!1},{bSortable:!1}]})):o.hide(),a.html()}}),MainMutationView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t),this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e={geneSymbol:t.model.geneSymbol,uniprotId:t.model.uniprotId},n=BackboneTemplateCache.getTemplateFn("mutation_view_template"),i=n(e);t.$el.html(i),t.format()},format:function(){var t=this;t.$el.find(".mutation-details-filter-info").hide(),t.$el.find(".mutation-details-no-data-info").hide(),t.$el.find(".mutation-3d-initializer").hide(),t.$el.find(".mutation-info-panel-container").hide(),t.$el.find(".mutation-summary-view").hide(),t.$el.find(".mutation-table-container").hide(),t.$el.find(".mutation-diagram-view").hide()},initPdbPanelView:function(t){var e=this,n=null;e.diagramView&&e.diagramView.mutationDiagram&&(n=e.diagramView.mutationDiagram);var i={el:e.$el.find(".mutation-pdb-panel-view"),config:{loaderImage:e.options.config.loaderImage},model:{geneSymbol:e.model.geneSymbol,pdbColl:t,pdbProxy:e.model.dataProxies.pdbProxy},diagram:n},a=new PdbPanelView(i);return a.render(),e._pdbPanelView=a,a},initSummaryView:function(){var t=this,e=t.$el.find(".mutation-summary-view");e.show();var n={el:e,model:{mutationProxy:t.model.dataProxies.mutationProxy,clinicalProxy:t.model.dataProxies.clinicalProxy,geneSymbol:t.model.geneSymbol,sampleArray:t.model.sampleArray}},i=new MutationSummaryView(n);return i.render(),t.summaryView=i,i},init3dView:function(t){var e=this;return e._init3dView(e.model.geneSymbol,e.model.uniprotId,e.model.dataProxies.pdbProxy,t)},_init3dView:function(t,e,n,i){var a=this,o=a.$el.find(".mutation-3d-initializer");o.show();var r=new Mutation3dView({el:o,model:{uniprotId:e,geneSymbol:t,pdbProxy:n}});return r.render(),i&&i.isVisible()&&r.resetView(),r},initMutationDiagramView:function(t,e){var n=this;return n.diagramView=n._initMutationDiagramView(n.model.geneSymbol,n.model.mutationData,e,n.model.dataProxies,t),n.diagramView?n.dispatcher.trigger(MutationDetailsEvents.DIAGRAM_INIT,n.diagramView.mutationDiagram):console.log("Error initializing mutation diagram: %s",n.model.geneSymbol),n.diagramView},_initMutationDiagramView:function(t,e,n,i,a){var o=this,r=o.$el.find(".mutation-diagram-view");r.show();var l={mutations:e,sequence:n,geneSymbol:t,dataProxies:i,diagramOpts:a},s=new MutationDiagramView({el:r,model:l});return s.render(),s},initMutationTableView:function(t){var e=this;return e.tableView=e._initMutationTableView(e.model.geneSymbol,e.model.mutationData,e.model.dataProxies,e.model.dataManager,t),e.tableView||console.log("Error initializing mutation table: %s",e.model.geneSymbol),e.tableView},_initMutationTableView:function(t,e,n,i,a){var o=this,r=o.$el.find(".mutation-table-container");r.show();var l=new MutationDetailsTableView({el:r,config:{loaderImage:o.options.config.loaderImage},model:{geneSymbol:t,mutations:e,dataProxies:n,dataManager:i,tableOpts:a}});return l.render(),l},initMutationInfoView:function(t){var e=this,n=e.$el.find(".mutation-info-panel-container");n.show();var i={mutations:e.model.mutationData,infoPanelOpts:t},a=new MutationInfoPanelView({el:n,model:i});return a.render(),e.infoView=a,e.dispatcher.trigger(MutationDetailsEvents.INFO_PANEL_INIT,e.infoView),a},addResetCallback:function(t){var e=this,n=e.$el.find(".mutation-details-filter-reset");n.click(t)},showFilterInfo:function(){this.$el.find(".mutation-details-filter-info").slideDown()},hideFilterInfo:function(){this.$el.find(".mutation-details-filter-info").slideUp()},showNoDataInfo:function(){this.$el.find(".mutation-details-no-data-info").slideDown();
-},hideNoDataInfo:function(){this.$el.find(".mutation-details-no-data-info").slideUp()}}),Mutation3dView=Backbone.View.extend({initialize:function(t){this.options=t||{},this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e=(t.model.geneSymbol,BackboneTemplateCache.getTemplateFn("mutation_3d_view_template")),n=e({});this.$el.html(n),this.format()},format:function(){var t=this,e=t.$el.find(".mutation-3d-vis");e.attr("disabled","disabled");var n=function(n){if(n)e.removeAttr("disabled");else{var i=t.model.geneSymbol,a="No structure data for "+i,o={content:{text:a},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow cc-ui-tooltip"},position:{my:"bottom center",at:"top center",viewport:$(window)}};t.$el.qtip(o)}},i=t.model.pdbProxy,a=t.model.uniprotId;i.hasPdbData(a,n)},addInitCallback:function(t){var e=this,n=e.$el.find(".mutation-3d-vis");n.click(t)},resetView:function(){var t=this,e=t.$el.find(".mutation-3d-vis");e.click()},isVisible:function(){var t=this;return t.$el.is(":visible")}}),Mutation3dVisInfoView=Backbone.View.extend({render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("mutation_3d_vis_info_template"),n=e(t.model);t.$el.html(n),t.format()},format:function(){var t=this,e=t.model.pdbInfo,n=t.model.molInfo;null==e||0==e.length?t.$el.find(".mutation-3d-pdb-info").hide():t._addExpander(".mutation-3d-pdb-info"),null==n||0==n.length?t.$el.find(".mutation-3d-mol-info").hide():t._addExpander(".mutation-3d-mol-info")},_addExpander:function(t){var e=this,n={slicePoint:40,widow:2,expandPrefix:" ",expandText:"[...]",userCollapseText:"[^]",moreClass:"expander-read-more",lessClass:"expander-read-less",detailClass:"expander-details",expandEffect:"fadeIn",collapseEffect:"fadeOut"};e.$el.find(t).expander(n)}}),Mutation3dVisView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif",helpImage:"images/help.png"}};this.options=jQuery.extend(!0,{},e,t),this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("mutation_3d_vis_template"),n=e({loaderImage:t.options.config.loaderImage,helpImage:t.options.config.helpImage});t.$el.html(n),t.format()},format:function(){var t=this,e=t.options.mut3dVis,n=t.$el;n.hide(),t.hideResidueWarning(),t.hideNoMapWarning();var i=t.$el.find(".mutation-3d-vis-help-content"),a=BackboneTemplateCache.getTemplateFn("3Dmol_basic_interaction");i.html(a({})),i.hide(),null!=e&&e.updateContainer(n),t.$el.find(".mutation-3d-close").click(function(){t.hideView()}),t.$el.find(".mutation-3d-minimize").click(function(){null!=e&&e.toggleSize()}),t._initMutationControls(),t._initProteinControls(),t._initButtons(),n.draggable({handle:".mutation-3d-info-title",stop:function(t,e){var i=parseInt(n.css("top")),a=parseInt(n.css("left"));0>i&&n.css("top",0),0>a&&n.css("left",0)}}),n.resizable({alsoResize:".mutation-3d-vis-container,.mutation-3d-vis-container div:eq(0)",handles:"sw, s, w",minWidth:400,minHeight:300,start:function(t,e){n.find(".mutation-3d-vis-help-content").css("width","auto"),n.css("position","fixed")},stop:function(t,e){n.css("height","auto"),n.css("position","fixed")},resize:function(t,n){t.stopPropagation(),e.resizeViewer()}}).on("resize",function(t){t.stopPropagation()})},_initButtons:function(){var t=this,e=t.options.mut3dVis,n=t.$el.find(".mutation-3d-vis-help-content"),i=t.$el.find(".mutation-3d-vis-help-init"),a=t.$el.find(".mutation-3d-vis-help-open"),o=t.$el.find(".mutation-3d-vis-help-close"),r=t.$el.find(".mutation-3d-pymol-dload");a.click(function(t){t.preventDefault(),n.slideToggle(),i.slideToggle()}),o.click(function(t){t.preventDefault(),n.slideToggle(),i.slideToggle()}),r.click(function(n){n.preventDefault();var i=e.generatePymolScript(),a=t.$el.find(".mutation-3d-pdb-id").text().trim()+"_"+t.$el.find(".mutation-3d-chain-id").text().trim()+".pml",o={filename:a,contentType:"text/plain;charset=utf-8",preProcess:!1};cbio.download.initDownload(i,o)}),r.qtip(t._generateTooltipOpts("Download PyMOL script"))},_initMutationControls:function(){var t=this,e=t.options.mut3dVis,n=t.$el.find(".mutation-3d-side-chain-select");n.change(function(){var t=$(this).val();e&&(e.updateOptions({displaySideChain:t}),e.reapplyStyle())});var i=t.$el.find(".mutation-3d-mutation-color-select");i.change(function(){var t=$(this).val();e&&(e.updateOptions({colorMutations:t}),e.reapplyStyle())}),t._initMutationColorInfo(),t._initSideChainInfo()},_initProteinControls:function(){var t=this,e=t.options.mut3dVis,n=t.$el.find(".mutation-3d-display-non-protein");n.change(function(){var t=n.is(":checked");e&&(e.updateOptions({restrictProtein:!t}),e.reapplyStyle())}),t._initHideNonProteinInfo(),t._initProteinSchemeSelector(),t._initProteinColorSelector()},_initProteinColorSelector:function(){var t=this,e=t.$el.find(".mutation-3d-protein-color-select"),n=t.options.mut3dVis;e.change(function(){var t=$(this).val();n.updateOptions({colorProteins:t}),n.reapplyStyle()})},_initProteinSchemeSelector:function(){var t=this,e=t.options.mut3dVis,n=t.$el.find(".mutation-3d-protein-style-select"),i=t.$el.find(".mutation-3d-protein-color-select");t._initProteinColorInfo(),n.change(function(){var t=$(this).val(),n=!1;i.find("option").removeAttr("disabled");var a=[];if("spaceFilling"==t?(a.push(i.find("option[value='bySecondaryStructure']")),a.push(i.find("option[value='byChain']"))):a.push(i.find("option[value='byAtomType']")),_.each(a,function(t,e){t.is(":selected")&&(t.removeAttr("selected"),i.find("option[value='uniform']").attr("selected","selected"),n="uniform"),t.attr("disabled","disabled")}),e){var o={};o.proteinScheme=t,n&&(o.colorProteins=n),e.updateOptions(o),e.reapplyStyle()}})},_initZoomSlider:function(){var t=this,e=t.$el.find(".mutation-3d-zoom-slider"),n=t.options.mut3dVis,i=function(t){return 0>t?100+t:100+5*t},a=function(t,e){n&&n.zoomTo(i(e.value))};e.slider({value:0,min:-80,max:80,stop:a,slide:a})},updateView:function(t,e,n){var i=this,a=i.options.mut3dVis,o=i.options.pdbProxy,r=function(t){n.positionMap=t,a.show(),i.refreshView(e,n),i.pdbId=e,i.chain=n},l=function(a){var l={pdbId:e,chainId:n.chainId,pdbInfo:"",molInfo:""};if(a&&a[e]){var s=PdbDataUtil.generatePdbInfoSummary(a[e],n.chainId);l.pdbInfo=s.title,l.molInfo=s.molecule}var u=new Mutation3dVisInfoView({el:i.$el.find(".mutation-3d-info"),model:l});u.render(),o.getPositionMap(t,n,r)};o.getPdbInfo(e,l)},refreshView:function(t,e){var n=this,i=n.options.mut3dVis;n.hideResidueWarning(),n.hideNoMapWarning();var a=function(t){0==t.length?n.showNoMapWarning():n.hideNoMapWarning()};if(null==t&&null==e||t==n.pdbId&&e==n.chain){var o=i.refresh();a(o),n.dispatcher.trigger(MutationDetailsEvents.VIEW_3D_STRUCTURE_RELOADED)}else n.showLoader(),setTimeout(function(){var o=i.reload(t,e,function(){n.hideLoader(),n.dispatcher.trigger(MutationDetailsEvents.VIEW_3D_STRUCTURE_RELOADED)});a(o)},50)},_initMutationColorInfo:function(){var t=this,e=t.$el.find(".mutation-type-color-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_type_color_tip_template"),i=n({}),a=t._generateTooltipOpts(i);a.style.classes+=" qtip-wide",e.qtip(a)},_initProteinColorInfo:function(){var t=this,e=t.$el.find(".protein-struct-color-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_structure_color_tip_template"),i=n({}),a=t._generateTooltipOpts(i);a.style.classes+=" qtip-wide",e.qtip(a)},_initSideChainInfo:function(){var t=this,e=t.$el.find(".display-side-chain-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_side_chain_tip_template"),i=n({}),a=t._generateTooltipOpts(i);e.qtip(a)},_initHideNonProteinInfo:function(){var t=this,e=t.$el.find(".display-non-protein-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_non_protein_tip_template"),i=n({}),a=t._generateTooltipOpts(i);e.qtip(a)},_generateTooltipOpts:function(t){return{content:{text:t},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow"},position:{my:"top right",at:"bottom center",viewport:$(window)}}},minimizeView:function(){var t=this,e=t.options.mut3dVis;e&&e.minimize()},maximizeView:function(){var t=this,e=t.options.mut3dVis;e&&e.maximize()},resetPanelPosition:function(){var t=this,e=t.$el;e.css({left:"",position:"",top:0})},hideView:function(){var t=this,e=t.options.mut3dVis;null!=e&&e.hide(),t.dispatcher.trigger(MutationDetailsEvents.VIEW_3D_PANEL_CLOSED)},isVisible:function(){var t=this,e=t.options.mut3dVis;return e.isVisible()},focusView:function(t){var e=this,n=e.options.mut3dVis;return t?n.focusOn(t):(n.resetFocus(),!0)},highlightView:function(t,e){var n=this,i=n.options.mut3dVis;return i.highlight(t,e)},resetHighlight:function(){var t=this,e=t.options.mut3dVis;e.resetHighlight()},showLoader:function(){var t=this,e=t.$el.find(".mutation-3d-vis-loader"),n=t.$el.find(".mutation-3d-vis-container"),i=n.css("height");0!==i&&"0px"!==i&&(t._actualHeight=i,n.css("height",0)),e.show()},hideLoader:function(){var t=this,e=t.$el.find(".mutation-3d-vis-loader"),n=t.$el.find(".mutation-3d-vis-container");e.hide(),n.css("height",t._actualHeight)},showResidueWarning:function(t,e){var n=this,i=n.$el.find(".mutation-3d-residue-warning"),a=n.$el.find(".mutation-3d-unmapped-info");n.$el.find(".mutation-3d-nomap-warning").is(":visible")||(e>1?a.text(t+" of the selections"):a.text("Selected mutation"),i.show())},hideResidueWarning:function(){var t=this,e=t.$el.find(".mutation-3d-residue-warning");e.hide()},showNoMapWarning:function(){var t=this,e=t.$el.find(".mutation-3d-nomap-warning");e.show()},hideNoMapWarning:function(){var t=this,e=t.$el.find(".mutation-3d-nomap-warning");e.hide()}}),MutationCustomizePanelView=Backbone.View.extend({initialize:function(t){this.options=t||{}},render:function(){var t=this,e=t.options.diagram,n={minY:2,maxY:e.getInitialMaxY()},i=BackboneTemplateCache.getTemplateFn("mutation_customize_panel_template"),a=i(n);t.$el.html(a),t.format()},format:function(){var t=this,e=t.options.diagram;t.$el.hide();var n=t.$el.find(".diagram-customize-close"),i=t.$el.find(".diagram-y-axis-slider"),a=t.$el.find(".diagram-y-axis-limit-input");n.click(function(e){e.preventDefault(),t.toggleView()}),a.val(e.getMaxY()),i.slider({value:e.getMaxY(),min:2,max:e.getInitialMaxY(),change:function(t,n){var i=n.value;return i>e.getThreshold()?(i=e.getThreshold(),void $(this).slider("value",i)):(a.val(i),e.updateOptions({maxLengthY:i}),void e.rescaleYAxis())},slide:function(t,e){a.val(e.value)}}),a.keypress(function(t){var n=13;if(t.keyCode==n){var o=a.val(),r=o;isNaN(r)||r>e.getThreshold()?r=e.getThreshold():2>o&&(r=2),a.val(r),i.slider("option","value",Math.floor(r))}})},toggleView:function(){var t=this;t.$el.slideToggle()}}),MutationDetailsTableView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t),this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("mutation_details_table_template"),n=e({loaderImage:t.options.config.loaderImage});t.$el.html(n),t._initMutationTable(),t.format()},_initMutationTable:function(t){var e=this,n=jQuery.extend(!0,{},e.model.tableOpts);n.el=n.el||e.$el.find(".mutation_details_table");var i=new MutationCollection(e.model.mutations),a=new MutationDetailsUtil(i),o=new MutationDetailsTable(n,e.model.geneSymbol,a,e.model.dataProxies,e.model.dataManager);return e.mutationTable=o,_.isFunction(t)&&t(e,o),e._generateRowData(o,o.getColumnOptions(),i,function(t){o.renderTable(t)}),o},_generateRowData:function(t,e,n,i){var a=[];n.each(function(n){for(var i={table:t,mutation:n},o=[i],r=0;r<_.size(e)-1;r++)o.push(null);a.push(o)}),i(a)},format:function(){},hideView:function(){var t=this;t.$el.hide()},showView:function(){var t=this;t.$el.show()},highlight:function(t){for(var e=this,n=e.$el.find(".mutation_details_table"),i=0;i0){var o=e.countMutations(n,i);a=e.generateSummary(o)}return a},_germlineMutationSummary:function(t){var e=this,n=e.model.mutationProxy.getMutationUtil(),i=e.model.geneSymbol,a=e.model.sampleArray,o=0,r="";if(a.length>0){for(var l=n.countMutations(i,a),s=0;s0)&&(i.pdbInfo=": "+e),(null!=n||n.length>0)&&(i.molInfo=": "+n);var a=BackboneTemplateCache.getTemplateFn("mutation_details_pdb_chain_tip_template");return a(i)}}),PdbPanelView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t),this.collapseTimer=null,this.expandTimer=null},render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("pdb_panel_view_template"),n=e({});t.$el.html(n),t.pdbPanel=t._initPdbPanel(),t.format()},format:function(){var t=this;t.$el.hide();var e=t.$el.find(".expand-collapse-pdb-panel"),n=t.$el.find(".init-pdb-table"),i=t.$el.find(".pdb-table-controls"),a=t.$el.find(".triangle-down"),o=t.$el.find(".triangle");t.pdbPanel.hasMoreChains()&&(e.button({icons:{primary:"ui-icon-triangle-2-n-s"},text:!1}),e.css({width:"300px",height:"12px"}),e.click(function(){t.pdbPanel.toggleHeight()})),e.hide(),i.hide(),a.hide(),o.click(function(t){n.click()}),t.$el.find(".mutation-pdb-main-container").mouseenter(function(e){t.autoExpand()}),t.$el.find(".mutation-pdb-main-container").mouseleave(function(e){t.autoCollapse()})},hideView:function(){var t=this;t.$el.slideUp()},showView:function(){var t=this;t.$el.slideDown()},initPdbTableView:function(t,e){var n=this,i={el:n.$el.find(".mutation-pdb-table-view"),config:{loaderImage:n.options.config.loaderImage},model:{geneSymbol:n.model.geneSymbol,pdbColl:t,pdbProxy:n.model.pdbProxy}},a=new PdbTableView(i);return n.pdbTableView=a,a.render(e),a},addInitCallback:function(t){var e=this,n=e.$el.find(".init-pdb-table");n.click(function(e){e.preventDefault(),t(e)})},toggleTableControls:function(){var t=this;t.$el.find(".triangle").toggle()},selectDefaultChain:function(){var t=this,e=t.pdbPanel,n=e.getDefaultChainGroup();t.clearTimers(),e.restoreChainPositions(function(){e.highlight(n)})},selectChain:function(t,e){var n=this,i=n.pdbPanel;n.clearTimers(),i.restoreChainPositions(function(){i.expandToChainLevel(t,e);var n=i.getChainGroup(t,e);n&&i.highlight(n)})},getSelectedChain:function(){var t=this,e=t.pdbPanel;return e.getHighlighted()},autoCollapse:function(t){null==t&&(t=2e3);var e=this,n=e.$el.find(".expand-collapse-pdb-panel"),i=e.$el.find(".pdb-table-controls"),a=e.$el.find(".pdb-table-wrapper");e.clearTimers(),e.collapseTimer=setTimeout(function(){e.pdbPanel.minimizeToHighlighted(),n.slideUp(),i.slideUp(),a.slideUp()},t)},autoExpand:function(t){null==t&&(t=400);var e=this,n=e.$el.find(".expand-collapse-pdb-panel"),i=e.$el.find(".pdb-table-controls"),a=e.$el.find(".pdb-table-wrapper");e.clearTimers(),e.expandTimer=setTimeout(function(){e.pdbPanel.restoreToFull(),e.pdbPanel.hasMoreChains()&&n.slideDown(),i.slideDown(),a.slideDown(),null!=e.pdbTableView&&e.pdbTableView.refreshView()},t)},toggleScrollBar:function(t){var e=this,n=e.$el.find(".mutation-pdb-panel-container");t>0?(n.css("max-height",t),n.css("overflow",""),n.css("overflow-y","scroll")):(n.css("max-height",""),n.css("overflow-y",""),n.css("overflow","hidden"))},scrollToSelected:function(){var t=this,e=t.$el.find(".mutation-pdb-panel-container");e.scrollTo($(".pdb-selection-rectangle-group"),{axis:"y",duration:800,offset:-150})},clearTimers:function(){var t=this;null!=t.collapseTimer&&clearTimeout(t.collapseTimer),null!=t.expandTimer&&clearTimeout(t.expandTimer)},_initPdbPanel:function(){var t=this,e=t.model.pdbColl,n=t.model.pdbProxy,i=t.options.diagram,a={el:t.$el.find(".mutation-pdb-panel-container"),maxHeight:200},o=null;null!=i&&(o=i.xScale,a.marginLeft=i.options.marginLeft,a.marginRight=i.options.marginRight);var r=new MutationPdbPanel(a,e,n,o);return r.init(),r}}),PdbTableView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t)},render:function(t){var e=this,n=BackboneTemplateCache.getTemplateFn("pdb_table_view_template"),i=n({loaderImage:e.options.config.loaderImage});e.$el.html(i),e._initPdbTable(t),e.format()},format:function(){var t=this;t.$el.hide()},hideView:function(){var t=this;t.$el.slideUp()},showView:function(){var t=this;t.$el.slideDown()},toggleView:function(){var t=this;t.$el.slideToggle()},refreshView:function(){var t=this;t.pdbTable.getDataTable().fnAdjustColumnSizing()},resetFilters:function(){var t=this;t.pdbTable.cleanFilters()},selectChain:function(t,e){var n=this;null!=n.pdbTable&&n.pdbTable.selectRow(t,e)},scrollToSelected:function(){var t=this,e=t.pdbTable.getSelectedRow(),n=t.$el.find(".dataTables_scrollBody");n.scrollTo($(e),{axis:"y",duration:800})},_initPdbTable:function(t){var e=this,n=e.model.pdbColl,i=e.model.pdbProxy,a=jQuery.extend(!0,{},e.model.tableOpts);a.el=a.el||e.$el.find(".pdb-chain-table");var o=new MutationPdbTable(a);return e.pdbTable=o,_.isFunction(t)&&t(e,o),e._generateRowData(o.getColumnOptions(),n,i,function(t){o.renderTable(t),e.$el.find(".pdb-chain-table-loader").hide()}),o},_generateRowData:function(t,e,n,i){var a=[],o=[];e.each(function(t){o.push(t.pdbId)}),n.getPdbInfo(o.join(" "),function(n){e.each(function(e){e.chains.each(function(i){for(var o={pdbId:e.pdbId,chain:i,organism:PdbDataUtil.getOrganism(n[e.pdbId],i.chainId),summary:PdbDataUtil.generatePdbInfoSummary(n[e.pdbId],i.chainId)},r=[o],l=0;l<_.size(t)-1;l++)r.push(null);a.push(r)})}),i(a)})}}),PredictedImpactTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){var t=function(t){var e=!0;return(null==t||"NA"==t||0==t.length)&&(e=!1),e},e=this.model.xvia;t(e)||this.$el.find(".mutation-assessor-main-link").hide();var n=this.model.pdbLink;t(n)||this.$el.find(".mutation-assessor-3d-link").hide();var i=this.model.msaLink;t(i)||this.$el.find(".mutation-assessor-msa-link").hide()},compileTemplate:function(){var t={linkOut:this.model.xvia,msaLink:this.model.msaLink,pdbLink:this.model.pdbLink,impact:this.model.impact},e=BackboneTemplateCache.getTemplateFn("mutation_details_fis_tip_template");return e(t)}}),RegionTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){},compileTemplate:function(){var t={identifier:this.model.identifier,type:this.model.type.toLowerCase(),description:this.model.description,start:this.model.start,end:this.model.end,pfamAccession:this.model.pfamAccession,mutationAlignerInfo:this.model.mutationAlignerInfo},e=BackboneTemplateCache.getTemplateFn("mutation_details_region_tip_template");return e(t)}});ClinicalDataProxy.prototype=new AbstractDataProxy,ClinicalDataProxy.prototype.constructor=ClinicalDataProxy,MutationAlignerDataProxy.prototype=new AbstractDataProxy,MutationAlignerDataProxy.prototype.constructor=MutationAlignerDataProxy,MutationDataProxy.prototype=new AbstractDataProxy,MutationDataProxy.prototype.constructor=MutationDataProxy,PancanMutationDataProxy.prototype=new AbstractDataProxy,PancanMutationDataProxy.prototype.constructor=PancanMutationDataProxy,PdbDataProxy.prototype=new AbstractDataProxy,PdbDataProxy.prototype.constructor=PdbDataProxy,PfamDataProxy.prototype=new AbstractDataProxy,PfamDataProxy.prototype.constructor=PfamDataProxy,PortalDataProxy.prototype=new AbstractDataProxy,PortalDataProxy.prototype.constructor=PortalDataProxy,VariantAnnotationDataProxy.prototype=new AbstractDataProxy,VariantAnnotationDataProxy.prototype.constructor=VariantAnnotationDataProxy,MutationDetailsTable.prototype=new AdvancedDataTable,MutationDetailsTable.prototype.constructor=MutationDetailsTable,MutationDiagram.prototype.defaultOpts={el:"#mutation_diagram_d3",elWidth:740,elHeight:180,marginLeft:45,marginRight:30,marginTop:30,marginBottom:60,labelTop:"",labelTopFont:"sans-serif",labelTopFontColor:"#2E3436",labelTopFontSize:"12px",labelTopFontWeight:"bold",labelTopMargin:2,labelX:!1,labelXFont:"sans-serif",labelXFontColor:"#2E3436",labelXFontSize:"12px",labelXFontWeight:"normal",labelY:"# Mutations",labelYFont:"sans-serif",labelYFontColor:"#2E3436",labelYFontSize:"12px",labelYFontWeight:"normal",minLengthX:0,minLengthY:5,maxLengthX:1/0,maxLengthY:1/0,seqFillColor:"#BABDB6",seqHeight:14,seqPadding:5,regionHeight:24,regionFont:"sans-serif",regionFontColor:"#FFFFFF",regionFontSize:"12px",regionTextAnchor:"middle",showRegionText:!0,showStats:!1,multiSelectKeycode:16,lollipopLabelCount:1,lollipopLabelThreshold:2,lollipopFont:"sans-serif",lollipopFontColor:"#2E3436",lollipopFontSize:"10px",lollipopTextAnchor:"auto",lollipopTextPadding:8,lollipopTextAngle:0,lollipopFillColor:{missense:"#008000",truncating:"#000000",inframe:"#8B4513",fusion:"#8B00C9",other:"#8B00C9","default":"#BB0000"},lollipopBorderColor:"#BABDB6",lollipopBorderWidth:.5,lollipopSize:30,lollipopHighlightSize:100,lollipopStrokeWidth:1,lollipopStrokeColor:"#BABDB6",lollipopShapeRegular:"circle",lollipopShapeSpecial:"circle",xAxisPadding:10,xAxisTickIntervals:[100,200,400,500,1e3,2e3,5e3,1e4,2e4,5e4],xAxisTicks:8,xAxisTickSize:6,xAxisStroke:"#AAAAAA",xAxisFont:"sans-serif",xAxisFontSize:"10px",xAxisFontColor:"#2E3436",yAxisPadding:5,yAxisLabelPadding:15,yAxisTicks:10,yAxisTickIntervals:[1,2,5,10,20,50,100,200,500],yAxisTickSize:6,yAxisStroke:"#AAAAAA",yAxisFont:"sans-serif",yAxisFontSize:"10px",yAxisFontColor:"#2E3436",yAxisAutoAdjust:!0,animationDuration:1e3,fadeDuration:1500,lollipopTipFn:function(t,e,n){var i=new LollipopTipView({model:e});i.setShowStats(n);var a=i.compileTemplate(),o={content:{text:a},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow cc-ui-tooltip"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,o)},regionTipFn:function(t,e,n){
-var i={identifier:e.metadata.identifier,type:e.type,description:e.metadata.description,start:e.metadata.start,end:e.metadata.end,pfamAccession:e.metadata.accession,mutationAlignerInfo:""};n.getMutationAlignerData({pfamAccession:e.metadata.accession},function(e){if(null!=e&&null!=e.linkToMutationAligner&&e.linkToMutationAligner.length>0){var n=BackboneTemplateCache.getTemplateFn("mutation_aligner_info_template");i.mutationAlignerInfo=n({linkToMutationAligner:e.linkToMutationAligner})}var a=new RegionTipView({model:i}),o=a.compileTemplate(),r={content:{text:o},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-lightyellow"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,r)})}},MutationDiagram.prototype.updateOptions=function(t){var e=this;e.options=jQuery.extend(!0,{},e.options,t),e.updateGlobals()},MutationDiagram.prototype.rescaleYAxis=function(t){var e=this;e.updateGlobals(),e.svg.select(".mut-dia-y-axis").remove(),e.drawYAxis(e.svg,e.yScale,e.yMax,e.options,e.bounds),t||e.updatePlot()},MutationDiagram.prototype.updateGlobals=function(t){var e=this;t=t||e.options;var n=e.data.pileups;t.yAxisAutoAdjust&&(n=e.pileups);var i=e.maxCount=e.calcMaxCount(n),a=e.xMax=e.calcXMax(t,e.data),o=e.yMax=e.calcYMax(t,i);e.bounds=this.calcBounds(t),e.xScale=this.xScaleFn(e.bounds,a),e.yScale=this.yScaleFn(e.bounds,o)},MutationDiagram.prototype.updateSequenceData=function(t){var e=this;e.data.sequence=t},MutationDiagram.prototype.initDiagram=function(){var t=this,e=$(t.options.el)[0],n=d3.select(e),i=t.bounds=t.calcBounds(t.options);t.mutationPileupMap=PileupUtil.mapToMutations(t.data.pileups);var a=t.createSvg(n,t.options.elWidth,t.options.elHeight);t.svg=a,t.drawDiagram(a,i,t.options,t.data),t.addDefaultListeners()},MutationDiagram.prototype.calcBounds=function(t){var e={};return e.width=t.elWidth-(t.marginLeft+t.marginRight),e.height=t.elHeight-(t.marginBottom+t.marginTop),e.x=t.marginLeft,e.y=t.elHeight-t.marginBottom,e},MutationDiagram.prototype.drawDiagram=function(t,e,n,i){var a=this,o=(parseInt(i.sequence.length),a.maxCount=a.calcMaxCount(i.pileups)),r=a.xMax=a.calcXMax(n,i),l=a.yMax=a.calcYMax(n,o),s=i.sequence.regions,u=i.pileups,c=a.generateSequenceTooltip(i),d=a.xScale=a.xScaleFn(e,r),p=a.yScale=a.yScaleFn(e,l);a.drawXAxis(t,d,r,n,e),0!=n.labelX,a.drawYAxis(t,p,l,n,e),0!=n.labelY&&(a.yAxisLabel=a.drawYAxisLabel(t,n,e)),0!=n.topLabel&&(a.topLabel=a.drawTopLabel(t,n,e));t.append("rect").attr("fill","#FFFFFF").attr("opacity",0).attr("x",e.x).attr("y",e.y-e.height).attr("width",e.width).attr("height",e.height).attr("class","mut-dia-background");a.drawPlot(t,u,n,e,d,p);var m=a.drawSequence(t,n,e);m.attr("title",c);for(var h=0,f=s.length;f>h;h++)a.drawRegion(t,s[h],n,e,d)},MutationDiagram.prototype.xScaleFn=function(t,e){return d3.scale.linear().domain([0,e]).range([t.x,t.x+t.width])},MutationDiagram.prototype.yScaleFn=function(t,e){return d3.scale.linear().domain([0,e]).range([t.y,t.y-t.height])},MutationDiagram.prototype.calcXMax=function(t,e){var n=parseInt(e.sequence.length);return Math.min(t.maxLengthX,Math.max(n,t.minLengthX))},MutationDiagram.prototype.calcYMax=function(t,e){return Math.min(t.maxLengthY,Math.max(e,t.minLengthY))},MutationDiagram.prototype.generateSequenceTooltip=function(t){var e="",n=parseInt(t.sequence.length);return t.sequence.metadata.identifier&&(e+=t.sequence.metadata.identifier,t.sequence.metadata.description&&(e+=", "+t.sequence.metadata.description)),e+=" ("+n+"aa)"},MutationDiagram.prototype.drawPlot=function(t,e,n,i,a,o){var r=this,l=r.gLabel;null===l&&(l=t.append("g").attr("class","mut-dia-lollipop-labels"),r.gLabel=l);var s=r.gLine;null===s&&(s=t.append("g").attr("class","mut-dia-lollipop-lines"),r.gLine=s);var u=r.gData;null===u&&(u=t.append("g").attr("class","mut-dia-lollipop-points"),r.gData=u);for(var c=0;co)break}return i},MutationDiagram.prototype.getTickValues=function(t,e){for(var n=[],i=0;t>i;)n.push(i),i+=e/2;return n.push(t),n},MutationDiagram.prototype.drawXAxis=function(t,e,n,i,a){var o=this,r=o.calcTickInterval(i.xAxisTickIntervals,n,i.xAxisTicks),l=o.getTickValues(n,r),s=function(t){return t==n?t+" aa":t%r!=0?"":n-t>r/3?t:""},u=i.xAxisTickSize,c=d3.svg.axis().scale(e).orient("bottom").tickValues(l).tickFormat(s).tickSize(u,u/2,0),d=a.y+i.regionHeight+i.xAxisPadding,p=t.append("g").attr("class","mut-dia-x-axis").attr("transform","translate(0,"+d+")").call(c);return o.formatAxis(".mut-dia-x-axis",i.xAxisStroke,i.xAxisFont,i.xAxisFontSize,i.xAxisFontColor),p},MutationDiagram.prototype.drawYAxis=function(t,e,n,i,a){var o=this,r=o.calcTickInterval(i.yAxisTickIntervals,n,i.yAxisTicks),l=o.getTickValues(n,2*r),s=function(t){var e="";return t===n?(e=t,o.maxCount>n&&(e=">"+t)):0===t&&(e=t),e},u=i.yAxisTickSize,c=d3.svg.axis().scale(e).orient("left").tickValues(l).tickFormat(s).tickSize(u,u/2,0),d=a.x-i.yAxisPadding,p=t.append("g").attr("class","mut-dia-y-axis").attr("transform","translate("+d+",0)").call(c);return o.formatAxis(".mut-dia-y-axis",i.yAxisStroke,i.yAxisFont,i.yAxisFontSize,i.yAxisFontColor),p},MutationDiagram.prototype.drawTopLabel=function(t,e,n){var i=e.labelTopMargin,a=e.marginTop/2,o=t.append("text").attr("fill",e.labelTopFontColor).attr("text-anchor","start").attr("x",i).attr("y",a).attr("class","mut-dia-top-label").style("font-family",e.labelTopFont).style("font-size",e.labelTopFontSize).style("font-weight",e.labelTopFontWeight).text(e.labelTop);return o},MutationDiagram.prototype.drawYAxisLabel=function(t,e,n){var i=n.x-e.yAxisPadding-e.yAxisTickSize-e.yAxisLabelPadding,a=n.y-n.height/2,o=t.append("text").attr("fill",e.labelYFontColor).attr("text-anchor","middle").attr("x",i).attr("y",a).attr("class","mut-dia-y-axis-label").attr("transform","rotate(270, "+i+","+a+")").style("font-family",e.labelYFont).style("font-size",e.labelYFontSize).style("font-weight",e.labelYFontWeight).text(e.labelY);return o},MutationDiagram.prototype.formatAxis=function(t,e,n,i,a){var o=d3.selectAll(t+" line");o.style("fill","none").style("stroke",e).style("shape-rendering","crispEdges"),o=d3.selectAll(t+" path"),o.style("fill","none").style("stroke",e).style("shape-rendering","crispEdges"),o=d3.selectAll(t+" text"),o.attr("fill",a).style("font-family",n).style("font-size",i)},MutationDiagram.prototype.drawLollipop=function(t,e,n,i,a,o,r){var l=this,s=i.lollipopShapeRegular,u=n.count,c=n.location,d=o(c),p=r(u);u>i.maxLengthY&&(s=i.lollipopShapeSpecial,p=r(i.maxLengthY));var m=l.getLollipopFillColor(i,n);l.updateColorMap(n,m);var h=t.append("path").attr("d",d3.svg.symbol().size(i.lollipopSize).type(s)).attr("transform","translate("+d+","+p+")").attr("fill",m).attr("stroke",i.lollipopBorderColor).attr("stroke-width",i.lollipopBorderWidth).attr("id",n.pileupId).attr("class","mut-dia-data-point").attr("opacity",0);l.fadeIn(h),h.datum(n);var f=i.lollipopTipFn;f(h,n,i.showStats);var g=e.append("line").attr("x1",d).attr("y1",p).attr("x2",d).attr("y2",l.calcSequenceBounds(a,i).y).attr("stroke",i.lollipopStrokeColor).attr("stroke-width",i.lollipopStrokeWidth).attr("class","mut-dia-data-line").attr("opacity",0);return l.fadeIn(g),{dataPoint:h,line:g}},MutationDiagram.prototype.updateColorMap=function(t,e){for(var n=this,i=0;it.options.maxLengthY&&(n=t.options.lollipopShapeSpecial),n};return e},MutationDiagram.prototype.getLollipopFillColor=function(t,e){var n,i=t.lollipopFillColor;if(_.isFunction(i))n=i(e);else if(_.isString(i))n=i;else{var a=PileupUtil.groupMutationsByMainType(e);n=0===a.length?i["default"]:i[a[0].type]}return n},MutationDiagram.prototype.drawLollipopLabels=function(t,e,n,i,a){var o=this,r=function(t,e){var i=e;if("auto"==i.toLowerCase()){var a=t.attr("x")-t.node().getComputedTextLength()/2;i=a1){for(var u=e[0].count,c=0;cl&&c>s&&(l=0)}for(var d=0;l>d&&d1&&e[d].counti&&(t=t.substring(0,3)+"..",r.text(t),r.node().getComputedTextLength()>i&&(r.remove(),r=null)),r},MutationDiagram.prototype.drawSequence=function(t,e,n){var i=this.calcSequenceBounds(n,e);return t.append("rect").attr("fill",e.seqFillColor).attr("x",i.x).attr("y",i.y).attr("width",i.width).attr("height",i.height).attr("class","mut-dia-sequence")},MutationDiagram.prototype.calcMaxCount=function(t){var e=-1;return t.length>0&&(e=t[0].count),e},MutationDiagram.prototype.calcSequenceBounds=function(t,e){var n=t.x,i=t.y+Math.abs(e.regionHeight-e.seqHeight)/2+e.seqPadding,a=t.width,o=e.seqHeight;return{x:n,y:i,width:a,height:o}},MutationDiagram.prototype.updatePlot=function(t){var e=this,n=e.pileups;return t&&(e.pileups=n=t,e.mutationPileupMap=PileupUtil.mapToMutations(n)),e.cleanPlotArea(),e.mutationColorMap={},e.options.yAxisAutoAdjust&&e.rescaleYAxis(!0),e.drawPlot(e.svg,n,e.options,e.bounds,e.xScale,e.yScale),_.each(_.keys(e.listeners),function(t){var n=e.svg.selectAll(t);_.each(_.keys(e.listeners[t]),function(i){n.on(i,e.listeners[t][i])})}),e.highlighted={},e.dispatcher.trigger(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED),e.isFiltered()},MutationDiagram.prototype.cleanPlotArea=function(){var t=this,e=t.gLabel.selectAll("text"),n=t.gLine.selectAll("line"),i=t.gData.selectAll(".mut-dia-data-point");t.fadeOut(e,function(t){$(t).remove()}),t.fadeOut(n,function(t){$(t).remove()}),t.fadeOut(i,function(t){$(t).remove()})},MutationDiagram.prototype.resetPlot=function(){var t=this;t.updatePlot(t.data.pileups),t.dispatcher.trigger(MutationDetailsEvents.DIAGRAM_PLOT_RESET)},MutationDiagram.prototype.updateTopLabel=function(t){var e=this;(void 0==t||null==t)&&(t=""),e.topLabel.text(t)},MutationDiagram.prototype.addListener=function(t,e,n){var i=this;i.svg.selectAll(t).on(e,n),null==i.listeners[t]&&(i.listeners[t]={}),i.listeners[t][e]=n},MutationDiagram.prototype.removeListener=function(t,e){var n=this;n.svg.selectAll(t).on(e,null),n.listeners[t]&&n.listeners[t][e]&&delete n.listeners[t][e]},MutationDiagram.prototype.addDefaultListeners=function(){var t=this;t.addListener(".mut-dia-background","click",function(e,n){var i=!t.isHighlighted()||t.multiSelect;i||(t.clearHighlights(),t.dispatcher.trigger(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED))}),t.addListener(".mut-dia-data-point","click",function(e,n){t.isHighlighted(this)?(t.removeHighlight(this),t.multiSelect||t.clearHighlights(),t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_DESELECTED,e,n)):(t.multiSelect||t.clearHighlights(),t.highlight(this),t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_SELECTED,e,n))}),t.addListener(".mut-dia-data-point","mouseout",function(e,n){t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_MOUSEOUT,e,n)}),t.addListener(".mut-dia-data-point","mouseover",function(e,n){t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_MOUSEOVER,e,n)});var e=function(e,n){t.multiSelect&&d3.event.preventDefault()};t.addListener(".mut-dia-data-point","mousedown",e),t.addListener(".mut-dia-background","mousedown",e),$(window).on("keydown",function(e){e.keyCode==t.options.multiSelectKeycode&&(t.multiSelect=!0)}),$(window).on("keyup",function(e){e.keyCode==t.options.multiSelectKeycode&&(t.multiSelect=!1)})},MutationDiagram.prototype.isHighlighted=function(t){var e=this,n=!1;if(void 0==t)n=!_.isEmpty(e.highlighted);else{var i=d3.select(t),a=i.datum().location;void 0!=e.highlighted[a]&&(n=!0)}return n},MutationDiagram.prototype.clearHighlights=function(){var t=this,e=t.gData.selectAll(".mut-dia-data-point");e.transition().ease("elastic").duration(t.options.animationDuration).attr("d",d3.svg.symbol().size(t.options.lollipopSize).type(t.getLollipopShapeFn())),t.highlighted={}},MutationDiagram.prototype.highlightMutation=function(t){var e=this,n=e.mutationPileupMap[t],i=e.svg.select("#"+n);i.length>0&&e.highlight(i[0][0])},MutationDiagram.prototype.highlight=function(t){var e=this,n=d3.select(t);n.transition().ease("elastic").duration(e.options.animationDuration).attr("d",d3.svg.symbol().size(e.options.lollipopHighlightSize).type(e.getLollipopShapeFn()));var i=n.datum().location;e.highlighted[i]=n},MutationDiagram.prototype.removeHighlight=function(t){var e=this,n=d3.select(t);n.transition().ease("elastic").duration(e.options.animationDuration).attr("d",d3.svg.symbol().size(e.options.lollipopSize).type(e.getLollipopShapeFn()));var i=n.datum().location;delete e.highlighted[i]},MutationDiagram.prototype.fadeIn=function(t,e){var n=this;t.transition().style("opacity",1).duration(n.options.fadeDuration).each("end",function(){_.isFunction(e)&&e(this)})},MutationDiagram.prototype.fadeOut=function(t,e){var n=this;t.transition().style("opacity",0).duration(n.options.fadeDuration).each("end",function(){_.isFunction(e)&&e(this)})},MutationDiagram.prototype.getSelectedElements=function(){var t=this;return _.values(t.highlighted)},MutationDiagram.prototype.isFiltered=function(){var t=this,e=!1;return PileupUtil.countMutations(t.pileups)';var f=function(t){if(cbio.util.getWindowOrigin()==t.origin)if("ready"==t.data.type)l&&(s=cbio.util.getTargetDocument("jsmol_frame"));else if("menu"==t.data.type)u&&("visible"==t.data.content?u.css("overflow","visible"):"hidden"==t.data.content&&u.css("overflow","hidden"));else if("done"==t.data.type){var e=p[t.data.scriptId];if(null!=e){delete p[t.data.scriptId];var n=e.callback;n&&_.isFunction(n)&&n()}_.isEmpty(d)||(e=d.shift(),p[e.data.scriptId]=e,l.postMessage(e.data,c))}};window.addEventListener("message",f,!1)}function e(t){t&&r&&(t.empty(),t.append(r),u=t),l=cbio.util.getTargetWindow("jsmol_frame"),l||console.log("warning: JSmol frame cannot be initialized properly")}function n(t,e){if(l){m=(m+1)%1e6;var n={type:"script",content:t,scriptId:"script_"+m};i(n,e)}}function i(t,e){var n={data:t,callback:e};_.isEmpty(d)?(p[n.data.scriptId]=n,l.postMessage(t,c)):d.push(n)}var a=null,o=null,r=null,l=null,s=null,u=null,c=cbio.util.getWindowOrigin(),d=[],p={},m=0,h={use:"HTML5",j2sPath:"js/lib/jsmol/j2s",disableJ2SLoadMonitor:!0,disableInitialConsole:!0};return{init:t,updateContainer:e,script:n}}function JmolScriptGenerator(){function t(t){return"load="+t+";"}function e(){return"select all;"}function n(){return"select none;"}function i(t){return D[t]}function a(t){return"color ["+P(t)+"];"}function o(t){return"select :"+t+";"}function r(t){return"select :"+t+" and helix;"}function l(t){return"select :"+t+" and sheet;"}function s(t){var e="@{{:"+t+"}.atomNo.min}",n="@{{:"+t+"}.atomNo.max}";return'color atoms property atomNo "roygb" range '+e+" "+n+";"}function u(t){return"color atoms CPK;"}function c(){return"restrict protein;"}function d(t){return t>0?"color translucent;":"color opaque;"}function p(t){var e=function(t){var e="";return null!=t&&t.length>0&&(e+="^"+t),e},n=t.start.pdbPos||t.start.pdbPosition,i=t.end.pdbPos||t.end.pdbPosition,a=n+e(t.start.insertion);return i>n&&(a+="-"+i+e(t.end.insertion)),a}function m(t,e){return"select ("+t.join(", ")+") and :"+e+";"}function h(t,e){return"select (("+t.join(", ")+") and :"+e+" and sidechain) or (("+t.join(", ")+") and :"+e+" and *.CA);"}function f(){return"wireframe 0.15; spacefill 25%;"}function g(){return"wireframe OFF; spacefill OFF;"}function v(t,e){var n=this,i=n.scriptPosition(t);return"center "+i+":"+e+";"}function _(){return"center;"}function b(){return"zoom in;"}function y(){return"zoom out;"}function T(t){return"spin "+t+";"}function C(t,e,n,i){var a=this,o=[];o.push(a.selectPositions(t,i.chainId)),o.push(a.setColor(e));var r="none"!=n.displaySideChain;return o=o.concat(a.generateSideChainScript(t,r,n,i))}function P(t){return t.replace("#","x")}var D={ballAndStick:"wireframe ONLY; wireframe 0.15; spacefill 20%;",spaceFilling:"spacefill ONLY; spacefill 100%;",ribbon:"ribbon ONLY;",cartoon:"cartoon ONLY;",trace:"trace ONLY;"};this.loadPdb=t,this.selectAll=e,this.selectNone=n,this.setScheme=i,this.setColor=a,this.selectChain=o,this.selectAlphaHelix=r,this.selectBetaSheet=l,this.rainbowColor=s,this.cpkColor=u,this.hideBoundMolecules=c,this.setTransparency=d,this.scriptPosition=p,this.selectPositions=m,this.selectSideChains=h,this.enableBallAndStick=f,this.disableBallAndStick=g,this.highlightScript=C,this.center=v,this.defaultZoomIn=b,this.defaultZoomOut=y,this.defaultCenter=_,this.spin=T}function JmolWrapper(t){function e(t,e){s=jQuery.extend(!0,{},l,e),delete Jmol._tracker,o=Jmol.getApplet(t,s),r=$("#"+t+"_appletinfotablediv"),r.hide()}function n(t){null!=r&&(t.append(r),r.show())}function i(t,e){Jmol.script(o,t),_.isFunction(e)&&e()}function a(t){return t?{jarPath:"js/lib/jmol/",jarFile:"JmolAppletSigned.jar",disableJ2SLoadMonitor:!0,disableInitialConsole:!0}:{use:"HTML5",j2sPath:"js/lib/jsmol/j2s",disableJ2SLoadMonitor:!0,disableInitialConsole:!0}}var o=null,r=null,l=a(t),s=null;return{init:e,updateContainer:n,script:i}}function MergedAlignmentSegmentor(t){function e(){return o=r;r++)e.push(r);return t.start.insertion&&(e[0]+="^"+t.start.insertion),e.length>1&&t.end.insertion&&(e[e.length-1]+="^"+t.end.insertion),e}function s(t,e){return P={rescode:t,chain:e},""}function u(t,e){return P={rescode:t,chain:e},""}function c(t,e,n,i){var a=this,o=[""];a.selectPositions(t,i.chainId),a.setColor(e);var r="none"!=n.displaySideChain;return a.generateSideChainScript(t,r,n,i),o}function d(){var t=_.extend({},D,S.ballAndStick);return t.sphere.color=w,t.stick.color=w,C.setStyle(P,t),""}function p(){return""}function m(t){return P={chain:t},i("spectrum"),""}function h(t){return P={chain:t},_.each(D,function(t){delete t.color,t.colors=$3Dmol.elementColors.defaultColors}),C.setStyle(P,D),""}function f(t){return t.replace("#","0x")}function g(t){C=t}function v(t){T=t}function b(){var t={resn:["asp","glu","arg","lys","his","asn","thr","cys","gln","tyr","ser","gly","ala","leu","val","ile","met","trp","phe","pro","ASP","GLU","ARG","LYS","HIS","ASN","THR","CYS","GLN","TYR","SER","GLY","ALA","LEU","VAL","ILE","MET","TRP","PHE","PRO"],invert:!0},e={sphere:{hidden:!0}};C.setStyle(t,e)}function y(t){_.each(D,function(e){e.opacity=(10-t)/10}),C.setStyle(P,D)}var T=null,C=null,P=null,D=null,w=null,S={ballAndStick:{stick:{},sphere:{scale:.25}},spaceFilling:{sphere:{scale:.6}},cartoon:{cartoon:{}},ribbon:{cartoon:{style:"ribbon"}},trace:{cartoon:{style:"trace"}}};this.setViewer=g,this.setPdbUri=v,this.loadPdb=t,this.selectAll=e,this.setScheme=n,this.setColor=i,this.selectChain=a,this.selectAlphaHelix=o,this.selectBetaSheet=r,this.scriptPosition=l,this.selectPositions=s,this.selectSideChains=u,this.highlightScript=c,this.rainbowColor=m,this.cpkColor=h,this.enableBallAndStick=d,this.disableBallAndStick=p,this.hideBoundMolecules=b,this.setTransparency=y}function Mol3DWrapper(){function t(t,e){o=jQuery.extend(!0,{},a,e),$(e.el).append("");var n=$("#"+t);n.hide();var i=$3Dmol.createViewer(n,{defaultcolors:$3Dmol.elementColors.rasmol});i.setBackgroundColor(16777215),r=i}function e(t){null!=r&&r.setContainer(t)}function n(t,e){null!=t&&null!=r&&r.render(),_.isFunction(e)&&e()}function i(){return r}var a={},o=null,r=null;return{init:t,updateContainer:e,getViewer:i,script:n}}function MolScriptGenerator(){this.loadPdb=function(t){return""},this.selectAll=function(){return""},this.selectNone=function(){return""},this.setScheme=function(t){return""},this.setColor=function(t){return""},this.selectChain=function(t){return""},this.selectAlphaHelix=function(t){return""},this.selectBetaSheet=function(t){return""},this.rainbowColor=function(t){return""},this.cpkColor=function(t){return""},this.hideBoundMolecules=function(){return""},this.setTransparency=function(t){return""},this.scriptPosition=function(t){return""},this.selectPositions=function(t,e){return""},this.selectSideChains=function(t,e){return""},this.enableBallAndStick=function(){return""},this.disableBallAndStick=function(){return""},this.center=function(t,e){return""},this.zoom=function(t){return""},this.defaultZoomIn=function(){return""},this.defaultZoomOut=function(){return""},this.defaultCenter=function(){return""},this.spin=function(t){return""},this.highlightScript=function(t,e,n,i){return[]},this.generateVisualStyleScript=function(t,e,n){var i=this,a=[];return a.push(i.selectAll()),a.push(i.setScheme(n.proteinScheme)),a.push(i.setColor(n.defaultColor)),a.push(i.setTransparency(n.defaultTranslucency)),a.push(i.selectChain(e.chainId)),a.push(i.setColor(n.chainColor)),a.push(i.setTransparency(n.chainTranslucency)),a.push(i.selectChain(e.chainId)),"byAtomType"==n.colorProteins?a.push(i.cpkColor(e.chainId)):"bySecondaryStructure"==n.colorProteins?(a.push(i.selectAlphaHelix(e.chainId)),a.push(i.setColor(n.structureColors.alphaHelix)),a.push(i.selectBetaSheet(e.chainId)),a.push(i.setColor(n.structureColors.betaSheet))):"byChain"==n.colorProteins&&(a.push(i.selectChain(e.chainId)),a.push(i.rainbowColor(e.chainId))),_.each(_.keys(t),function(o){a.push(i.selectPositions(t[o],e.chainId)),"byMutationType"==n.colorMutations?a.push(i.setColor(o)):"uniform"==n.colorMutations&&a.push(i.setColor(n.mutationColor)),a=a.concat(i.generateSideChainScript(t[o],"all"==n.displaySideChain,n,e))}),n.restrictProtein&&a.push(i.hideBoundMolecules()),a},this.generateSideChainScript=function(t,e,n,i){var a=this,o=[];return"spaceFilling"!=n.proteinScheme&&(o.push(a.selectSideChains(t,i.chainId)),e?o.push(a.enableBallAndStick()):o.push(a.disableBallAndStick())),o},this.generateHighlightScript=function(t,e,n,i){var a=this,o=[];if(!_.isEmpty(t)){var r=a.highlightScriptPositions(t);o=o.concat(a.highlightScript(r,e,n,i))}return o},this.highlightScriptPositions=function(t){var e=this,n=[];return _.each(t,function(t){n.push(e.scriptPosition(t))}),n}}function MutationInputParser(){function t(t){var n=new MutationCollection,a=t.split("\n");if(a.length>0)for(var o=i(a[0]),r=1;r0&&n.push(e(a[r],o));return l=n,n}function e(t,e){var i=new MutationModel,a=t.split(" "),o={};return _.each(_.keys(d),function(t){var i=n(t,a,e);i&&(o[t]=i)}),o.mutationId=o.mutationId||r(),o.mutationSid=o.mutationSid||o.mutationId,o.variantKey=VariantAnnotationUtil.generateVariantKey(o),i.set(o),i}function n(t,e,n){var i=d[t],a=n[i],o=void 0;return null!=a&&(o=e[a]||void 0),o}function i(t){var e=t.split(" "),n={};return _.each(e,function(t,e){n[t.toLowerCase()]=e}),n}function a(){if(null==l)return[];if(null==u){var t={};l.each(function(e,n){null!=e.get("caseId")&&e.get("caseId").length>0&&(t[e.get("caseId")]=e.get("caseId"))}),u=_.values(t)}return u}function o(){if(null==l)return[];if(null==s){var t={};l.each(function(e,n){null!=e.get("geneSymbol")&&e.get("geneSymbol").length>0&&(t[e.get("geneSymbol").toUpperCase()]=e.get("geneSymbol").toUpperCase())}),s=_.values(t)}return s}function r(){return c++,"stalone_mut_"+c}var l=null,s=null,u=null,c=0,d={proteinPosEnd:"protein_position_end",uniprotId:"uniprot_id",cancerType:"cancer_type",tumorType:"tumor_type",cancerStudyLink:"cancer_study_link",codonChange:"codon_change",proteinPosStart:"protein_position_start",linkToPatientView:"patient_view_link",geneticProfileId:"genetic_profile_id",mutationCount:"mutation_count",mutationType:"mutation_type",referenceAllele:"reference_allele",uniprotAcc:"uniprot_accession",fisValue:"fis_value",functionalImpactScore:"fis",cancerStudy:"cancer_study",normalRefCount:"normal_ref_count",ncbiBuildNo:"ncbi_build",normalFreq:"normal_frequency",cancerStudyShort:"cancer_study_short",msaLink:"msa_link",mutationStatus:"mutation_status",cna:"copy_number",proteinChange:"protein_change",aminoAcidChange:"amino_acid_change",endPos:"end_position",geneSymbol:"hugo_symbol",tumorFreq:"tumor_frequency",startPos:"start_position",keyword:"keyword",cosmic:"cosmic",validationStatus:"validation_status",mutationSid:"mutation_sid",normalAltCount:"normal_alt_count",variantAllele:"variant_allele",mutationId:"mutation_id",caseId:"sample_id",xVarLink:"xvar_link",pdbLink:"pdb_link",tumorAltCount:"tumor_alt_count",tumorRefCount:"tumor_ref_count",sequencingCenter:"center",chr:"chromosome"};return{parseInput:t,getSampleArray:a,getGeneList:o}}function PymolScriptGenerator(){function t(){return"reinitialize;"}function e(t){return"bg_color "+g(t)+";"}function n(t){return"fetch "+t+", async=0;"}function i(t){return v[t]}function a(t){return"color "+g(t)+", sele;"}function o(t){return"select chain "+t+";"}function r(t){return"select (chain "+t+") and (ss h);"}function l(t){return"select (chain "+t+") and (ss s);"}function s(t,e){return"select (resi "+t.join(",")+") and (chain "+e+");"}function u(t,e){return"select ((resi "+t.join(",")+") and (chain "+e+") and (not name c+n+o));"}function c(t){return"set transparency, "+t/10+", sele;\nset cartoon_transparency, "+t/10+", sele;\nset sphere_transparency, "+t/10+", sele;\nset stick_transparency, "+t/10+", sele;"}function d(){return"show spheres, sele; show sticks, sele; alter sele, vdw=0.50;"}function p(){return"hide spheres, sele; hide sticks, sele;"}function m(t){return"spectrum count, rainbow_rev, sele"}function h(t){return"util.cbaw sele;"}function f(){return"hide everything,not resn asp+glu+arg+lys+his+asn+thr+cys+gln+tyr+ser+gly+ala+leu+val+ile+met+trp+phe+pro"}function g(t){return t.replace("#","0x")}var v={ballAndStick:"hide everything; show spheres; show sticks; alter all, vdw=0.50",spaceFilling:"hide everything; show spheres;",ribbon:"hide everything; show ribbon;",cartoon:"hide everything; show cartoon;",trace:"hide everything; show ribbon;"};this.loadPdb=n,this.setScheme=i,this.setColor=a,this.selectChain=o,this.selectAlphaHelix=r,this.selectBetaSheet=l,this.rainbowColor=m,this.cpkColor=h,this.hideBoundMolecules=f,this.setTransparency=c,this.selectPositions=s,this.selectSideChains=u,this.enableBallAndStick=d,this.disableBallAndStick=p,this.reinitialize=t,this.bgColor=e}function RequestQueue(t){function e(t){c.on(l.newRequestEvent,function(){u||n(t)}),c.on(l.completeEvent,function(){n(t)})}function n(t){var e=_.first(s);s=_.rest(s),e?(u=e,_.isFunction(t)&&t(e)):u=!1}function i(){u=!1,c.trigger(l.completeEvent)}function a(t){s.push(t),c.trigger(l.newRequestEvent)}var o=this,r={completeEvent:"requestQueueProcessComplete",newRequestEvent:"requestQueueNewRequest"},l=jQuery.extend(!0,{},r,t),s=[],u=!1,c={};_.extend(c,Backbone.Events),o.add=a,o.complete=i,o.init=e}function AbstractDataProxy(t){var e=this;e._defaultOpts={initMode:"lazy",servletName:"",data:{}},e._queryQueue=new RequestQueue,e._options=jQuery.extend(!0,{},e._defaultOpts,t),e.init=function(){e._queryQueue.init(function(t){$.ajax(t)}),e.isFullInit()?e.fullInit(e._options):e.lazyInit(e._options)},e.lazyInit=function(t){},e.fullInit=function(t){},e.isFullInit=function(){return!("lazy"===e._options.initMode.toLowerCase())},e.requestData=function(t){var n=t.complete,i={complete:function(t,i){e._queryQueue.complete(),_.isFunction(n)&&n(t,i)}},a=jQuery.extend(!0,{},t,i);e._queryQueue.add(a)}}function ClinicalDataProxy(t){function e(t){r=t.data}function n(t,e){function n(){if(!a||0===_.size(r))return void e(null);var t={study_id:a,attribute_ids:["12_245_PARTC_CONSENTED"],patient_ids:r},n=[];for(var l in t)t.hasOwnProperty(l)&&n.push(l+"="+[].concat(t[l]).join(","));var s=n.join("&")||"?",u={type:"POST",url:o.servletName+"/"+o.subService.patients,data:s,dataType:"json",success:function(t){e(t)},error:function(t){e(null)}};i.requestData(u)}var a,r=[],l=null;try{l=window.QuerySession}catch(s){}l?(a=l.cancer_study_ids[0],l.getPatientSampleIdMap().then(function(e){for(var i=0;i0&&a?(o=o.join(","),a.getAnnotationData(o,function(t){VariantAnnotationUtil.addAnnotationData(i,t),_.isFunction(n)&&n(e)})):_.isFunction(n)&&n(e)},pdbMatch:function(t,e,n){var a=e.mutations||e.mutationTable.getMutations(),o=e.gene||e.mutationTable.getGene(),r=t.pdbProxy,l=i[o],s=l.model.uniprotId;a&&r&&s?r.getPdbRowData(s,function(t){PdbDataUtil.addPdbMatchData(a,t),_.isFunction(n)&&n(e)}):_.isFunction(n)&&n(e)},cBioPortal:function(t,e,n){var i=t.pancanProxy,a=e.mutationUtil||e.mutationTable.getMutationUtil(),o=e.mutations||e.mutationTable.getMutations();i.getPancanData({cmd:"byProteinPos"},a,function(t){i.getPancanData({cmd:"byHugos"},a,function(i){var a=PancanMutationDataUtil.getMutationFrequencies({protein_pos_start:t,hugo:i});_.each(o,function(t,e){var n=t.get("proteinPosStart");if(n>0){var i=PancanMutationDataUtil.countByKey(a,n)||0;t.set({cBioPortal:i})}else t.set({cBioPortal:0})}),_.isFunction(n)&&n(e,a)})})}},dataProxies:{}},o=jQuery.extend(!0,{},a,t),r={};this.getData=e,this.addView=n}function MutationDataProxy(t){function e(t){var e=t.data,n=e;_.isArray(e)&&(n=new MutationCollection(e)),d.processMutationData(n)}function n(){return m}function i(){return p}function a(){return c.geneList}function o(){return d}function r(t,e){var n=t.trim().split(/\s+/),i=[],a=[],o=d.getMutationGeneMap();if(_.each(n,function(t,e){t=t.toUpperCase();var n=o[t];void 0==n||0==n.length?i.push(t):a=a.concat(n)}),s.isFullInit())e(a);else{var r=function(t){var n=new MutationCollection(t);d.processMutationData(n),a=a.concat(n.models),e(a)},l=c.paramsPromise||(new $.Deferred).resolve(c.params);l.then(function(t){if(i.length>0){t.geneList=i.join(" ");var n={type:"POST",url:c.servletName,data:t,success:r,error:function(){console.log("[MutationDataProxy.getMutationData] error retrieving mutation data for genetic profiles: "+t.geneticProfiles),r([])},dataType:"json"};s.requestData(n)}else e(a)})}}function l(){return!0}var s=this,u={servletName:"getMutationData.json",geneList:"",params:{},paramsPromise:null},c=jQuery.extend(!0,{},u,t);AbstractDataProxy.call(this,c),c=s._options;var d=new MutationDetailsUtil,p=c.geneList.trim().split(/\s+/),m=c.geneList.trim().split(/\s+/).sort();s.fullInit=e,s.getMutationData=r,s.getGeneList=n,s.getRawGeneList=a,s.getUnsortedGeneList=i,s.getMutationUtil=o,s.hasData=l}function PancanMutationDataProxy(t){function e(t){var e=t.data;c=e.byKeyword,d=e.byProteinChange,m=e.byGeneSymbol,p=e.byProteinPosition}function n(t,e,n){var a=t.cmd,o=t.q;if(null==a)n(null);else if("byKeywords"==a){var r=null==o?e.getAllKeywords():o.split(",");i(a,r,c,["keyword"],n)}else if("byHugos"==a){var l=null==o?e.getAllGenes():o.split(",");i(a,l,m,["hugo"],n)}else if("byProteinChanges"==a){var s=null==o?e.getAllProteinChanges():o.split(",");i(a,s,d,["protein_change"],n)}else if("byProteinPos"==a){var u=null==o?e.getAllProteinPosStarts():o.split(",");i(a,u,p,["hugo","protein_pos_start"],n)}else n(null)}function i(t,e,n,i,s){var c=o(e,n),d=r(c);if(d.length>0&&!l.isFullInit()){var p={type:"POST",url:u.servletName,data:{cmd:t,q:d.join(",")},success:function(t){a(t,c,n,i,s)},dataType:"json"};l.requestData(p)}else a([],c,n,i,s)}function a(t,e,n,i,a){_.each(t,function(t,a){var o=[];_.each(i,function(e,n){o.push(t[e])});var r=o.join("_");null==n[r]&&(n[r]=[]),null==e[r]&&(e[r]=[]),n[r].push(t),e[r].push(t)});var o=[];_.each(e,function(t){o=o.concat(t)}),a(o)}function o(t,e){var n={};return _.each(t,function(t){n[t]=e[t]}),n}function r(t){var e=[];return _.each(_.keys(t),function(n){null==t[n]&&e.push(n)}),e}var l=this,s={servletName:"pancancerMutations.json"},u=jQuery.extend(!0,{},s,t);AbstractDataProxy.call(this,u),u=l._options;var c={},d={},p={},m={};l.fullInit=e,l.getPancanData=n}function PdbDataProxy(t){function e(t){var e=t.data;_.each(_.keys(e.pdbData),function(t){var n=PdbDataUtil.processPdbData(e.pdbData[t]);m[t]=n,h[t]=PdbDataUtil.allocateChainRows(n)}),f=e.infoData,g=e.summaryData,v=e.positionData}function n(t,e,n){var a=e.alignments,o=i(t,e);if(u.isFullInit()||null!=v[o])return void n(v[o]||{});var r=p.getProteinPositions(t),l={};_.each(r,function(t,n){t.start>-1&&t.start>=e.mergedAlignment.uniprotFrom&&t.start<=e.mergedAlignment.uniprotTo&&(l[t.start]=t.start),t.end>t.start&&t.end>=e.mergedAlignment.uniprotFrom&&t.end<=e.mergedAlignment.uniprotTo&&(l[t.end]=t.end)});var s=_.values(l),c=[];a.each(function(t,e){c.push(t.alignmentId)});var m=function(e){var i={},a=p.getMutationGeneMap()[t],r=e.positionMap||e;if(null!=r&&_.size(r)>0)for(var l=0;l0&&(s=s[0]);var u=s,c=a[l].get("mutationType");null!=c&&"in_frame_del"===c.toLowerCase()&&(u=r[a[l].get("proteinPosEnd")]||u,_.isArray(u)&&_.size(u)>0&&(u=u[0])),null!=s&&null!=u&&(i[a[l].get("mutationId")]={start:s,end:u})}o&&(v[o]=i),n(i)};if(s.length>0){var h=d.servletName;d.subService&&d.subService.map&&(h=h+"/"+d.subService.map);var f={type:"POST",url:h,data:{positions:s.join(d.listJoiner),alignments:c.join(d.listJoiner)},success:m,dataType:"json"};u.requestData(f)}else n({})}function i(t,e){var n=null;return e.alignments.length>0&&(n=t+"_"+e.alignments.at(0).pdbId+"_"+e.chainId),n}function a(t,e){if(u.isFullInit())return void e(m[t]);if(void 0==m[t]){var n=function(n){var i=PdbDataUtil.processPdbData(n);m[t]=i,e(i)},i=d.servletName;d.subService&&d.subService.alignmentByUniprot&&(i=i+"/"+d.subService.alignmentByUniprot);var a={type:"POST",url:i,data:{uniprotId:t,uniprotIds:t},success:n,dataType:"json"};u.requestData(a)}else e(m[t])}function o(t,e){u.isFullInit()||void 0!=h[t]?e(h[t]):a(t,function(n){var i=PdbDataUtil.allocateChainRows(n);h[t]=i,e(i)})}function r(t,e){if(u.isFullInit()||void 0!=g[t])e(g[t]);else{var n=function(n){var i=n;_.isArray(i)&&_.size(i)>0&&(i=i[0]),g[t]=i,e(i)},i=d.servletName;d.subService&&d.subService.summary&&(i=i+"/"+d.subService.summary);var a={type:"POST",url:i,data:{uniprotId:t,uniprotIds:t,type:"summary"},success:n,dataType:"json"};u.requestData(a)}}function l(t,e){var n=function(t){var n=t&&t.alignmentCount>0;e(n)};r(t,n)}function s(t,e){var n=t.trim().split(/\s+/),i=[],a={};if(_.each(n,function(t,e){var n=f[t];void 0==n||0==n.length?i.push(t):a[t]=n}),u.isFullInit())return void e(a);var o={};if(i.length>0){var r=function(t){var i=t;_.isArray(t)&&(i=_.indexBy(t,"pdbId")),_.each(n,function(t,e){null!=i[t]&&(f[t]=i[t],a[t]=i[t])}),e(a)};o.pdbIds=i.join(d.listJoiner);var l=d.servletName;d.subService&&d.subService.header&&(l=l+"/"+d.subService.header);var s={type:"POST",url:l,data:o,success:r,dataType:"json"};u.requestData(s)}else e(a)}var u=this,c={servletName:"pdb_annotation",subService:{alignmentByPdb:"alignment/byPdb",alignmentByUniprot:"alignment/byUniprot",header:"header",map:"map",summary:"summary"},listJoiner:",",mutationUtil:{}},d=jQuery.extend(!0,{},c,t);AbstractDataProxy.call(this,d),d=u._options;var p=d.mutationUtil,m={},h={},f={},g={},v={};u.fullInit=e,u.hasPdbData=l,u.getPdbData=a,u.getPdbRowData=o,u.getPdbInfo=s,u.getPositionMap=n}function PfamDataProxy(t){function e(t){r=t.data}function n(t,e){var n=t.geneSymbol;if(null==n)return void e(null);if(void 0==r[n]){if(i.isFullInit())return void e(null);var a=function(t){r[n]=t,e(t)},l={type:"POST",url:o.servletName,data:t,success:a,dataType:"json"};i.requestData(l)}else e(r[n])}var i=this,a={servletName:"getPfamSequence.json"},o=jQuery.extend(!0,{},a,t);AbstractDataProxy.call(this,o),o=i._options;var r={};i.fullInit=e,i.getPfamData=n}function PortalDataProxy(t){function e(t){r=t.data}function n(t,e){var n={},a={};_.each(_.keys(t),function(e,i){null==r[e]?a[e]=t[e]:n[e]=r[e]});var l=function(t){_.each(_.keys(t),function(e,n){r[e]=t[e]}),_.isFunction(e)&&e(jQuery.extend(!0,{},n,t))};if(_.isEmpty(a))l(n);else{var s={type:"POST",url:o.servletName,data:a,success:l,dataType:"json"};i.requestData(s)}}var i=this,a={servletName:"portalMetadata.json"},o=jQuery.extend(!0,{},a,t);AbstractDataProxy.call(this,o),o=i._options;var r={};i.fullInit=e,i.getPortalData=n}function VariantAnnotationDataProxy(t){function e(t){o=t.data}function n(t,e){var n=t.trim().split(","),r=[],s=[];if(_.each(n,function(t,e){var n=o[t];void 0==n||_.isEmpty(n)?r.push(t):s=s.concat(n)}),a.isFullInit())e(s);else{var u=function(t){_.each(t,function(t,e){i(t),t.id?o[t.id]=t:t.annotationJSON.id&&(o[t.annotationJSON.id]=t)}),s=s.concat(t),e(s)};if(r.length>0){var c=r.join(","),d={type:"POST",url:l.servletName,data:{variants:c},success:u,error:function(){console.log("[VariantDataProxy.getAnnotationData] error retrieving annotation data for variants: "+c),u([])},dataType:"json"};a.requestData(d)}else e(s)}}function i(t){if(_.isString(t.annotationJSON)){var e=JSON.parse(t.annotationJSON);_.isArray(e)&&e.length>0&&(e=e[0]),t.annotationJSON=e}}var a=this,o={},r={servletName:"variant_annotation/hgvs"},l=jQuery.extend(!0,{},r,t);AbstractDataProxy.call(this,l),l=a._options,a.fullInit=e,a.getAnnotationData=n}function AdvancedDataTable(t){var e=this,n=null;e._defaultOpts={el:"",columns:{},columnOrder:[],columnVisibility:{},columnSearch:{},columnRender:{},columnSort:{},columnFilter:{},columnData:{},columnTooltips:{},eventListeners:{},customSort:{},filteringDelay:0,dataTableOpts:{}},e._options=jQuery.extend(!0,{},e._defaultOpts,t),e._dispatcher={},_.extend(e._dispatcher,Backbone.Events),e._dataTable=null,e._visibilityValue=function(t){return"hidden"},e._searchValue=function(t){return!1},e.renderTable=function(t){var i=e._options.columnOrder,a=n=DataTableUtil.buildColumnIndexMap(i),o=DataTableUtil.buildColumnNameMap(e._options.columns),r=DataTableUtil.buildColumnVisMap(i,e._visibilityValue);e._visiblityMap=r;var l=DataTableUtil.buildColumnSearchMap(i,e._searchValue),s=DataTableUtil.getHiddenColumns(i,a,r),u=DataTableUtil.getExcludedColumns(i,a,r),c=DataTableUtil.getNonSearchableColumns(i,a,l);e._addSortFunctions(),e._dataTable=e._initDataTable($(e._options.el),t,e._options.columns,o,a,s,u,c),e._addEventListeners(a),e._options.filteringDelay>0&&e._dataTable.fnSetFilteringDelay(e._options.filteringDelay)},e._initDataTableOpts=function(t,e,n,i,a,o,r,l){return null},e._initDataTable=function(t,n,i,a,o,r,l,s){var u=e._initDataTableOpts(t,n,i,a,o,r,l,s),c=DataTableUtil.getColumnData(o,e._options.columnRender,e._options.columnSort,e._options.columnFilter,e._options.columnData);return u.aoColumnDefs=u.aoColumnDefs.concat(c),u=jQuery.extend(!0,{},e._options.dataTableOpts,u),t.dataTable(u)},e._addSortFunctions=function(){_.each(_.pairs(e._options.customSort),function(t){var e=t[0],n=t[1];jQuery.fn.dataTableExt.oSort[e]=n})},e._addEventListeners=function(t){null!=e.getDataTable()&&_.each(e._options.eventListeners,function(n){n(e.getDataTable(),e._dispatcher,t)})},e._addColumnTooltips=function(t){t=t||{};var n=$(e._options.el);_.each(_.keys(e._options.columnTooltips),function(i){if("excluded"!=e._visiblityMap[i]){var a=e._options.columnTooltips[i];_.isFunction(a)&&a(n,t)}})},e.getColumnOptions=function(){return e._options.columns},e.getDataTable=function(){return e._dataTable},e.setDataTable=function(t){e._dataTable=t},e.getIndexMap=function(){return n}}function Mutation3dVis(t,e){function n(){V=new Mol3DWrapper,V.init(t,j.appOptions),G.setViewer(V.getViewer()),G.setPdbUri(j.pdbUri)}function i(t){k=$(t);var e=k.find(".mutation-3d-vis-container");e.css("width",j.appOptions.width),e.css("height",j.appOptions.height+j.containerPadding),V.updateContainer(e)}function a(){q="ON"==q?"OFF":"ON";var t=G.spin(q);V.script(t)}function o(){var t=G.generateVisualStyleScript(B,R,j);t=t.concat(w(O)),t=t.join(" "),V.script(t)}function r(){if(null!=k){k.show();var t=parseInt(k.css("top"));0>t&&(null!=z&&z>0?k.css("top",z):k.css("top",0))}}function l(){if(null!=k){var t=parseInt(k.css("top"));t>0&&(z=t),k.css("top",-9999)}}function s(){null!=k&&(k.css({overflow:"hidden",height:j.minimizedHeight}),N=!0)}function u(){null!=k&&(k.css({overflow:"",height:""}),N=!1)}function c(){null!=k&&(N?u():s())}function d(){var t=parseInt(k.css("top")),e=-9999==t||k.is(":hidden");return!e}function p(t,e,n){var i=[];if(O={},!t||!e)return i;R=e,U=t,i=h(t,e);var a=[],o=function(){a.push(r),a=a.concat(G.generateVisualStyleScript(B,R,j)),a=a.join(" "),V.script(a,n),b()},r=G.loadPdb(t,o);return"$3Dmol"!=r&&o(),i}function m(){var t=[];if(O={},null==U||null==R)return t;t=h(U,R);var e=[];return e=e.concat(G.generateVisualStyleScript(B,R,j)),e=e.join(" "),V.script(e),t}function h(t,e){var n=f(t,e,j,G);return B=n.colorMap,n.mappedMutations}function f(t,e,n,i){var a=[],o={},r=n.mutationColor;return _.each(_.keys(e.positionMap),function(l){var s=e.positionMap[l];if(_.isFunction(n.mutationColorMapper)&&(r=n.mutationColorMapper(l,t,e)),null!=r){null==o[r]&&(o[r]={});var u=i.scriptPosition(s);o[r][u]=u,a.push(l)}}),_.each(o,function(t,e,n){n[e]=_.values(t)}),{colorMap:o,mappedMutations:a}}function g(){if(1!=_.size(O))return!1;var t=[];return _.each(O,function(e){t=t.concat(S(e))}),t=t.join(" "),V.script(t),!0}function v(){var t=[];t.push(G.defaultCenter()),t=t.join(" "),V.script(t)}function b(){V.getViewer&&V.getViewer().resize()}function y(t){if(null==R)return!1;var e=t.mutations[0].get("mutationId"),n=M(e);return n.length>0?(n=n.join(" "),V.script(n),!0):(T(),!1)}function T(){var t=[];t.push(G.zoom(j.defaultZoom)),t.push(G.defaultCenter()),t=t.join(" "),V.script(t)}function C(t,e){if(null==R)return 0;e&&(O={});var n=G.generateVisualStyleScript(B,R,j),i=0;return _.each(t,function(t,e){var n=t.mutations[0].get("mutationId"),a=R.positionMap[n];null!=a&&(O[n]=a,i++)}),n=n.concat(w(O)),n=n.join(" "),V.script(n),i}function P(){var t=w(O);t=t.join(" "),V.script(t)}function D(){O={};var t=G.generateVisualStyleScript(B,R,j);t=t.join(" "),V.script(t)}function w(t){return G.generateHighlightScript(t,j.highlightColor,j,R)}function S(t){var e=[];return e.push(G.center(t,R.chainId)),e}function M(t){var e=[],n=R.positionMap[t];return null!=n&&(e.push(G.zoom(j.focusZoom)),e.push(G.center(n,R.chainId))),e}function x(){V.script(G.defaultZoomIn())}function I(){V.script(G.defaultZoomOut())}function A(){V.script(G.zoom(j.defaultZoom))}function E(t){V.script(G.zoom(t))}function L(t){j=jQuery.extend(!0,{},j,t)}function F(){var t=new PymolScriptGenerator,e=[];return e.push(t.reinitialize()),e.push(t.bgColor(j.appOptions.color)),e.push(t.loadPdb(U)),e=e.concat(t.generateVisualStyleScript(B,R,j)),e=e.concat(t.generateHighlightScript(O,j.highlightColor,j,R)),e.push(t.selectNone()),e=e.join("\n")}var k=null,V=null,N=!1,B=null,O={},R=null,U=null,q="OFF",z=null,H={appOptions:{width:400,height:300,debug:!1,color:"white"},pdbUri:"http://www.rcsb.org/pdb/files/",frame:"jsmol_frame.html",proteinScheme:"cartoon",restrictProtein:!1,defaultColor:"#DDDDDD",structureColors:{alphaHelix:"#FFA500",betaSheet:"#0000FF",loop:"#DDDDDD"},defaultTranslucency:5,chainColor:"#888888",chainTranslucency:0,colorProteins:"uniform",colorMutations:"byMutationType",mutationColor:"#8A2BE2",highlightColor:"#FFDD00",highlightGradient:["#FFDD00","#000000"],addGlowEffect:!1,
+displaySideChain:"highlighted",defaultZoom:100,focusZoom:250,containerPadding:10,minimizedHeight:10,mutationColorMapper:function(t,e,n){return"#FF0000"}},j=jQuery.extend(!0,{},H,e),G=new Mol3DScriptGenerator;return{init:n,show:r,hide:l,minimize:s,maximize:u,toggleSize:c,isVisible:d,reload:p,refresh:m,resizeViewer:b,focusOn:y,center:g,resetCenter:v,highlight:C,resetHighlight:D,refreshHighlight:P,zoomIn:x,zoomOut:I,zoomActual:A,zoomTo:E,resetFocus:T,updateContainer:i,toggleSpin:a,reapplyStyle:o,updateOptions:L,generatePymolScript:F}}function MutationDetailsTable(t,e,n,i,a){function o(t,a,o,l,s,u,c,d){var p=DataTableUtil.getColumnOptions(o,s),m={aaData:a,aoColumns:p,aoColumnDefs:[{bVisible:!1,aTargets:u},{bSearchable:!1,aTargets:d}],oColVis:{aiExclude:c},oTableTools:{aButtons:[{sExtends:"text",sButtonText:"Download",mColumns:r(o,c),fnCellRender:function(t,e,n,i){if(e===s.caseId){var a=T.getDataTable().fnGetData()[i];return a[0].mutation.get("caseId")}var o=t;return-1!=t.indexOf("<")&&-1!=t.indexOf(">")&&(o=$(t).text()),e===s.proteinChange&&(o=o.replace(/(\s)3D/,"")),o.trim()},fnClick:function(t,n){var i=this.fnGetTableData(n),a={filename:"mutation_table_"+e+".tsv",contentType:"text/plain;charset=utf-8",preProcess:!1};cbio.download.initDownload(i,a)}}]},fnDrawCallback:function(a){T._addColumnTooltips({gene:e,mutationUtil:n,dataProxies:i,table:T}),T._addEventListeners(s);var o=a.oPreviousSearch.sSearch;w&&S!=o&&(D.trigger(MutationDetailsEvents.MUTATION_TABLE_FILTERED,t),M=o),S=o,D.trigger(MutationDetailsEvents.MUTATION_TABLE_REDRAWN,t);var r=$(t).DataTable().rows({filter:"applied"}).data();$(a.nTableWrapper).find(".mutation-table-samples-info").text(_.size(f(r))),$(t).find('a[href=""]').remove(),$(t).find('span.mutation-table-additional-protein-change[alt=""]').remove()},fnRowCallback:function(t,e,n,i){var a=e[s.datum].mutation;$(t).attr("id",a.get("mutationId")),$(t).addClass(a.get("mutationSid")),$(t).addClass("mutation-table-data-row")},fnInitComplete:function(e,n){T.setDataTable(this),$(e.nTableWrapper).find(".ColVis_MasterButton").one("click",function(){jQuery.each($(".ColVis_radio"),function(t,e){var n=$(e).siblings(":first").text();$(e).children(":first").attr("title",n)})}),D.trigger(MutationDetailsEvents.MUTATION_TABLE_INITIALIZED,t)},fnHeaderCallback:function(e,n,i,a,o){$(e).find("th").addClass("mutation-details-table-header"),T._addHeaderTooltips(e,l),D.trigger(MutationDetailsEvents.MUTATION_TABLE_HEADER_CREATED,t)}};return m}function r(t,e){for(var n=[],i=0;i<=_.keys(t).length;i++)n.push(i);return _.difference(n,e)}function l(t){var i=P.columnVisibility[t],a=i;return i?_.isFunction(i)&&(a=i(n,e)):a="hidden",a}function s(t){var e=P.columnSearch[t],n=e;return null==e?n=!1:_.isFunction(e)&&(n=e()),n}function u(t){null!=T.getDataTable()&&_.each(P.eventListeners,function(t){t(T.getDataTable(),D,n,e)})}function c(t){w=t}function d(){S="",M=""}function p(){return M}function m(t,e){var n=MutationViewsUtil.defaultTableTooltipOpts(),i={};jQuery.extend(!0,i,n),i.position={my:"bottom center",at:"top center",viewport:$(window)},$(t).find("th").each(function(){var t=$(this).text(),n=e[t];if(null!=n){var a=P.columns[n].tip,o={};_.isString(a)&&(a={content:a}),jQuery.extend(!0,o,i,a),cbio.util.addTargetedQTip(this,o)}})}function h(t,e,n){function i(){D.off(MutationDetailsEvents.MUTATION_TABLE_INITIALIZED,i),a.getData(t,{mutationTable:T},n)}e=e||t,"excluded"===T._visiblityMap[e]||I[t+":"+e]||(I[t+":"+e]=!0,n=n||function(n,i){var a=n.mutationTable;i&&(T.getCustomData()[t]=i),MutationViewsUtil.refreshTableColumn(a.getDataTable(),a.getIndexMap(),e)},null==T.getDataTable()?D.on(MutationDetailsEvents.MUTATION_TABLE_INITIALIZED,i):i())}function f(t){var e={};return _.each(t,function(t,n){var i=t[0].mutation;i&&!_.isEmpty(i.get("caseId"))&&(e[i.get("caseId").toLowerCase()]=!0)}),e}function g(){var t=null;return n&&(t=n.getMutations()),t}function v(){return x}function b(){return n}function y(){return e}var T=this,C={el:"#mutation_details_table_d3",columns:{datum:{sTitle:"datum",tip:""},mutationId:{sTitle:"Mutation ID",tip:"Mutation ID",sType:"string"},mutationSid:{sTitle:"Mutation SID",tip:"",sType:"string"},caseId:{sTitle:"Sample ID",tip:"Sample ID",sType:"string"},cancerStudy:{sTitle:"Cancer Study",tip:"Cancer Study",sType:"string"},tumorType:{sTitle:"Cancer Type",tip:"Cancer Type",sType:"string"},proteinChange:{sTitle:"AA change",tip:"Protein Change",sType:"numeric"},mutationType:{sTitle:"Type",tip:"Mutation Type",sType:"string",sClass:"center-align-td"},cna:{sTitle:"Copy #",tip:"Copy-number status of the mutated gene",sType:"numeric",sClass:"center-align-td"},cosmic:{sTitle:"COSMIC",tip:"Overlapping mutations in COSMIC",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},mutationStatus:{sTitle:"MS",tip:"Mutation Status",sType:"string",sClass:"center-align-td"},validationStatus:{sTitle:"VS",tip:"Validation Status",sType:"string",sClass:"center-align-td"},mutationAssessor:{sTitle:"Mutation Assessor",tip:"Predicted Functional Impact Score (via Mutation Assessor) for missense mutations",sType:"numeric",sClass:"center-align-td",asSorting:["desc","asc"],sWidth:"2%"},sequencingCenter:{sTitle:"Center",tip:"Sequencing Center",sType:"string",sClass:"center-align-td"},chr:{sTitle:"Chr",tip:"Chromosome",sType:"string"},startPos:{sTitle:"Start Pos",tip:"Start Position",sType:"numeric",sClass:"right-align-td"},endPos:{sTitle:"End Pos",tip:"End Position",sType:"numeric",sClass:"right-align-td"},referenceAllele:{sTitle:"Ref",tip:"Reference Allele",sType:"string"},variantAllele:{sTitle:"Var",tip:"Variant Allele",sType:"string"},tumorFreq:{sTitle:"Allele Freq (T)",tip:"Variant allele frequency
in the tumor sample",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},normalFreq:{sTitle:"Allele Freq (N)",tip:"Variant allele frequency
in the normal sample",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},tumorRefCount:{sTitle:"Var Ref",tip:"Variant Ref Count",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},tumorAltCount:{sTitle:"Var Alt",tip:"Variant Alt Count",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},normalRefCount:{sTitle:"Norm Ref",tip:"Normal Ref Count",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},normalAltCount:{sTitle:"Norm Alt",tip:"Normal Alt Count",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]},igvLink:{sTitle:"BAM",tip:"Link to BAM file",sType:"string",sClass:"center-align-td"},mutationCount:{sTitle:"#Mut in Sample",tip:"Total number of
nonsynonymous mutations
in the sample",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"],sWidth:"2%"},cBioPortal:{sTitle:"cBioPortal",tip:"Mutation frequency in cBioPortal",sType:"numeric",sClass:"right-align-td",asSorting:["desc","asc"]}},columnOrder:["datum","mutationId","mutationSid","caseId","cancerStudy","tumorType","proteinChange","mutationType","cna","cBioPortal","cosmic","mutationStatus","validationStatus","mutationAssessor","sequencingCenter","chr","startPos","endPos","referenceAllele","variantAllele","tumorFreq","normalFreq","tumorRefCount","tumorAltCount","normalRefCount","normalAltCount","igvLink","mutationCount"],columnVisibility:{datum:"excluded",proteinChange:"visible",caseId:function(t,e){return t.containsCaseId(e)?"visible":"hidden"},mutationType:function(t,e){return t.containsMutationType(e)?"visible":"hidden"},mutationAssessor:function(t,e){return t.containsFis(e)?"visible":"hidden"},cosmic:"visible",mutationCount:function(t,e){return t.containsMutationCount(e)?"visible":"hidden"},mutationId:"excluded",mutationSid:"excluded",cancerStudy:"excluded",cna:function(t,e){return t.containsCnaData(e)?"visible":"hidden"},tumorFreq:function(t,e){return t.containsAlleleFreqT(e)?"visible":"hidden"},igvLink:function(t,e){return t.containsIgvLink(e)?"visible":"hidden"},mutationStatus:function(t,e){return t.containsGermline(e)?"visible":"hidden"},validationStatus:function(t,e){return t.containsValidStatus(e)?"visible":"hidden"},tumorType:function(t,e){var n=t.distinctTumorTypeCount(e);return n>1?"visible":"hidden"},cBioPortal:"excluded"},columnSearch:{caseId:!0,mutationId:!0,mutationSid:!0,cancerStudy:!0,proteinChange:!0,tumorType:!0,mutationType:!0},columnRender:{mutationId:function(t){var e=t.mutation,n=e.get("mutationId");return void 0===n?"":n},mutationSid:function(t){var e=t.mutation,n=e.get("mutationSid");return void 0===n?"":n},caseId:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getCaseId(e.get("caseId")),i={};i.linkToPatientView=e.get("linkToPatientView"),i.caseId=n.text,i.caseIdClass=n.style,i.caseIdTip=n.tip;var a=BackboneTemplateCache.getTemplateFn("mutation_table_case_id_template");return a(i)},proteinChange:function(t){var e=t.mutation;if(_.isUndefined(e.get("proteinChange")))return T.requestColumnData("variantAnnotation","proteinChange"),MutationViewsUtil.renderTablePlaceHolder();var n=MutationDetailsTableFormatter.getProteinChange(e),i={};i.proteinChange=n.text,i.proteinChangeClass=n.style,i.proteinChangeTip=n.tip,i.additionalProteinChangeTip=n.additionalTip,_.isUndefined(e.get("pdbMatch"))&&T.requestColumnData("pdbMatch","proteinChange"),i.pdbMatchLink=MutationDetailsTableFormatter.getPdbMatchLink(e);var a=BackboneTemplateCache.getTemplateFn("mutation_table_protein_change_template");return a(i)},cancerStudy:function(t){var e=t.mutation,n={};n.cancerStudy=e.get("cancerStudy"),n.cancerStudyShort=e.get("cancerStudyShort"),n.cancerStudyLink=e.get("cancerStudyLink");var i=BackboneTemplateCache.getTemplateFn("mutation_table_cancer_study_template");return i(n)},tumorType:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getTumorType(e),i={};i.tumorType=n.text,i.tumorTypeClass=n.style,i.tumorTypeTip=n.tip;var a=BackboneTemplateCache.getTemplateFn("mutation_table_tumor_type_template");return a(i)},mutationType:function(t){var e=t.mutation;if(_.isUndefined(e.get("mutationType")))return T.requestColumnData("variantAnnotation","mutationType"),MutationViewsUtil.renderTablePlaceHolder();var n=MutationDetailsTableFormatter.getMutationType(e.get("mutationType")),i={};i.mutationTypeClass=n.style,i.mutationTypeText=n.text;var a=BackboneTemplateCache.getTemplateFn("mutation_table_mutation_type_template");return a(i)},cosmic:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getCosmic(e.getCosmicCount()),i={};i.cosmicClass=n.style,i.cosmicCount=n.count;var a=BackboneTemplateCache.getTemplateFn("mutation_table_cosmic_template");return a(i)},cna:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getCNA(e.get("cna")),i={};i.cna=n.text,i.cnaClass=n.style,i.cnaTip=n.tip;var a=BackboneTemplateCache.getTemplateFn("mutation_table_cna_template");return a(i)},mutationCount:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getIntValue(e.get("mutationCount")),i={};i.mutationCount=n.text,i.mutationCountClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_mutation_count_template");return a(i)},normalFreq:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getAlleleCount(e.get("normalAltCount")),i=MutationDetailsTableFormatter.getAlleleFreq(e.get("normalFreq"),e.get("normalAltCount"),e.get("normalRefCount"),"simple-tip"),a={};a.normalFreq=i.text,a.normalFreqClass=i.style,a.normalFreqTipClass=i.tipClass,a.normalTotalCount=i.total,a.normalAltCount=n.text;var o=BackboneTemplateCache.getTemplateFn("mutation_table_normal_freq_template");return o(a)},tumorFreq:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getAlleleCount(e.get("tumorAltCount")),i=MutationDetailsTableFormatter.getAlleleFreq(e.get("tumorFreq"),e.get("tumorAltCount"),e.get("tumorRefCount"),"simple-tip"),a={};a.tumorFreq=i.text,a.tumorFreqClass=i.style,a.tumorFreqTipClass=i.tipClass,a.tumorTotalCount=i.total,a.tumorAltCount=n.text;var o=BackboneTemplateCache.getTemplateFn("mutation_table_tumor_freq_template");return o(a)},mutationAssessor:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getFis(e.get("functionalImpactScore"),e.get("fisValue")),i={};i.fisClass=n.fisClass,i.omaClass=n.omaClass,i.fisText=n.text;var a=BackboneTemplateCache.getTemplateFn("mutation_table_mutation_assessor_template");return a(i)},mutationStatus:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getMutationStatus(e.get("mutationStatus")),i={};i.mutationStatusTip=n.tip,i.mutationStatusClass=n.style,i.mutationStatusText=n.text;var a=BackboneTemplateCache.getTemplateFn("mutation_table_mutation_status_template");return a(i)},validationStatus:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getValidationStatus(e.get("validationStatus")),i={};i.validationStatusTip=n.tip,i.validationStatusClass=n.style,i.validationStatusText=n.text;var a=BackboneTemplateCache.getTemplateFn("mutation_table_validation_status_template");return a(i)},normalRefCount:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getAlleleCount(e.get("normalRefCount")),i={};i.normalRefCount=n.text,i.normalRefCountClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_normal_ref_count_template");return a(i)},normalAltCount:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getAlleleCount(e.get("normalAltCount")),i={};i.normalAltCount=n.text,i.normalAltCountClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_normal_alt_count_template");return a(i)},tumorRefCount:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getAlleleCount(e.get("tumorRefCount")),i={};i.tumorRefCount=n.text,i.tumorRefCountClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_tumor_ref_count_template");return a(i)},tumorAltCount:function(t){var e=t.mutation,n=MutationDetailsTableFormatter.getAlleleCount(e.get("tumorAltCount")),i={};i.tumorAltCount=n.text,i.tumorAltCountClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_tumor_alt_count_template");return a(i)},startPos:function(t){var e=t.mutation;if(_.isUndefined(e.get("startPos")))return T.requestColumnData("variantAnnotation","startPos"),MutationViewsUtil.renderTablePlaceHolder();var n=MutationDetailsTableFormatter.getIntValue(e.get("startPos")),i={};i.startPos=n.text,i.startPosClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_start_pos_template");return a(i)},endPos:function(t){var e=t.mutation;if(_.isUndefined(e.get("endPos")))return T.requestColumnData("variantAnnotation","endPos"),MutationViewsUtil.renderTablePlaceHolder();var n=MutationDetailsTableFormatter.getIntValue(e.get("endPos")),i={};i.endPos=n.text,i.endPosClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_end_pos_template");return a(i)},sequencingCenter:function(t){var e=t.mutation,n=e.get("sequencingCenter");return void 0===n?"":n},chr:function(t){var e=t.mutation;return _.isUndefined(e.get("chr"))?(T.requestColumnData("variantAnnotation","chr"),MutationViewsUtil.renderTablePlaceHolder()):e.get("chr")||""},referenceAllele:function(t){var e=t.mutation;return _.isUndefined(e.get("referenceAllele"))?(T.requestColumnData("variantAnnotation","referenceAllele"),MutationViewsUtil.renderTablePlaceHolder()):e.get("referenceAllele")||""},variantAllele:function(t){var e=t.mutation;return _.isUndefined(e.get("variantAllele"))?(T.requestColumnData("variantAnnotation","variantAllele"),MutationViewsUtil.renderTablePlaceHolder()):e.get("variantAllele")||""},igvLink:function(t){var e=t.mutation,n={};n.igvLink=MutationDetailsTableFormatter.getIgvLink(e);var i=BackboneTemplateCache.getTemplateFn("mutation_table_igv_link_template");return i(n)},cBioPortal:function(t){var e=t.mutation;if(_.isUndefined(e.get("cBioPortal")))return T.requestColumnData("cBioPortal"),MutationViewsUtil.renderTablePlaceHolder();var n=MutationDetailsTableFormatter.getCbioPortal(e.get("cBioPortal")),i={};i.portalFrequency=n.frequency,i.portalClass=n.style;var a=BackboneTemplateCache.getTemplateFn("mutation_table_cbio_portal_template");return a(i)}},columnTooltips:{simple:function(t,e){var n=MutationViewsUtil.defaultTableTooltipOpts();cbio.util.addTargetedQTip($(t).find(".simple-tip"),n)},cosmic:function(t,e){var n=e.gene,i=e.mutationUtil,a=MutationViewsUtil.defaultTableTooltipOpts();$(t).find(".mutation_table_cosmic").each(function(){var t=this,e=$(t).closest("tr.mutation-table-data-row").attr("id"),o=i.getMutationIdMap()[e],r={};jQuery.extend(!0,r,a),r.content={text:"NA"},r.events={render:function(e,i){var a={cosmic:o.get("cosmic"),keyword:o.get("keyword"),geneSymbol:n,total:$(t).text()},r=$(this).find(".qtip-content"),l=new CosmicTipView({el:r,model:a});l.render()}},cbio.util.addTargetedQTip(t,r)})},mutationAssessor:function(t,e){var n=(e.gene,e.mutationUtil),i=MutationViewsUtil.defaultTableTooltipOpts();$(t).find(".oma_link").each(function(){var t=$(this).closest("tr.mutation-table-data-row").attr("id"),e=n.getMutationIdMap()[t],a=MutationDetailsTableFormatter.getFis(e.get("functionalImpactScore"),e.get("fisValue")),o={};jQuery.extend(!0,o,i),o.content={text:"NA"},o.events={render:function(t,n){var i={impact:a.value,xvia:e.get("xVarLink").replace("getma.org","mutationassessor.org/r2"),msaLink:e.get("msaLink").replace("getma.org","mutationassessor.org/r2"),pdbLink:e.get("pdbLink").replace("getma.org","mutationassessor.org/r2")},o=$(this).find(".qtip-content"),r=new PredictedImpactTipView({el:o,model:i});r.render()}},cbio.util.addTargetedQTip(this,o)})},cBioPortal:function(t,e){var n=e.gene,i=e.mutationUtil,a=e.dataProxies.portalProxy,o=e.table,r=function(e,a,o){$(t).find(".mutation_table_cbio_portal").each(function(t,r){var l=$(this).closest("tr.mutation-table-data-row").attr("id"),s=i.getMutationIdMap()[l],u=o||s.get("cancerStudy");cbio.util.addTargetedQTip(r,{content:{text:"pancancer mutation bar chart is broken"},events:{render:function(t,i){var o={pancanMutationFreq:e,cancerStudyMetaData:a,cancerStudyName:u,geneSymbol:n,keyword:s.get("keyword"),proteinPosStart:s.get("proteinPosStart"),mutationType:s.get("mutationType"),qtipApi:i},r=$(this),l=new PancanMutationHistTipView({el:r,model:o});l.render()}},hide:{fixed:!0,delay:100},style:{classes:"qtip-light qtip-rounded qtip-shadow",tip:!0},position:{my:"center right",at:"center left",viewport:$(window)}})})};null!=o.getCustomData().cBioPortal&&a.getPortalData({cancerStudyMetaData:!0,cancerStudyName:!0},function(t){r(o.getCustomData().cBioPortal,t.cancerStudyMetaData,t.cancerStudyName)})}},eventListeners:{windowResize:function(t,e,n,i){$(window).one("resize",function(){t.is(":visible")&&t.fnAdjustColumnSizing()})},igvLink:function(t,e,n,i){$(t).find(".igv-link").off("click").on("click",function(t){t.preventDefault();var e=$(this).closest("tr.mutation-table-data-row").attr("id"),i=n.getMutationIdMap()[e],a=i.get("igvLink");$.getJSON(a,function(t){prepIGVLaunch(t.bamFileUrl,t.encodedLocus,t.referenceGenome,t.trackName)})})},proteinChange3d:function(t,e,n,i){$(t).find(".mutation-table-3d-link").off("click").on("click",function(t){t.preventDefault();var n=$(this).closest("tr.mutation-table-data-row").attr("id");e.trigger(MutationDetailsEvents.PDB_LINK_CLICKED,n)})},proteinChange:function(t,e,n,i){$(t).find(".mutation-table-protein-change a").off("click").on("click",function(t){t.preventDefault();var n=$(this).closest("tr.mutation-table-data-row").attr("id");e.trigger(MutationDetailsEvents.PROTEIN_CHANGE_LINK_CLICKED,n)})}},columnSort:{mutationId:function(t){var e=t.mutation;return void 0===e.get("mutationId")?"":e.get("mutationId")},mutationSid:function(t){var e=t.mutation;return void 0===e.get("mutationSid")?"":e.get("mutationSid")},caseId:function(t){var e=t.mutation;return void 0===e.get("caseId")?"":e.get("caseId")},proteinChange:function(t){var e=t.mutation.get("proteinChange"),n=/[A-Za-z][0-9]+./g,i=/[0-9]+/g,a=/[^0-9]+/g,o=function(t){var e=t[0].match(a);if(e&&e.length>0){var n=e.join("");e=[];for(var i=0;i0){var s=r[0];return l&&l.length>0&&(s+="."+l.join("")),parseFloat(s)}return-(1/0)},cancerStudy:function(t){var e=t.mutation,n=e.get("cancerStudy");return void 0===n?"":n},tumorType:function(t){var e=t.mutation,n=e.get("tumorType");return void 0===n?"":n},mutationType:function(t){var e=t.mutation,n=e.get("mutationType");return void 0===n?"":n},cosmic:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.getCosmicCount())},cna:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("cna"))},mutationCount:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("mutationCount"))},normalFreq:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignFloatValue(e.get("normalFreq"))},tumorFreq:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignFloatValue(e.get("tumorFreq"))},mutationAssessor:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignValueToPredictedImpact(e.get("functionalImpactScore"),e.get("fisValue"))},mutationStatus:function(t){var e=t.mutation,n=e.get("mutationStatus");return void 0===n?"":n},validationStatus:function(t){var e=t.mutation,n=e.get("validationStatus");return void 0===n?"":n},normalRefCount:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("normalRefCount"))},normalAltCount:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("normalAltCount"))},tumorRefCount:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("tumorRefCount"))},tumorAltCount:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("tumorAltCount"))},startPos:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("startPos"))},endPos:function(t){var e=t.mutation;return MutationDetailsTableFormatter.assignIntValue(e.get("endPos"))},sequencingCenter:function(t){var e=t.mutation,n=e.get("sequencingCenter");return void 0===n&&(n=""),n},chr:function(t){var e=t.mutation,n=e.get("chr");return void 0===n?"":n},referenceAllele:function(t){var e=t.mutation,n=e.get("referenceAllele");return void 0===n?"":n},variantAllele:function(t){var e=t.mutation,n=e.get("variantAllele");return void 0===n?"":n},igvLink:function(t){var e=t.mutation,n=e.get("igvLink");return void 0===n?"":n},cBioPortal:function(t){var e=t.cBioPortal;return e||0}},columnFilter:{proteinChange:function(t){return t.mutation.get("proteinChange")||""},mutationType:function(t){var e=MutationDetailsTableFormatter.getMutationType(t.mutation.get("mutationType"));return e.text},cosmic:function(t){return t.mutation.getCosmicCount()||""},cna:function(t){return t.mutation.get("cna")||""},mutationCount:function(t){return t.mutation.get("mutationCount")||""},normalFreq:function(t){return t.mutation.get("normalFreq")||""},tumorFreq:function(t){return t.mutation.get("tumorFreq")||""},mutationAssessor:function(t){return t.mutation.get("functionalImpactScore")||""},normalRefCount:function(t){return t.mutation.get("normalRefCount")||""},normalAltCount:function(t){return t.mutation.get("normalAltCount")||""},tumorRefCount:function(t){return t.mutation.get("tumorRefCount")||""},tumorAltCount:function(t){return t.mutation.get("tumorAltCount")||""},startPos:function(t){return t.mutation.get("startPos")||""},endPos:function(t){return t.mutation.get("endPos")||""}},columnData:{},filteringDelay:600,dataTableOpts:{sDom:'<"H"<"mutation_datatables_filter"f>C<"mutation_datatables_info"i>>t<"F"<"mutation_datatables_download"T>>',bJQueryUI:!0,bPaginate:!1,bFilter:!0,sScrollY:"600px",bScrollCollapse:!0,oLanguage:{sInfo:"Showing _TOTAL_ mutation(s) in sample(s)",sInfoFiltered:"(out of _MAX_ total mutations)",sInfoEmpty:"No mutations to show"}}},P=jQuery.extend(!0,{},C,t);AdvancedDataTable.call(this,P),P=T._options;var D=T._dispatcher,w=!0,S="",M="",x={},I={};this._initDataTableOpts=o,this._visibilityValue=l,this._searchValue=s,this._addEventListeners=u,this._addHeaderTooltips=m,this.setFilterEventActive=c,this.getManualSearch=p,this.cleanFilters=d,this.requestColumnData=h,this.getCustomData=v,this.getMutations=g,this.getMutationUtil=b,this.getGene=y,this.dispatcher=this._dispatcher}function MutationDiagram(t,e,n,i){var a=this;a.listeners={},a.dispatcher={},_.extend(a.dispatcher,Backbone.Events),a.options=jQuery.extend(!0,{},a.defaultOpts,e),a.dataProxies=i,a.geneSymbol=t,a.data=n,a.pileups=null==n?null:PileupUtil.convertToPileups(n.mutations,e.pileupConverter),a.initialPileups=a.pileups,a.highlighted={},a.multiSelect=!1,a.svg=null,a.bounds=null,a.gData=null,a.gLine=null,a.gLabel=null,a.xScale=null,a.yScale=null,a.topLabel=null,a.xAxisLabel=null,a.yAxisLabel=null,a.xMax=null,a.yMax=null,a.maxCount=null,a.mutationColorMap={},a.mutationPileupMap={}}function MutationHistogram(t,e,n){MutationDiagram.call(this,t,e,n)}function MutationPdbPanel(t,e,n,i){function a(t,e,n,i,a){var l=nt;_.each(n,function(n,o){_.each(n,function(n,s){var u=n.chain;if(u.alignments.length>0){var c=e.colors[s%e.colors.length],d=e.marginTop+(a+o)*(e.chainHeight+e.chainPadding),p=r(t,u,c,e,i,d);p.datum(n),at[PdbDataUtil.chainKey(n.pdbId,n.chain.chainId)]=p,null==X&&(X=p),l++}})}),nt=l,o(n,e)}function o(t,e){var i=[],a=[];_.each(t,function(t,e){_.each(t,function(t,e){i.push(t.pdbId),a.push(at[PdbDataUtil.chainKey(t.pdbId,t.chain.chainId)])})}),n.getPdbInfo(i.join(" "),function(t){_.each(a,function(t,n){var i=e.chainTipFn;i(t)})})}function r(t,e,n,i,a,o){for(var r=t.append("g").attr("class","pdb-chain-group").attr("opacity",1),l=i.chainHeight,s=new MergedAlignmentSegmentor(e.mergedAlignment);s.hasNextSegment();){var u=s.getNextSegment(),c=Math.abs(a(u.start)-a(u.end)),d=a(u.start);if(u.type==PdbDataUtil.ALIGNMENT_GAP){var p=r.append("line").attr("stroke",i.chainBorderColor).attr("stroke-width",i.chainBorderWidth).attr("x1",d).attr("y1",o+l/2).attr("x2",d+c).attr("y2",o+l/2);p.datum({initPos:{x:d,y:o+l/2}})}else{var m=r.append("rect").attr("fill",n).attr("opacity",e.mergedAlignment.identityPerc).attr("stroke",i.chainBorderColor).attr("stroke-width",i.chainBorderWidth).attr("x",d).attr("y",o).attr("width",c).attr("height",l);m.datum({initPos:{x:d,y:o}})}}return r}function l(t,e){var n=e.marginLeft-e.labelYPaddingRightV,i=e.marginTop+e.labelYPaddingTopV,a="middle",o="rotate(270, "+n+","+i+")",r="vertical";Z.lengtht){n=i;break}return-1==n&&(n=e.length-1),n}function p(t){var e=0,n=Z.length;return e="auto"!=t?t:K.marginTop+K.marginBottom+n*(K.chainHeight+K.chainPadding)-K.chainPadding/2}function m(t){var e=0,n=Z.length;return e=n>t?K.marginTop+t*(K.chainHeight+K.chainPadding)-K.chainPadding/2:p("auto")}function h(t,e,n){var i=t.append("svg");return i.attr("width",e),i.attr("height",n),i}function f(t){var e=K.elWidth-(K.marginLeft+K.marginRight),n=K.marginLeft;return d3.scale.linear().domain([0,g(t)]).range([n,n+e])}function g(t){var e=[];return _.each(t,function(t){_.each(t,function(t){e.push(t.chain.mergedAlignment.uniprotTo)})}),_.max(e)}function v(){Z=PdbDataUtil.allocateChainRows(e),et=d(Z.length,K.numRows),null==i&&(i=f(Z));var t=$(K.el)[0],n=d3.select(t),o=K.numRows[0];rt=m(o);var r=h(n,K.elWidth,rt);J=r,a(r,K,Z.slice(0,o),i,0),it[0]=!0,0!=K.labelY&&l(r,K),ot=b(Z),C()}function b(t){var e={};return _.each(t,function(t,n){_.each(t,function(t,i){e[PdbDataUtil.chainKey(t.pdbId,t.chain.chainId)]=n})}),e}function y(t,e,n){J.selectAll(t).on(e,n),null==Q[t]&&(Q[t]={}),Q[t][e]=n}function T(t,e){J.selectAll(t).on(e,null),Q[t]&&Q[t][e]&&delete Q[t][e]}function C(){y(".pdb-chain-group","click",function(t,e){L(d3.select(this))})}function P(){_.each(_.keys(Q),function(t){var e=J.selectAll(t);_.each(_.keys(Q[t]),function(n){e.on(n,Q[t][n])})})}function D(){$(K.el).show()}function w(){$(K.el).hide()}function S(t){var e=m(K.numRows[t]),n=J.attr("height");j(e,n),J.transition().duration(K.animationDuration).attr("height",e).each("end",function(){G(e,n)}),rt=e}function M(){var t=x();S(t)}function x(){var t=(tt+1)%(et+1);return it[t]||(a(J,K,Z.slice(K.numRows[tt],K.numRows[t]),i,K.numRows[tt]),P(),it[t]=!0),tt=t,t}function I(t){for(var e=-1,n=tt;t>n&&et>n;n++)e=x();-1!==e&&S(e)}function A(t,e){for(var n=-1,i=ot[PdbDataUtil.chainKey(t,e)],a=0;aK.numRows[0]}function L(t){lt=t;var e=F(t);J.selectAll(".pdb-selection-rectangle-group").remove();var n=J.append("g").attr("class","pdb-selection-rectangle-group").attr("opacity",0),i=n.append("rect").attr("fill","none").attr("stroke",K.highlightBorderColor).attr("stroke-width",K.highlightBorderWidth).attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height);n.transition().duration(K.animationDuration).attr("opacity",1),i.datum({initPos:{x:e.x,y:e.y}}),W.trigger(MutationDetailsEvents.PANEL_CHAIN_SELECTED,t)}function F(t){var e=1/0,n=-1,i=-1,a=-1;return t.selectAll("rect").each(function(t,o){var r=d3.select(this);i=parseFloat(r.attr("y")),a=parseFloat(r.attr("height"));var l=parseFloat(r.attr("x")),s=parseFloat(r.attr("width"));e>l&&(e=l),l+s>n&&(n=l+s)}),{x:e,y:i,width:n-e,height:a}}function k(t){null!=lt&&V(lt,t)}function V(t,e){var n=K.animationDuration;N(t,e),t==lt&&N(J.selectAll(".pdb-selection-rectangle-group")),B(t);var i=m(1),a=J.attr("height");j(i,a),J.transition().duration(n).attr("height",i).each("end",function(){G(i,a)})}function N(t,e){var n=K.animationDuration,i=K.marginTop,a=K.chainHeight;t.selectAll("line").transition().duration(n).attr("y1",i+a/2).attr("y2",i+a/2),t.selectAll("rect").transition().duration(n).attr("y",i).each("end",function(){_.isFunction(e)&&e()})}function B(t,e){var n=K.animationDuration,i=t.datum(),a=PdbDataUtil.chainKey(i.pdbId,i.chain.chainId);J.selectAll(".pdb-chain-group").transition().duration(n).attr("opacity",function(t){return PdbDataUtil.chainKey(t.pdbId,t.chain.chainId)===a?1:0}),J.selectAll(".pdb-selection-rectangle-group").transition().duration(n).attr("opacity",function(e){return lt==t?1:0}),J.select(".pdb-panel-y-axis-label-group").transition().duration(n).attr("opacity",0).each("end",function(){_.isFunction(e)&&e()})}function O(t,e,n){J.selectAll(t).transition().duration(n).attr("y1",function(t){return e(this,t,"y1")}).attr("y2",function(t){return e(this,t,"y2")})}function R(t,e,n){J.selectAll(t).transition().duration(n).attr("y",function(t){return e(this,t,"y")})}function U(t){var e=K.animationDuration;q(),z();var n=J.attr("height");j(rt,n),J.transition().duration(e).attr("height",rt).each("end",function(){_.isFunction(t)&&t(),G(rt,n)})}function q(t){var e=K.animationDuration,n=function(t,e,n){return e.initPos.y};R(".pdb-chain-group rect",n,e),O(".pdb-chain-group line",n,e),R(".pdb-selection-rectangle-group rect",n,e),setTimeout(t,e+50)}function z(t){var e=K.animationDuration;
+J.selectAll(".pdb-chain-group").transition().duration(e).attr("opacity",1),J.selectAll(".pdb-selection-rectangle-group").transition().duration(e).attr("opacity",1),J.selectAll(".pdb-panel-y-axis-label-group").transition().duration(e).attr("opacity",1).each("end",function(){_.isFunction(t)&&t()})}function H(){return lt}function j(t,e){W.trigger(MutationDetailsEvents.PDB_PANEL_RESIZE_STARTED,t,e,K.maxHeight)}function G(t,e){W.trigger(MutationDetailsEvents.PDB_PANEL_RESIZE_ENDED,t,e,K.maxHeight)}var Y={el:"#mutation_pdb_panel_d3",elWidth:740,elHeight:"auto",maxHeight:200,numRows:[1/0],marginLeft:45,marginRight:30,marginTop:2,marginBottom:0,chainHeight:6,chainPadding:3,labelY:["PDB","Chains"],labelYFont:"sans-serif",labelYFontColor:"#2E3436",labelYFontSize:"12px",labelYFontWeight:"normal",labelYPaddingRightH:45,labelYPaddingTopH:7,labelYPaddingRightV:25,labelYPaddingTopV:20,labelAlignThreshold:5,chainBorderColor:"#666666",chainBorderWidth:.5,highlightBorderColor:"#FF9900",highlightBorderWidth:2,colors:["#3366cc"],animationDuration:1e3,chainTipFn:function(t){var e=t.datum();n.getPdbInfo(e.pdbId,function(n){var i=null;n&&(i=PdbDataUtil.generatePdbInfoSummary(n[e.pdbId],e.chain.chainId));var a=new PdbChainTipView({model:{pdbId:e.pdbId,pdbInfo:i.title,molInfo:i.molecule,chain:e.chain}}),o=a.compileTemplate(),r={content:{text:o},hide:{fixed:!0,delay:100},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-lightyellow"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,r)})},yHelpTipFn:function(t){var e=BackboneTemplateCache.getTemplateFn("mutation_details_pdb_help_tip_template"),n=e({}),i={content:{text:n},hide:{fixed:!0,delay:100},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-lightyellow qtip-wide"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,i)}},Q={},W={};_.extend(W,Backbone.Events);var K=jQuery.extend(!0,{},Y,t),J=null,Z=null,X=null,tt=0,et=null,nt=0,it=[],at={},ot={},rt=0,lt=null;return{init:v,addListener:y,removeListener:T,getChainGroup:c,getDefaultChainGroup:u,show:D,hide:w,toggleHeight:M,expandToChainLevel:A,minimizeToChain:V,minimizeToHighlighted:k,restoreToFull:U,restoreChainPositions:q,fadeInAll:z,hasMoreChains:E,highlight:L,getHighlighted:H,dispatcher:W}}function MutationPdbTable(t){function e(t,e,n,i,a,o,r,l){var u=DataTableUtil.getColumnOptions(n,a),c={aaData:e,aoColumns:u,aoColumnDefs:[{bVisible:!1,aTargets:o},{bSearchable:!1,aTargets:l}],oColVis:{aiExclude:r},fnDrawCallback:function(t){s._addColumnTooltips()},fnHeaderCallback:function(t,e,n,i,a){$(t).find("th").addClass("mutation-pdb-table-header")},fnRowCallback:function(t,e,n,i){var o=e[a.datum],r=PdbDataUtil.chainKey(o.pdbId,o.chain.chainId);p[r]=t,$(t).addClass("pdb-chain-table-data-row")},fnInitComplete:function(t,e){d.trigger(MutationDetailsEvents.PDB_TABLE_READY)}};return c}function n(t){var e=c.columnVisibility[t],n=e;return e?_.isFunction(e)&&(n=e()):n="hidden",n}function i(t){var e=c.columnSearch[t],n=e;return null==e?n=!1:_.isFunction(e)&&(n=e()),n}function a(){s.getDataTable().fnFilter("")}function o(t,e){var n=PdbDataUtil.chainKey(t,e);r();var i=p[n];$(i).addClass("row_selected"),m=i}function r(){$(c.el).find("tr").removeClass("row_selected")}function l(){return m}var s=this,u={el:"#mutation_pdb_table_d3",elWidth:740,columns:{datum:{sTitle:"datum",tip:""},pdbId:{sTitle:"PDB Id",tip:"",sType:"string"},chain:{sTitle:"Chain",tip:"",sType:"string"},uniprotPos:{sTitle:"Uniprot Positions",tip:"",sType:"numeric"},identityPercent:{sTitle:"Identity Percent",tip:"",sType:"numeric"},organism:{sTitle:"Organism",tip:"",sType:"string"},summary:{sTitle:"Summary",tip:"",sType:"string",sWidth:"65%"}},columnOrder:["datum","pdbId","chain","uniprotPos","identityPercent","organism","summary"],columnVisibility:{pdbId:"visible",chain:"visible",uniprotPos:"visible",identityPercent:"hidden",organism:"visible",summary:"visible",datum:"excluded"},columnSearch:{pdbId:!0,organism:!0,summary:!0},columnRender:{identityPercent:function(t){return Math.round(100*t.chain.mergedAlignment.identityPerc)},pdbId:function(t){var e=BackboneTemplateCache.getTemplateFn("mutation_pdb_table_pdb_cell_template");return e({pdbId:t.pdbId})},chain:function(t){var e=BackboneTemplateCache.getTemplateFn("mutation_pdb_table_chain_cell_template");return e({chainId:t.chain.chainId})},organism:function(t){return t.organism},summary:function(t){var e={summary:t.summary.title,molecule:t.summary.molecule},n=BackboneTemplateCache.getTemplateFn("mutation_pdb_table_summary_cell_template");return n(e)},uniprotPos:function(t){return t.chain.mergedAlignment.uniprotFrom+"-"+t.chain.mergedAlignment.uniprotTo}},columnTooltips:{simple:function(e){MutationViewsUtil.defaultTableTooltipOpts();cbio.util.addTargetedQTip($(e).find(".simple-tip"),t)}},eventListeners:{pdbLink:function(t,e,n){$(t).on("click",".pbd-chain-table-chain-cell a",function(i){i.preventDefault(),r();var a=$(i.target).closest("tr.pdb-chain-table-data-row");a.addClass("row_selected");var o=t.fnGetData(a[0]),l=o[n.datum];e.trigger(MutationDetailsEvents.TABLE_CHAIN_SELECTED,l.pdbId,l.chain.chainId)})}},columnSort:{identityPercent:function(t){return MutationDetailsTableFormatter.assignFloatValue(Math.round(100*t.chain.mergedAlignment.identityPerc))},pdbId:function(t){return t.pdbId},chain:function(t){return t.chain.chainId},organism:function(t){return t.organism},summary:function(t){return t.summary.title+t.summary.molecule},uniprotPos:function(t){return MutationDetailsTableFormatter.assignIntValue(t.chain.mergedAlignment.uniprotFrom)}},columnFilter:{identityPercent:function(t){return Math.round(100*t.chain.mergedAlignment.identityPerc)},summary:function(t){return t.summary.title+" "+t.summary.molecule},uniprotPos:function(t){return t.chain.mergedAlignment.uniprotFrom+"-"+t.chain.mergedAlignment.uniprotTo}},filteringDelay:0,dataTableOpts:{sDom:'<"H"<"mutation_pdb_datatable_info"i><"mutation_pdb_datatable_filter"f>>t',bJQueryUI:!0,bPaginate:!1,bFilter:!0,sScrollY:"200px",bScrollCollapse:!0,oLanguage:{sInfo:"Showing _TOTAL_ PDB chain(s)",sInfoFiltered:"(out of _MAX_ total chains)",sInfoEmpty:"No chains to show"}}},c=jQuery.extend(!0,{},u,t);AdvancedDataTable.call(this,c),c=s._options;var d=s._dispatcher,p={},m=null;this._initDataTableOpts=e,this._visibilityValue=n,this._searchValue=i,this.selectRow=o,this.cleanFilters=a,this.getSelectedRow=l,this.dispatcher=this._dispatcher}function PancanMutationHistogram(t,e,n,i,a){function o(t){return t.map(_.clone)}function r(t){return _.reduce(t,function(t,e){return t[e.cancer_study]=e,t},{})}function l(t){var e=v[t.cancer_study].num_sequenced_samples;return t.num_sequenced_samples=e,t.frequency=t.count/e,t}function s(t){var e=_.reduce(t,function(t,e){return t+e.frequency},0);return-1*e}function u(t){var e=t[0].cancer_type;if(!_.every(t,function(t){return t.cancer_type===e}))throw new Error("not all data in a group have the same cancer type");return e}function c(t){function e(t){return{cancer_study:t,count:0,cancer_type:v[t].cancer_type,num_sequenced_samples:v[t].num_sequenced_samples}}var n=r(t);return _.chain(b).reduce(function(t,e){return _.has(n,e)||t.push(e),t},[]).map(e).value()}function d(t){return t.concat(c(t))}function p(){var t,e=_.find(x[0],function(t){return t.cancer_study===a.this_cancer_study});try{t=e.cancer_type}catch(n){throw new Error(n+": could not find this the corresponding datum for this cancer study, ["+a.this_cancer_study+"]")}var i=function(t){return _.find(t,function(t){return t.cancer_study===a.this_cancer_study})},o=_.zip.apply(null,x);o=_.find(o,i);var r=s(o);L.append("text").text("*").attr("id","star").attr("x",V(a.this_cancer_study)).attr("y",O(-1*r)+10).style("font-family","Helvetica Neue, Helvetica, Arial, sans-serif").style("font-size",3*V.rangeBand()+"px")}function m(t){var e=d3.select(t).selectAll(".mouseOver").data(b).enter().append("rect").attr("class","mouseOver").attr("y",a.margin.top).attr("x",function(t){return V(t)+a.margin.left}).attr("opacity","0").attr("height",E+5).attr("width",V.rangeBand()).on("mouseover",function(){d3.select(this).attr("opacity","0.25")}).on("mouseout",function(){d3.select(this).attr("opacity","0")});e.each(function(t){$(this).qtip({content:{text:"mouseover failed"},position:{my:"left top",at:"center right",viewport:$(window)},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-wide"},hide:{fixed:!0,delay:100},events:{render:function(e,n){var i=g(t).map(function(t){return t[0].__data__}),a=i.filter(function(t){return _.has(t,"keyword")})[0]||{},o=i.filter(function(t){return!_.has(t,"keyword")})[0]||{},r=o.cancer_study,l=v[r].num_sequenced_samples,s=""+r+"
"+f(a,o,l);n.set("content.text",s)}}})})}function h(t,e){var n=t.count||0;"frequency"in t||(t.frequency=n/e);var i=(100*t.frequency).toFixed(1)+"%";return _.template("{{percent}} ({{count}} of {{total}} sequenced samples)")({percent:i,count:n,total:e})}function f(t,e,n){return""+C+": "+h(t,n)+"
Other "+Y+" mutations: "+h(e,n)+"
"}function g(t){return z.filter(function(e){return e.cancer_study===t})}a=a||{},a=a.sparkline?_.extend({margin:{top:-12,right:0,bottom:0,left:0},width:30,height:12,this_cancer_study:void 0},a):_.extend({margin:{top:6,right:10,bottom:20,left:40},width:600,height:300,this_cancer_study:void 0},a);var v=r(n),b=_.keys(v),y=o(t),T=o(e),C=y[0].hugo+" "+y[0].protein_pos_start;y=d(y).map(function(t){return t.keyword=C,t}),T=d(T);var P={bykeyword:r(y),bygene:r(T)},D=_.intersection(_.keys(P.bykeyword),_.keys(P.bygene));if(y=[],T=[],_.each(D,function(t){y.push(P.bykeyword[t]),T.push(P.bygene[t])}),T.length!==y.length)throw new Error("must be same length");if(T.length!==b.length)throw new Error("there must be a datum for every cancer study and visa versa");T.forEach(function(t){var e=P.bykeyword[t.cancer_study],n=t.count-e.count;if(0>n)throw new Error("more mutations for a particular keyword than for all keywords of a particular gene");t.count=n});var w=_.reduce(T,function(t,e){return t+e.count},0),S=_.reduce(y,function(t,e){return t+e.count},0),M=_.reduce(v,function(t,e){return t+e.num_sequenced_samples},0);_.mixin({unzip:function(t){return _.zip.apply(_,t)}});var x=y.concat(T);try{x=_.chain(x).map(l).groupBy(function(t){return t.cancer_study}).map(_.identity).sortBy(u).unzip().value()}catch(I){throw new Error(I)}var A=a.width-a.margin.left-a.margin.left,E=a.height-a.margin.top-a.margin.bottom,L=d3.select(i).append("svg").attr("width",a.width).attr("height",a.height).append("g").attr("transform","translate("+a.margin.left+","+a.margin.top+")"),F=d3.layout.stack().x(function(t){return t.cancer_study}).y(function(t){return t.frequency}),k=F(x),V=d3.scale.ordinal().domain(x[0].map(function(t){return t.cancer_study})).rangeBands([0,A],.1),N=.2,B=a.sparkline?N:d3.max(k,function(t){return d3.max(t,function(t){return t.y0+t.y})}),O=d3.scale.linear().domain([0,B]).range([E,0]).clamp(!0),R="LimeGreen",U="Green",q=L.selectAll(".layer").data(k).enter().append("g").attr("class","layer").style("fill",function(t,e){return[U,R][e]}),z=q.selectAll("rect").data(function(t){return t}).enter().append("rect").attr("x",function(t){return V(t.cancer_study)}).attr("y",function(t){return O(t.y0+t.y)}).attr("width",function(t){return V.rangeBand()}).attr("height",function(t){return O(t.y0)-O(t.y0+t.y)});if(a.sparkline)return{el:i,qtip:function(){throw new Error("don't qtip a sparkline")}};var H=d3.format(B>.1?".0%":".1%"),j=d3.svg.axis().scale(O).tickFormat(H).orient("left");j.tickSize(j.tickSize(),0,0);var G=function(){function t(t){return{cancer_type:t.cancer_type,start:t.cancer_study,end:t.cancer_study,color:v[t.cancer_study].color}}var e=x[0][0];return _.chain(x[0]).reduce(function(e,n){var i=_.last(e);return i.cancer_type!==n.cancer_type?e.concat(t(n)):i.cancer_type===n.cancer_type?(i.end=n.cancer_study,e):void 0},[t(e)]).value()}();L.selectAll("line").data(G).enter().append("line").attr("x1",function(t){return V(t.start)}).attr("x2",function(t){return V(t.end)+V.rangeBand()}).attr("y1",E+a.margin.bottom/3).attr("y2",E+a.margin.bottom/3).style("stroke-width",5).style("stroke",function(t){return t.color});var Y=(L.append("g").call(j).attr("stroke","#000").attr("shape-rendering","crispEdges"),_.find(k[0],function(t){return void 0!==t.hugo}).hugo),C=_.find(k[0],function(t){return void 0!==t.keyword}).keyword;return _.isUndefined(a.this_cancer_study)||p(),{el:i,qtip:m,overallCountText:function(){return f({count:S},{count:w},M)}}}function MainMutationController(t){function e(){t.diagramView?n(t.diagramView.mutationDiagram):t.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,n),t.addResetCallback(i)}function n(t){s=t,t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,o),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,r),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,l),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED,a)}function i(e){s&&s.resetPlot(),t.hideFilterInfo()}function a(){s&&s.isFiltered()?t.showFilterInfo():t.hideFilterInfo()}function o(){s&&!s.isFiltered()&&t.hideFilterInfo()}function r(t,e){s&&0==s.getSelectedElements().length&&o()}function l(e,n){t.showFilterInfo()}var s=null;e()}function Mutation3dController(t,e,n,i,a,o,r,l,s){function u(){e.diagramView?c(e.diagramView.mutationDiagram):e.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,c),e.tableView&&e.tableView.mutationTable&&(e.tableView.mutationTable.dispatcher.on(MutationDetailsEvents.PDB_LINK_CLICKED,k),e.tableView.mutationTable.dispatcher.on(MutationDetailsEvents.PROTEIN_CHANGE_LINK_CLICKED,F)),o.addInitCallback(h),t.dispatcher.on(MutationDetailsEvents.GENE_TAB_SELECTED,p),a?d(a):t.dispatcher.on(MutationDetailsEvents.VIS_3D_PANEL_CREATED,d)}function c(t){j=t,t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,x),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,I),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,A),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOVER,E),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOUT,L),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED,M),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_RESET,S)}function d(t){t&&(z=t,H=t.options.mut3dVis,z.dispatcher.on(MutationDetailsEvents.VIEW_3D_PANEL_CLOSED,m),z.dispatcher.on(MutationDetailsEvents.VIEW_3D_STRUCTURE_RELOADED,b))}function p(t){z&&(z.resetPanelPosition(),z.hideView())}function m(){U&&U.hideView()}function h(t){$(),null!=z&&(z.resetPanelPosition(),z.maximizeView())}function f(t,e,n){t>n&&U.toggleScrollBar(n)}function g(t,e,n){n>=t&&U.toggleScrollBar(-1),e!=t&&U.scrollToSelected()}function v(t){G&&U.scrollToSelected();var e=t.datum();null!=z&&(z.maximizeView(),z.updateView(s,e.pdbId,e.chain)),G||null==q||(q.resetFilters(),q.selectChain(e.pdbId,e.chain.chainId),q.scrollToSelected()),G=!1}function b(){o.isVisible()&&j&&j.isHighlighted()&&B()}function y(t,e){t&&e&&(U.selectChain(t,e),G=!0)}function T(){U.pdbPanel.minimizeToHighlighted()}function C(t,e){t&&e&&U.pdbPanel.minimizeToChain(U.pdbPanel.getChainGroup(t,e))}function P(t){null==U&&(U=e.initPdbPanelView(i.pdbPanel,n.pdbPanel,n.pdbTable,t),U.pdbPanel&&(U.pdbPanel.dispatcher.on(MutationDetailsEvents.PANEL_CHAIN_SELECTED,v),U.pdbPanel.dispatcher.on(MutationDetailsEvents.PDB_PANEL_RESIZE_STARTED,f),U.pdbPanel.dispatcher.on(MutationDetailsEvents.PDB_PANEL_RESIZE_ENDED,g)),n.pdbTable?U.addInitCallback(function(e){D(t)}):U.$el.find(".pdb-table-controls").remove())}function D(t){null==q&&null!=U&&t.length>0&&(q=U.initPdbTableView(t,function(t,e){e.dispatcher.on(MutationDetailsEvents.PDB_TABLE_READY,w),q=t}),q.pdbTable.dispatcher.on(MutationDetailsEvents.TABLE_CHAIN_SELECTED,y),q.pdbTable.dispatcher.on(MutationDetailsEvents.TABLE_CHAIN_MOUSEOUT,T),q.pdbTable.dispatcher.on(MutationDetailsEvents.TABLE_CHAIN_MOUSEOVER,C)),null!=U&&null!=q&&(U.toggleTableControls(),q.toggleView())}function w(){if(null!=U){var t=U.getSelectedChain();if(null!=t){var e=t.datum();q.selectChain(e.pdbId,e.chain.chainId),q.scrollToSelected()}}}function S(){z&&z.isVisible()&&z.refreshView()}function M(){z&&z.isVisible()&&z.refreshView()}function x(){z&&z.isVisible()&&(z.resetHighlight(),z.hideResidueWarning())}function I(t,e){j&&j.isHighlighted()?A():x()}function A(t,e){z&&z.isVisible()&&B()}function E(t,e){if(z&&z.isVisible()){var n=N();n.push(t),O(n,!0)}}function L(t,e){I(t,e)}function F(t){var e=V(t);e&&z&&z.isVisible()&&B()}function k(t){var e=V(t);e&&$(e.get("pdbMatch").pdbId,e.get("pdbMatch").chainId)}function V(t){var e=l.getMutationIdMap(),n=e[t];return n&&j&&(j.clearHighlights(),j.highlightMutation(n.get("mutationSid"))),n}function N(){var t=[];return j&&_.each(j.getSelectedElements(),function(e,n){t=t.concat(e.datum())}),t}function B(){var t=N();O(t)}function O(t,e){var n=z.highlightView(t,!0),i=t.length-n;e||(i>0?z.showResidueWarning(i,t.length):z.hideResidueWarning())}function $(e,n){var i=o.model.uniprotId;t.is3dPanelInitialized()||t.init3dPanel();var a=function(t){null==U&&P(t),null!=z&&null!=U&&t.length>0&&(R(),U.showView(),e&&n?U.selectChain(e,n):U.selectDefaultChain(),U.autoCollapse())};r.getPdbData(i,a)}function R(){if(j){var t=function(t,e,n){return j.mutationColorMap[t]};H.updateOptions({mutationColorMapper:t})}}var U=null,q=null,z=null,H=null,j=null,G=!1;u(),this.reset3dView=$,this.highlightSelected=B}function MutationDetailsController(t,e,n,i){function a(){t.dispatcher.on(MutationDetailsEvents.GENE_TAB_SELECTED,r),t.dispatcher.on(MutationDetailsEvents.GENE_TABS_CREATED,l),t.dispatcher.on(MutationDetailsEvents.VIS_3D_PANEL_INIT,o)}function o(t){var e=p.vis3d;if(e){var n={appOptions:{el:t||"#mutation_details"}},i=jQuery.extend(!0,{},n,e),a=new Mutation3dVis("default3dView",i);a.init(),s(a)}}function r(t){null==v[t]&&u(t,d,p)}function l(){t.$el.find(".mutation-3d-container").hide();var e=h.getGeneList();u(e[0],d,p)}function s(e){var n=t.$el.find(".mutation-3d-container");if(e){var i=new Mutation3dVisView({el:n,config:m.mutation3dVis,mut3dVis:e,pdbProxy:g,mutationProxy:h});i.render(),_=i,t.dispatcher.trigger(MutationDetailsEvents.VIS_3D_PANEL_CREATED,i)}else $(n).hide()}function u(i,a,o){var r=function(r,l){var s=h.getMutationUtil(),u="";r&&(u=r.metadata.identifier);var d={geneSymbol:i,mutationData:l,dataProxies:n,dataManager:e,uniprotId:u,sampleArray:a},p=new MainMutationView({el:"#mutation_details_"+cbio.util.safeProperty(i),config:m.mainMutation,model:d});t.dispatcher.trigger(MutationDetailsEvents.MAIN_VIEW_INIT,p),p.render(),v[i].mainMutationView=p,e.addView(i,p),null==l||0==l.length?p.showNoDataInfo():c(p,i,s,r,o)};h.getMutationData(i,function(t){v[i]={},null==t&&(t=[]);var n=h.getMutationUtil().dataFieldCount(i,"uniprotAcc",["NA"]),a=null,o={geneSymbol:i};n.length>0&&(a=n[0].uniprotAcc),a&&(o.uniprotAcc=a),f.getPfamData(o,function(n){var i=null;null==n?console.log("[warning] no pfam data found: %o",o):i=n[0],e.getData("variantAnnotation",{mutations:t},function(t,e){r(i,t.mutations)})})})}function c(n,i,a,o,r){function l(){if(s&&o){v=n.initMutationDiagramView(s,o);var t=null;h&&(t=h.mutationTable);var e=null;d&&(e=n.initMutationInfoView(d),new MutationInfoController(n)),new MutationDiagramController(v.mutationDiagram,t,e,a)}}var s=r.mutationDiagram,u=r.mutationTable,c=r.vis3d,d=r.infoPanel,p=r.mutationSummary,h=null;u&&(h=n.initMutationTableView(u),new MutationDetailsTableController(n,t));var f=null;p&&(f=n.initSummaryView(u));var v=null;if(a.containsProteinChange(i)?l():e.getData("variantAnnotation",{mutations:n.model.mutationData},function(t,e){l()}),new MainMutationController(n),c){var y=n.init3dView(null);b=new Mutation3dController(t,n,r,m,_,y,g,a,i),m.mutationDetails.activate3dOnInit&&b.reset3dView(m.mutationDetails.activate3dOnInit.pdbId,m.mutationDetails.activate3dOnInit.chain)}}var d=i.data.sampleList,p=i.view,m=i.render,h=n.mutationProxy,f=n.pfamProxy,g=n.pdbProxy,v={},_=null,b=null;a(),this.getMainView=function(t){return v[t]},this.get3dController=function(){return b},this.get3dVisView=function(){return _},this.getMainViews=function(){return v},this.getDataManager=function(){return e},this.getDataProxies=function(){return n}}function MutationDetailsTableController(t,e){function n(){t.diagramView?i(t.diagramView.mutationDiagram):t.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,i),t.infoView?a(t.infoView):t.dispatcher.on(MutationDetailsEvents.INFO_PANEL_INIT,a),e.dispatcher.on(MutationDetailsEvents.GENE_TAB_SELECTED,p)}function i(t){m=t,t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,r),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,l),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,s),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOVER,c),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_MOUSEOUT,d),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_RESET,o)}function a(t){t&&t.dispatcher.on(MutationDetailsEvents.INFO_PANEL_MUTATION_TYPE_SELECTED,u)}function o(){t.tableView&&t.tableView.resetFilters()}function r(){t.tableView&&(t.tableView.clearHighlights(),t.tableView.filter(PileupUtil.getPileupMutations(m.pileups)))}function l(e,n){if(t.tableView){t.tableView.clearHighlights();var i=[];m&&_.each(m.getSelectedElements(),function(t,e){i=i.concat(t.datum().mutations)}),i.length>0?t.tableView.filter(i):t.tableView.filter(PileupUtil.getPileupMutations(m.pileups))}}function s(e,n){if(t.tableView){t.tableView.clearHighlights();var i=[];m&&_.each(m.getSelectedElements(),function(t,e){i=i.concat(t.datum().mutations)}),t.tableView.filter(i)}}function u(e){if(null!==t.tableView){var n=t.infoView.currentMapByType[e];_.size(n)>0?t.tableView.filter(n):(n=t.infoView.initialMapByType[e],t.tableView.filter(n),t.tableView.clearSearchBox())}}function c(e,n){t.tableView&&t.tableView.highlight(e.mutations)}function d(e,n){t.tableView&&t.tableView.clearHighlights()}function p(e){if(t.tableView){var n=t.tableView.mutationTable.getDataTable();n.is(":visible")&&n.fnAdjustColumnSizing()}}var m=null;n()}function MutationDiagramController(t,e,n,i){function a(){e&&e.dispatcher.on(MutationDetailsEvents.MUTATION_TABLE_FILTERED,o),n&&n.dispatcher.on(MutationDetailsEvents.INFO_PANEL_MUTATION_TYPE_SELECTED,r)}function o(e){var n=[],i=[];try{i=$(e).DataTable().rows({filter:"applied"}).data()}catch(a){i=$(e).dataTable()._("tr",{filter:"applied"})}if(_.each(i,function(t,e){var i=t[0].mutation;i&&n.push(i)}),null!==t){var o=new MutationCollection(n);t.updatePlot(o)}}function r(e){if(null!==t){var i=n.currentMapByType[e];_.size(i)>0?t.updatePlot(new MutationCollection(i)):(i=n.initialMapByType[e],t.updatePlot(new MutationCollection(i)))}}a()}function MutationInfoController(t){function e(){t.diagramView?n(t.diagramView.mutationDiagram):t.dispatcher.on(MutationDetailsEvents.DIAGRAM_INIT,n)}function n(t){s=t,t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_RESET,r),t.dispatcher.on(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED,l),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_SELECTED,o),t.dispatcher.on(MutationDetailsEvents.LOLLIPOP_DESELECTED,a),t.dispatcher.on(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED,i)}function i(){l()}function a(e,n){if(t.infoView){var i=[];s&&_.each(s.getSelectedElements(),function(t,e){i=i.concat(t.datum())}),i.length>0?t.infoView.updateView(PileupUtil.getPileupMutations(i)):l()}}function o(t,e){a(t,e)}function r(){l()}function l(){t.infoView&&t.infoView.updateView(PileupUtil.getPileupMutations(s.pileups))}var s=null;e()}function MutationMapper(t){function e(){o.proxy.mutationProxy.options.geneList=o.data.geneList.join(" ");var t=DataProxyUtil.initDataProxies(o.proxy);o.dataManager=jQuery.extend(!0,{},o.dataManager,{dataProxies:t});var e=new MutationDataManager(o.dataManager),a={mutationProxy:t.mutationProxy},r={el:o.el,config:o.render.mutationDetails,model:a},l=new MutationDetailsView(r);n=l;var s=new MutationDetailsController(l,e,t,o);i=s,l.render()}var n=null,i=null,a={el:"#mutation_details",data:{geneList:[],sampleList:[]},view:{mutationDiagram:{},mutationTable:{},mutationSummary:{},pdbPanel:{},pdbTable:{},infoPanel:{},vis3d:{}},render:{mutationDetails:{init:null,format:null,activate3dOnInit:!1},mainMutation:{},pdbPanel:{},mutation3dVis:{}},proxy:{pfamProxy:{instance:null,instanceClass:PfamDataProxy,options:{data:{}}},variantAnnotationProxy:{instance:null,instanceClass:VariantAnnotationDataProxy,options:{data:{}}},mutationProxy:{instance:null,instanceClass:MutationDataProxy,options:{data:{},params:{},geneList:""}},clinicalProxy:{instance:null,instanceClass:ClinicalDataProxy,options:{data:{}}},pdbProxy:{instance:null,instanceClass:PdbDataProxy,options:{data:{pdbData:{},infoData:{},summaryData:{},positionData:{}},mutationUtil:{}}},pancanProxy:{instance:null,instanceClass:PancanMutationDataProxy,options:{data:{byKeyword:{},byProteinChange:{},byProteinPosition:{},byGeneSymbol:{}}}},mutationAlignerProxy:{instance:null,instanceClass:MutationAlignerDataProxy,options:{data:{}}},portalProxy:{instance:null,instanceClass:PortalDataProxy,options:{data:{}}}},dataManager:{dataFn:{},dataProxies:{}}},o=jQuery.extend(!0,{},a,t);this.init=e,this.getView=function(){return n},this.getController=function(){return i}}var DataTableUtil=function(){function t(t){var e={};return _.each(t,function(t,n){null==e[t]&&(e[t]=n)}),e}function e(t){var e={};return _.each(_.pairs(t),function(t,n){var i=t[0],a=t[1];null!=a.sTitle&&a.sTitle.length>0&&(e[a.sTitle]=i)}),e}function n(t,e){var n={};return _.each(t,function(t,i){null==n[t]&&(_.isFunction(e)?n[t]=e(t):n[t]="hidden")}),n}function i(t,e){var n={};return _.each(t,function(t,i){null==n[t]&&(n[t]=_.isFunction(e)&&e(t))}),n}function a(t,e,n){var i=[];return _.each(t,function(t,a){"visible"!=n[t]&&i.push(e[t])}),i}function o(t,e,n){var i=[];return _.each(t,function(t,a){"excluded"==n[t]&&i.push(e[t])}),i}function r(t,e,n){var i=[];return _.each(t,function(t,a){n[t]===!1&&i.push(e[t])}),i}function l(t,e){var n=[];return _.each(_.pairs(t),function(t){var i=t[0],a=t[1],o=e[i];if(null!=o){var r={fnRender:function(t){var n=t.aData[e.datum];return a(t,n)},aTargets:[o]};n.push(r)}}),n}function s(t,e,n,i,a){var o={};return _.each(_.pairs(e),function(e){var a=e[0],r=e[1],l=n[a],s=i[a],u=t[a],c=function(t){return null!=l?l(t):r(t)};if(null!=u){var d={mData:function(e,n,i){var a=e[t.datum];return"set"===n?null:"display"===n?r(a):"sort"===n?c(a):"filter"===n?null!=s?s(a):c(a):e[u]},aTargets:[u]};o[a]=d}}),_.each(_.pairs(a),function(e){var n=e[0],i=e[1],a=t[n],r={mData:function(e,n,a){return i(e,n,a,t)},aTargets:[a]};o[n]=r}),_.values(o)}function u(t,e){var n=[];return _.each(_.pairs(t),function(t){var i=t[0],a=t[1],o=e[i];o>0&&(n[o]=a)}),n}function c(t){var e=$(t).attr("alt"),n=parseFloat(e);return isNaN(n)&&(n=""),n}function d(t){return-1!=t.indexOf("label")?$(t).find("label").text().trim()||$(t).text().trim():-1}function p(t){return-1!=t.indexOf("label")?parseInt($(t).text()):-1}function m(t){return-1!=t.indexOf("label")?parseFloat($(t).text()):-1}function h(t,e,n,i){return n>=0?i>=0?n==i?0:i>n?-1:1:-1:i>=0?1:t==e?0:e>t?1:-1}function f(t,e,n,i){return n>=0?i>=0?n==i?0:i>n?1:-1:-1:i>=0?1:t==e?0:e>t?-1:1}return{buildColumnIndexMap:t,buildColumnNameMap:e,buildColumnVisMap:n,buildColumnSearchMap:i,getHiddenColumns:a,getExcludedColumns:o,getNonSearchableColumns:r,getColumnOptions:u,getColumnRenderers:l,getColumnData:s,compareSortAsc:h,compareSortDesc:f,getAltTextValue:c,getLabelTextValue:d,getLabelTextIntValue:p,getLabelTextFloatValue:m}}(),MutationViewsUtil=function(){function t(t,e,n,i){var a=new MutationMapper(e),o=!1;return $(t).is(":visible")&&(a.init(),o=!0),$(n).bind("tabsactivate",function(t,e){e.newTab.text().trim().toLowerCase()==i.toLowerCase()&&(o?a.getView().refreshGenesTab():(a.init(),o=!0))}),a}function e(){return{mutationType:r,validationStatus:l,mutationStatus:s,omaScore:u,cna:c}}function n(){return{content:{attr:"alt"},show:{event:"mouseover"},hide:{fixed:!0,delay:100,event:"mouseout"},style:{classes:"mutation-details-tooltip qtip-shadow qtip-light qtip-rounded"},position:{my:"top left",at:"bottom right",viewport:$(window)}}}function i(t){t=t||"images/ajax-loader.gif";var e={loaderImage:t,width:15,height:15},n=BackboneTemplateCache.getTemplateFn("mutation_table_placeholder_template");return n(e)}function a(t,e,n){var i=t.fnGetData();_.each(i,function(i,a){t.fnUpdate(null,a,e[n],!1,!1)}),i.length>0&&t.fnUpdate(null,0,e[n])}var o={missense:{label:"Missense",longName:"Missense",style:"missense_mutation",mainType:"missense",priority:1},inframe:{label:"IF",longName:"In-frame",style:"inframe_mutation",mainType:"inframe",priority:2},truncating:{label:"Truncating",longName:"Truncating",style:"trunc_mutation",mainType:"truncating",priority:4},nonsense:{label:"Nonsense",longName:"Nonsense",style:"trunc_mutation",mainType:"truncating",priority:6},nonstop:{label:"Nonstop",longName:"Nonstop",style:"trunc_mutation",mainType:"truncating",priority:7},nonstart:{label:"Nonstart",longName:"Nonstart",style:"trunc_mutation",mainType:"truncating",priority:8},frameshift:{label:"FS",longName:"Frame Shift",style:"trunc_mutation",mainType:"truncating",priority:4},frame_shift_del:{label:"FS del",longName:"Frame Shift Deletion",style:"trunc_mutation",mainType:"truncating",priority:4},frame_shift_ins:{label:"FS ins",longName:"Frame Shift Insertion",style:"trunc_mutation",mainType:"truncating",priority:5},in_frame_ins:{label:"IF ins",longName:"In-frame Insertion",style:"inframe_mutation",mainType:"inframe",priority:3},in_frame_del:{label:"IF del",longName:"In-frame Deletion",style:"inframe_mutation",mainType:"inframe",priority:2},splice_site:{label:"Splice",longName:"Splice site",style:"trunc_mutation",mainType:"truncating",priority:9},fusion:{label:"Fusion",longName:"Fusion",style:"fusion",mainType:"other",priority:10},other:{style:"other_mutation",mainType:"other",priority:11}},r={missense_mutation:o.missense,missense:o.missense,missense_variant:o.missense,frame_shift_ins:o.frame_shift_ins,frame_shift_del:o.frame_shift_del,frameshift:o.frameshift,frameshift_deletion:o.frame_shift_del,frameshift_insertion:o.frame_shift_ins,de_novo_start_outofframe:o.frameshift,frameshift_variant:o.frameshift,nonsense_mutation:o.nonsense,nonsense:o.nonsense,stopgain_snv:o.nonsense,splice_site:o.splice_site,splice:o.splice_site,"splice site":o.splice_site,splicing:o.splice_site,splice_site_snp:o.splice_site,splice_site_del:o.splice_site,splice_site_indel:o.splice_site,translation_start_site:o.nonstart,start_codon_snp:o.nonstart,start_codon_del:o.nonstart,nonstop_mutation:o.nonstop,in_frame_del:o.in_frame_del,in_frame_ins:o.in_frame_ins,indel:o.in_frame_del,nonframeshift_deletion:o.inframe,nonframeshift:o.inframe,"nonframeshift insertion":o.inframe,nonframeshift_insertion:o.inframe,targeted_region:o.inframe,inframe:o.inframe,truncating:o.truncating,fusion:o.fusion,other:o.other},l={valid:{label:"V",style:"valid",tooltip:"Valid"},validated:{label:"V",style:"valid",tooltip:"Valid"},wildtype:{label:"W",style:"wildtype",tooltip:"Wildtype"},unknown:{label:"U",style:"unknown",tooltip:"Unknown"},not_tested:{label:"U",style:"unknown",tooltip:"Unknown"},none:{label:"U",style:"unknown",tooltip:"Unknown"},na:{label:"U",style:"unknown",tooltip:"Unknown"}},s={somatic:{label:"S",style:"somatic",tooltip:"Somatic"},germline:{label:"G",style:"germline",tooltip:"Germline"},unknown:{label:"U",style:"unknown",tooltip:"Unknown"},none:{label:"U",style:"unknown",tooltip:"Unknown"},na:{label:"U",style:"unknown",tooltip:"Unknown"}},u={h:{label:"High",style:"oma_high",tooltip:"High"},m:{label:"Medium",style:"oma_medium",tooltip:"Medium"},l:{label:"Low",style:"oma_low",tooltip:"Low"},n:{label:"Neutral",style:"oma_neutral",tooltip:"Neutral"}},c={"-2":{label:"DeepDel",style:"cna-homdel",tooltip:"Deep deletion"},"-1":{label:"ShallowDel",style:"cna-hetloss",tooltip:"Shallow deletion"},0:{label:"Diploid",style:"cna-diploid",tooltip:"Diploid / normal"},1:{label:"Gain",
+style:"cna-gain",tooltip:"Low-level gain"},2:{label:"AMP",style:"cna-amp",tooltip:"High-level amplification"},unknown:{label:"NA",style:"cna-unknown",tooltip:"CNA data is not available for this gene"}};return{initMutationMapper:t,renderTablePlaceHolder:i,refreshTableColumn:a,defaultTableTooltipOpts:n,getVisualStyleMaps:e}}(),MutationDetailsTableFormatter=function(){function t(t){return e(E,t)}function e(t,e){var n,i,a;return null!=t[e]?(n=t[e].style,i=t[e].label,a=t[e].tooltip):(n=t.unknown.style,i=t.unknown.label,a=t.unknown.tooltip),{style:n,tip:a,text:i}}function n(t){var e=16,n=t,i="",a=t;return null!=t&&t.length>e+2&&(n=t.substring(0,e)+"...",i="simple-tip"),{style:i,tip:a,text:n}}function i(t){return a(M,t)}function a(t,e){var n,i;return null!=e&&(e=e.toLowerCase()),null!=t[e]?(n=t[e].style,i=t[e].label):(n=t.other.style,i=e),{style:n,text:i}}function o(t){return r(I,t)}function r(t,e){var n="simple-tip",i=e,a="";return null!=e&&(e=e.toLowerCase()),null!=t[e]&&(n=t[e].style,i=t[e].label,a=t[e].tooltip),{style:n,tip:a,text:i}}function l(t){return s(x,t)}function s(t,e){var n,i,a;return null!=e&&(e=e.toLowerCase()),null!=t[e]?(n=t[e].style,i=t[e].label,a=t[e].tooltip):(n=t.unknown.style,i=t.unknown.label,a=t.unknown.tooltip),{style:n,tip:a,text:i}}function u(t,e){return c(A,t,e)}function c(t,e,n){var i="",a="",o="",r="";return null!=e&&(e=e.toLowerCase()),null!=t[e]&&(r=t[e].tooltip,null!=n&&(r=n.toFixed(2)),i=t[e].label,a=t[e].style,o="oma_link"),{fisClass:a,omaClass:o,value:r,text:i}}function d(t,e,n,i){var a="NA",o=e+n,r="",l="";return t&&(r="mutation_table_allele_freq",a=t.toFixed(2),l=i),{text:a,total:o,style:r,tipClass:l}}function p(t){return h(t.get("pdbMatch"))}function m(t){return h(t.get("igvLink"))}function h(t){return t?"#":""}function f(t){var e="mutation-table-protein-change",n="click to highlight the position on the diagram",i="";return null!=t.get("aminoAcidChange")&&t.get("aminoAcidChange").length>0&&"NA"!==t.get("aminoAcidChange")&&null!=t.get("cancerStudyShort")&&-1!=t.get("cancerStudyShort").toLowerCase().indexOf("msk-impact")&&g(t.get("proteinChange"),t.get("aminoAcidChange"))&&(i="The original annotation file indicates a different value: "+v(t.get("aminoAcidChange"))+""),{text:v(t.get("proteinChange")),style:e,tip:n,additionalTip:i}}function g(t,e){var n=!1;if(t=v(t),e=v(e),e!==t){var i=t.match(/[A-Z]/g),a=e.match(/[A-Z]/g),o=t.match(/[0-9]+/),r=e.match(/[0-9]+/),l=t.match(/([a-z]+)/),s=e.match(/([a-z]+)/);o&&r&&o.length>0&&r.length>0&&o[0]!=r[0]?n=!0:i&&a&&i.length>0&&a.length>0&&"X"!==i[0]&&"X"!==a[0]&&i[0]!==a[0]?n=!0:i&&a&&i.length>1&&a.length>1&&i[1]!==a[1]?n=!0:l&&s&&l.length>0&&s.length>0&&l[0]!==s[0]&&(n=!0)}return n}function v(t){var e="p.";return-1!=t.indexOf(e)&&(t=t.substr(t.indexOf(e)+e.length)),t}function _(t){var e="tumor_type",n="";return{text:t.get("tumorType"),style:e,tip:n}}function b(t){var e="",n="";return t>0&&(e="mutation_table_cosmic",n=t),{style:e,count:n}}function y(t){var e="",n="";return t>0&&(e="mutation_table_cbio_portal",n=t),{style:e,frequency:n}}function T(t){var e=t,n="mutation_table_int_value";return null==t&&(e="NA",n=""),{text:e,style:n}}function C(t){var e=t,n="mutation_table_allele_count";return null==t&&(e="NA",n=""),{text:e,style:n}}function P(t,e){var n;return null!=t&&(t=t.toLowerCase()),n="low"==t||"l"==t?2:"medium"==t||"m"==t?3:"high"==t||"h"==t?4:"neutral"==t||"n"==t?1:-1,n>0&&!isNaN(e)&&(n+=e/1e3),n}function D(t){var e=parseInt(t);return isNaN(e)&&(e=-(1/0)),e}function w(t){var e=parseFloat(t);return isNaN(e)&&(e=-(1/0)),e}var S=MutationViewsUtil.getVisualStyleMaps(),M=S.mutationType,x=S.validationStatus,I=S.mutationStatus,A=S.omaScore,E=S.cna;return{getCaseId:n,getProteinChange:f,getPdbMatchLink:p,getIgvLink:m,getAlleleCount:C,getAlleleFreq:d,getCNA:t,getMutationType:i,getMutationStatus:o,getValidationStatus:l,getFis:u,getTumorType:_,getCosmic:b,getCbioPortal:y,getIntValue:T,assignValueToPredictedImpact:P,assignIntValue:D,assignFloatValue:w}}(),PileupUtil=function(){function t(t){var e=t.mutations,n={};return _.each(e,function(t){var e=t.get("mutationType")||"";e=e.trim().toLowerCase(),void 0==n[e]&&(n[e]=[]),n[e].push(t)}),n}function e(e){var n=t(e),i=[];return _.each(_.keys(n),function(t){i.push({type:t,count:n[t].length})}),i.sort(function(t,e){return e.count-t.count}),i}function n(e){var n=MutationViewsUtil.getVisualStyleMaps().mutationType,i=t(e),a=[],o={};return _.each(_.keys(i),function(t){var e=void 0;null!=n[t]&&(e=n[t].mainType),void 0==e&&(e=n.other.mainType),void 0==o[e]&&(o[e]=0),o[e]+=i[t].length}),_.each(_.keys(o),function(t){a.push({type:t,count:o[t],priority:n[t].priority})}),a.sort(function(t,e){return e.count===t.count?e.priority-t.priority:e.count-t.count}),a}function i(){return d++,"pileup_"+d}function a(t){var e={};return _.each(t,function(t){_.each(t.mutations,function(n){e[n.get("mutationSid")]=t.pileupId})}),e}function o(t,e){t=l(t);for(var n={},i=0;i0&&(e[t.get("proteinChange")]=t.get("proteinChange"))});var n=_.keys(e).sort(),i="";n.length>1&&(i=cbio.util.lcss(n[0],n[n.length-1]));var a=i;return _.each(n,function(t){a+=t.substring(i.length)+"/"}),a.substring(0,a.length-1)}function u(t){var e=0;return _.each(t,function(t){e+=t.count}),e}function c(t){var e=[];return _.each(t,function(t){e=e.concat(t.get("mutations")||[])}),e}var d=0;return{nextId:i,mapToMutations:a,convertToPileups:o,initPileup:r,countMutations:u,getPileupMutations:c,getMutationTypeMap:t,groupMutationsByType:e,groupMutationsByMainType:n}}(),BackboneTemplateCache=function(){function t(t){return _.template($("#"+t).html())}function e(e){var i=n[e];return null==i&&(i=t(e),n[e]=i),i}var n={};return{getTemplateFn:e}}(),DataProxyUtil=function(){function t(t){var n={};return _.each(_.keys(t).sort(),function(i){var a=t[i],o=null;o="pdbProxy"==i?e(a,function(t){var e=n.mutationProxy;return null!=e&&e.hasData()?(t.options.mutationUtil=e.getMutationUtil(),!0):!1}):e(a),n[i]=o}),n}function e(t,e){var n=t.instance;if(null==n){if(null!=e&&_.isFunction(e)&&!e(t))return null;var i=t.instanceClass;n=new i(t.options),n.init()}return n}return{initDataProxies:t,initDataProxy:e}}();JmolScriptGenerator.prototype=new MolScriptGenerator,JmolScriptGenerator.prototype.constructor=JmolScriptGenerator,Mol3DScriptGenerator.prototype=new MolScriptGenerator,Mol3DScriptGenerator.prototype.constructor=Mol3DScriptGenerator;var MutationDetailsUtil=function(t){var e="germline",n="valid",i={},a={},o={},r={},l={},s={},u=[];this.getMutationGeneMap=function(){return i},this.getMutationCaseMap=function(){return a},this.getMutationIdMap=function(){return o},this.getMutations=function(){return u},this.processMutationData=function(t){i=this._updateGeneMap(t),a=this._updateCaseMap(t),o=this._updateIdMap(t),r=this._updateKeywordMap(t),l=this._updateProteinChangeMap(t),s=this._updateProteinPosStartMap(t),u=u.concat(t.models)},this.getProteinPositions=function(t){var e=i[t],n=[];if(null!=e)for(var a=0;a0&&(void 0!==t.numGermlineCases&&t.numGermlineCases>0&&(i=t.numGermlineCases),e=t.numGermline/i*100,n+="Germline Mutation Rate: "+e.toFixed(1)+"%, "),e=t.numSomatic/t.numCases*100,n+="Somatic Mutation Rate: "+e.toFixed(1)+"%]"},this.countMutations=function(t,n){for(var i=n.length,o=0,r=0,l=0,s=0;s0})},this.containsRefAllele=function(t){return this._contains(t,function(t){return t.get("referenceAllele")&&"NA"!=t.get("referenceAllele")})},this.containsVarAllele=function(t){return this._contains(t,function(t){return t.get("variantAllele")&&"NA"!=t.get("variantAllele")})},this.containsEndPos=function(t){return this._contains(t,function(t){return t.get("endPos")&&t.get("endPos")>0})},this.containsFis=function(t){return this._contains(t,function(t){return t.get("functionalImpactScore")&&"NA"!=t.get("functionalImpactScore")})},this.containsCosmic=function(t){return this._contains(t,function(t){return t.get("cosmic")&&t.getCosmicCount()&&t.getCosmicCount()>0})},this.containsMutationType=function(t){return this._contains(t,function(t){return t.get("mutationType")&&"NA"!=t.get("mutationType")})},this.containsMutationCount=function(t){return this._contains(t,function(t){return t.get("mutationCount")&&t.get("mutationCount")>0})},this.containsKeyword=function(t){return this._contains(t,function(t){return t.get("keyword")&&"NA"!=t.get("keyword")})},this.containsMutationEventId=function(t){return this._contains(t,function(t){return t.get("mutationEventId")&&"NA"!=t.get("mutationEventId")})},this.distinctTumorTypeCount=function(t){t=t.toUpperCase();var e=i[t],n={};if(null!=e)for(var a=0;ae.pdbId?-1:1),n});var e=null,n=[],i={};return _.each(t,function(t,n){e=new PdbAlignmentModel(t),void 0==i[e.pdbId]&&(i[e.pdbId]={}),void 0==i[e.pdbId][e.chain]&&(i[e.pdbId][e.chain]=[]),i[e.pdbId][e.chain].push(e)}),_.each(_.keys(i),function(t){var e=[];_.each(_.keys(i[t]),function(n){var a=new PdbChainModel({chainId:n,alignments:i[t][n]});e.push(a)});var a=new PdbModel({pdbId:t,chains:e});n.push(a)}),new PdbCollection(n)}function e(t){var e=[],n=t.midlineAlign,i=t.uniprotAlign,a=t.pdbAlign;if(n.length===i.length&&n.length===a.length)for(var o=0;o0?(i+=t[0].alignmentString,a=t[0].uniprotTo,e=t[0],_.each(t,function(t,n){var o=t.uniprotFrom-a-1,r=t.alignmentString;if(0==o)i+=r;else if(o>0){for(var l=[],s=0;o>s;s++)l.push(C);l.push(r),i+=l.join("")}else{var u=[],c=Math.min(-1*o,r.length);u.push(i.substr(i.length+o,c)),u.push(r.substr(0,c)),u[0]!=u[1]&&(console.log("[warning] alignment mismatch: "+e.alignmentId+" & "+t.alignmentId),console.log(u[0]),console.log(u[1])),i+=r.substr(-1*o)}a=Math.max(a,t.uniprotTo),a==t.uniprotTo&&(e=t)}),n.uniprotFrom=t[0].uniprotFrom,n.uniprotTo=n.uniprotFrom+i.length,n.pdbFrom=t[0].pdbFrom,n.mergedString=i,n.identityPerc=u(i),n.identity=c(i),n):n}function r(t,e){var n=null,i=t.getProteinStartPos(),a=t.get("mutationType")||"";if(a=a.trim().toLowerCase(),null==i||"fusion"===a)return n;for(var o=0;o=c.uniprotFrom&&i<=c.uniprotTo;if(d&&s(c,i)){n={pdbId:u.pdbId,chainId:u.chain.chainId};break}}if(n)break}return n}function l(t,e){return e?(_.each(t,function(t,n){if(null==t)return void console.log("warning [processMutationData]: mutation (at index %d) is null.",n);var i=PdbDataUtil.mutationToPdb(t,e);t.set({pdbMatch:i})}),t):t}function s(t,e){var n=e-t.uniprotFrom,i=t.mergedString[n],a=i==C;return!a}function u(t){for(var e=0,n=0,i=0;i0){for(var a=!1,o=0;o0&&n[0].sort(function(t,e){return e.chain.mergedAlignment.mergedString.length-t.chain.mergedAlignment.mergedString.length}),n}function p(t,e){var n=!0;return(t.mergedAlignment.uniprotFrom>=e.mergedAlignment.uniprotTo||e.mergedAlignment.uniprotFrom>=t.mergedAlignment.uniprotTo)&&(n=!1),n}function m(t){var e=[];return t.each(function(t,n){t.chains.each(function(n,i){var a={pdbId:t.pdbId,chain:n};e.push(a)})}),h(e,[g,b,v,y,T]),e}function h(t,e){t.sort(function(t,n){for(var i=0,a=0;at.pdbId?-1:e.pdbIdt.chain.chainId?-1:e.chain.chainId0&&(r=r.substring(n.length),l=l.substring(n.length),t+=n.length,e+=n.length,a=t.toString(),o=e.toString())}}var n=void 0,i=t.chr,a=t.startPos,o=t.endPos,r=t.referenceAllele,l=t.variantAllele;return _.isFunction(t.get)&&(i=t.get("chr"),a=t.get("startPos"),o=t.get("endPos"),r=t.get("referenceAllele"),l=t.get("variantAllele")),null!=r&&r===l&&console.log("[VariantAnnotationUtil.generateVariantKey] Warning: Reference allele ("+r+") for "+i+":"+a+"-"+o+" is the same as variant allele"),i&&a&&r&&l&&(e(),n=i+":g."+a+r+">"+l,o&&("-"===r||0===r.length?n=i+":g."+o+"_"+a+"ins"+l:("-"===l||0===l.length)&&(n=i+":g."+a+"_"+o+"del"+r))),n}return{generateVariantKey:i,addAnnotationData:t}}(),VepParser=function(){function t(t){var i={};if(!t)return console.log("[warning] VEP parser error"),{};if(t.error)return console.log("[warning] VEP parser error: "+t.error),{};var o=t.allele_string,l=o.split("/",-1);2===l.length&&(i.referenceAllele=l[0],i.variantType=a(l[0],l[1])),i.ncbiBuildNo=t.assembly_name,i.chr=t.seq_region_name,i.startPos=t.start,i.endPos=t.end,i.strand=r(t.strand);var s=t.transcript_consequences,u=t.most_severe_consequence;i.transcripts=[],_.each(s,function(t,n){i.transcripts.push(e(t,u,i.variantType))});var c=n(s,u);return c&&i.transcripts[c.index]&&(i.canonicalTranscript=i.transcripts[c.index]),i.rawData=t,i}function e(t,e,n,i){i=i||{},i.geneSymbol=t.gene_symbol;var a=t.consequence_terms;if(null!=a&&a.length>0){var r=o(a[0]);"Frame_Shift"===r&&(null!=n&&"INS"===n?r+="_Ins":"DEL"===n&&(r+="_Del")),i.variantClassification=r}var s=t.refseq_transcript_ids;null!=s&&s.length>0&&(i.refseqIds=s);var u=t.hgvsc;null!=u&&(i.hgvsc=u.substr(u.indexOf(":")+1));var c=t.hgvsp;null!=c&&(i.hgvsp=c.substr(c.indexOf(":")+1)),i.transcriptId=t.transcript_id,i.proteinPosStart=t.protein_start,i.proteinPosEnd=t.protein_end,i.codons=t.codons;var d;if(null!=c&&(d=c.substr(c.indexOf(":")+1),_.each(_.pairs(l),function(t,e){d=d.replace(new RegExp(t[0],"g"),t[1])}),i.hgvspShort=d),("splice_acceptor_variant"===e||"splice_donor_variant"===e)&&i.hgvsc){var p=/c\.([0-9]+)*/.exec(i.hgvsc);if(p&&2==p.length){var m=parseInt(p[1]);1>m&&(m=1);var h=m+m%3/3;i.hgvspShort="p.X"+h+"_splice"}}return"synonymous_variant"===e&&(d="p."+t.amino_acids+t.protein_start+t.amino_acids,i.hgvspShort=d),i.mutationType=i.variantClassification,i.proteinChange=i.hgvspShort,i.refseqIds&&i.refseqIds.length>0&&(i.refseqMrnaId=i.refseqIds[0]),i}function n(t,e){var n=[];return _.each(t,function(t,e){1==t.canonical&&n.push({index:e,transcript:t})}),1===n.length?n[0]:n.length>1?i(n,e):(_.each(t,function(t,e){n.push({index:e,transcript:t})}),i(n,e))}function i(t,e){var n=null;return _.each(t,function(t,i){var a=t.transcript.consequence_terms;null==n&&null!=a&&null!=e&&_.each(a,function(i,a){i.trim().toLowerCase()===e.trim().toLowerCase()&&(n=t)})}),n}function a(t,e){var n=t.length,i=e.length;if(n="-"===t?0:n,i="-"===e?0:i,n===i){var a=["SNP","DNP","TNP"];return 3>n?a[n-1]:"ONP"}return i>n?"INS":"DEL"}function o(t){return s[t.toLowerCase()]}function r(t){var e;return e=null==t||"+"===t||"-"===t?t:0>t?"-":t>0?"+":t}var l={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Asx:"B",Cys:"C",Glu:"E",Gln:"Q",Glx:"Z",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V",Xxx:"X",Ter:"*"},s={splice_acceptor_variant:"Splice_Site",splice_donor_variant:"Splice_Site",transcript_ablation:"Splice_Site",stop_gained:"Nonsense_Mutation",frameshift_variant:"Frame_Shift",stop_lost:"Nonstop_Mutation",initiator_codon_variant:"Translation_Start_Site",start_lost:"Translation_Start_Site",inframe_insertion:"In_Frame_Ins",inframe_deletion:"In_Frame_Del",missense_variant:"Missense_Mutation",protein_altering_variant:"Missense_Mutation",coding_sequence_variant:"Missense_Mutation",conservative_missense_variant:"Missense_Mutation",rare_amino_acid_variant:"Missense_Mutation",transcript_amplification:"Intron",splice_region_variant:"Intron",intron_variant:"Intron",INTRAGENIC:"Intron",intragenic_variant:"Intron",incomplete_terminal_codon_variant:"Silent",synonymous_variant:"Silent",stop_retained_variant:"Silent",NMD_transcript_variant:"Silent",mature_miRNA_variant:"RNA",non_coding_exon_variant:"RNA",non_coding_transcript_exon_variant:"RNA",non_coding_transcript_variant:"RNA",nc_transcript_variant:"RNA","5_prime_UTR_variant":"5'UTR","5_prime_UTR_premature_start_codon_gain_variant":"5'UTR","3_prime_UTR_variant":"3'UTR",TF_binding_site_variant:"IGR",regulatory_region_variant:"IGR",regulatory_region:"IGR",intergenic_variant:"IGR",intergenic_region:"IGR",upstream_gene_variant:"5'Flank",downstream_gene_variant:"3'Flank",TFBS_ablation:"Targeted_Region",TFBS_amplification:"Targeted_Region",regulatory_region_ablation:"Targeted_Region",regulatory_region_amplification:"Targeted_Region",feature_elongation:"Targeted_Region",feature_truncation:"Targeted_Region"};return{parseJSON:t}}(),MutationModel=Backbone.Model.extend({_initialize:function(t){this.mutationId=t.mutationId,this.mutationSid=t.mutationSid,this.geneticProfileId=t.geneticProfileId,this.mutationEventId=t.mutationEventId,this.caseId=t.caseId,this.geneSymbol=t.geneSymbol,this.linkToPatientView=t.linkToPatientView,this.cancerType=t.cancerType,this.cancerStudy=t.cancerStudy,this.cancerStudyShort=t.cancerStudyShort,this.cancerStudyLink=t.cancerStudyLink,this.tumorType=t.tumorType,this.proteinChange=t.proteinChange,this.aminoAcidChange=t.aminoAcidChange,this.mutationType=t.mutationType,this.cosmic=t.cosmic,this.cosmicCount=this.calcCosmicCount(t.cosmic),this.functionalImpactScore=t.functionalImpactScore,this.fisValue=t.fisValue,this.msaLink=t.msaLink,this.xVarLink=t.xVarLink,this.pdbLink=t.pdbLink,this.pdbMatch=t.pdbMatch,this.igvLink=t.igvLink,this.mutationStatus=t.mutationStatus,this.validationStatus=t.validationStatus,this.sequencingCenter=t.sequencingCenter,this.ncbiBuildNo=t.ncbiBuildNo,this.chr=t.chr,this.startPos=t.startPos,this.endPos=t.endPos,this.referenceAllele=t.referenceAllele,this.variantAllele=t.variantAllele,this.tumorFreq=t.tumorFreq,this.normalFreq=t.normalFreq,this.tumorRefCount=t.tumorRefCount,this.tumorAltCount=t.tumorAltCount,this.normalRefCount=t.normalRefCount,this.normalAltCount=t.normalAltCount,this.canonicalTranscript=t.canonicalTranscript,this.refseqMrnaId=t.refseqMrnaId,this.codonChange=t.codonChange,this.uniprotId=t.uniprotId,this.uniprotAcc=t.uniprotAcc,this.proteinPosStart=t.proteinPosStart,this.proteinPosEnd=t.proteinPosEnd,this.mutationCount=t.mutationCount,this.specialGeneData=t.specialGeneData,this.keyword=t.keyword,this.cna=t.cna,this.myCancerGenome=t.myCancerGenome,this.isHotspot=t.isHotspot},url:function(){},getProteinStartPos:function(){var t=this.get("proteinPosStart");return(null==t||0==t.length||"NA"==t||0>t)&&(t=this.getProteinChangeLocation()),t},getProteinChangeLocation:function(){var t=null,e=null,n=this.get("proteinChange");return null!=n&&(e=n.match(/[0-9]+/)),e&&e.length>0&&(t=e[0]),t},getCosmicCount:function(){if(this.get("cosmicCount"))return this.get("cosmicCount");if(this.get("cosmic")){var t=this.calcCosmicCount(this.get("cosmic"));return this.set({cosmicCount:t}),t}return null},calcCosmicCount:function(t){var e=0;return t&&t.forEach(function(t){e+=t[2]}),e}}),MutationCollection=Backbone.Collection.extend({model:MutationModel,initialize:function(t){},parse:function(t){},url:function(){}}),PdbAlignmentModel=Backbone.Model.extend({initialize:function(t){this.alignmentId=t.alignmentId,this.pdbId=t.pdbId,this.chain=t.chain,this.uniprotId=t.uniprotId,this.pdbFrom=t.pdbFrom,this.pdbTo=t.pdbTo,this.uniprotFrom=t.uniprotFrom,this.uniprotTo=t.uniprotTo,this.alignmentString=t.alignmentString||PdbDataUtil.alignmentString(t),this.eValue=t.eValue,this.identityPerc=t.identityPerc}}),PdbAlignmentCollection=Backbone.Collection.extend({model:PdbAlignmentModel,initialize:function(t){}}),PdbChainModel=Backbone.Model.extend({initialize:function(t){this.chainId=t.chainId,this.positionMap=t.positionMap,this.alignments=new PdbAlignmentCollection(t.alignments),this.mergedAlignment=PdbDataUtil.mergeAlignments(t.alignments)}}),PdbChainCollection=Backbone.Collection.extend({model:PdbChainModel,initialize:function(t){}}),PdbModel=Backbone.Model.extend({initialize:function(t){this.pdbId=t.pdbId,this.chains=new PdbChainCollection(t.chains)}}),PdbCollection=Backbone.Collection.extend({model:PdbModel,initialize:function(t){}}),Pileup=Backbone.Model.extend({initialize:function(t){this.pileupId=t.pileupId,this.mutations=t.mutations,this.count=t.count,this.location=t.location,this.label=t.label,this.stats=t.stats}}),CosmicTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){this.$el.find(".cosmic-details-table").dataTable({aaSorting:[[2,"desc"]],sDom:"pt",aoColumnDefs:[{mRender:function(t,e,n){return''+t+""},aTargets:[0]},{sType:"aa-change-col",sClass:"left-align-td",aTargets:[1]},{sType:"numeric",sClass:"left-align-td",aTargets:[2]}],bDestroy:!1,bPaginate:!0,bJQueryUI:!0,bFilter:!1})},_parseCosmic:function(t){var e=[];return t.forEach(function(t){e.push(t[0]+""+t[1]+" | "+t[2])})," | "+e.join(" |
")+" |
"},compileTemplate:function(){var t=this._parseCosmic(this.model.cosmic),e={cosmicDataRows:t,cosmicTotal:this.model.total,mutationKeyword:this.model.keyword},n=BackboneTemplateCache.getTemplateFn("mutation_details_cosmic_tip_template");return n(e)}}),LollipopTipStatsView=Backbone.View.extend({initialize:function(){},render:function(){var t=BackboneTemplateCache.getTemplateFn("mutation_details_lollipop_tip_stats_template"),e=this.$el.find("table tbody");return _.each(this.model,function(n){e.append(t(n))}),this}}),LollipopTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){},showStats:!1,setShowStats:function(t){this.showStats=t},getShowStats:function(t){return this.showStats},compileTemplate:function(){var t=this.model,e=t.count>1?"mutations":"mutation",n={count:t.count,mutationStr:e,label:t.label},i=BackboneTemplateCache.getTemplateFn("mutation_details_lollipop_tip_template"),a=$(i(n)),o=a.find(".lollipop-stats");return this.showStats?(new LollipopTipStatsView({el:o,model:t.stats}).render(),o.find("table").dataTable({sDom:"t",bJQueryUI:!0,bDestroy:!0,aaSorting:[[1,"desc"]],aoColumns:[{bSortable:!1},{bSortable:!1}]})):o.hide(),a.html()}}),MainMutationView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t),this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e={geneSymbol:t.model.geneSymbol,uniprotId:t.model.uniprotId},n=BackboneTemplateCache.getTemplateFn("mutation_view_template"),i=n(e);t.$el.html(i),t.format()},format:function(){var t=this;t.$el.find(".mutation-details-filter-info").hide(),t.$el.find(".mutation-details-no-data-info").hide(),t.$el.find(".mutation-3d-initializer").hide(),t.$el.find(".mutation-info-panel-container").hide(),t.$el.find(".mutation-summary-view").hide(),t.$el.find(".mutation-table-container").hide(),t.$el.find(".mutation-diagram-view").hide()},initPdbPanelView:function(t,e,n,i){var a=this,o=null;a.diagramView&&a.diagramView.mutationDiagram&&(o=a.diagramView.mutationDiagram),t.loaderImage=a.options.config.loaderImage;var r={el:a.$el.find(".mutation-pdb-panel-view"),config:t,model:{geneSymbol:a.model.geneSymbol,pdbColl:i,pdbProxy:a.model.dataProxies.pdbProxy,pdbPanelOpts:e,pdbTableOpts:n},diagram:o},l=new PdbPanelView(r);return l.render(),a._pdbPanelView=l,l},initSummaryView:function(){var t=this,e=t.$el.find(".mutation-summary-view");e.show();var n={el:e,model:{mutationProxy:t.model.dataProxies.mutationProxy,clinicalProxy:t.model.dataProxies.clinicalProxy,geneSymbol:t.model.geneSymbol,sampleArray:t.model.sampleArray}},i=new MutationSummaryView(n);return i.render(),t.summaryView=i,i},init3dView:function(t){var e=this;return e._init3dView(e.model.geneSymbol,e.model.uniprotId,e.model.dataProxies.pdbProxy,t)},_init3dView:function(t,e,n,i){var a=this,o=a.$el.find(".mutation-3d-initializer");o.show();var r=new Mutation3dView({el:o,model:{uniprotId:e,geneSymbol:t,pdbProxy:n}});return r.render(),i&&i.isVisible()&&r.resetView(),r},initMutationDiagramView:function(t,e){var n=this;return n.diagramView=n._initMutationDiagramView(n.model.geneSymbol,n.model.mutationData,e,n.model.dataProxies,t),n.diagramView?n.dispatcher.trigger(MutationDetailsEvents.DIAGRAM_INIT,n.diagramView.mutationDiagram):console.log("Error initializing mutation diagram: %s",n.model.geneSymbol),n.diagramView},_initMutationDiagramView:function(t,e,n,i,a){var o=this,r=o.$el.find(".mutation-diagram-view");r.show();var l={mutations:e,sequence:n,geneSymbol:t,dataProxies:i,diagramOpts:a},s=new MutationDiagramView({el:r,model:l});return s.render(),s},initMutationTableView:function(t){var e=this;return e.tableView=e._initMutationTableView(e.model.geneSymbol,e.model.mutationData,e.model.dataProxies,e.model.dataManager,t),e.tableView||console.log("Error initializing mutation table: %s",e.model.geneSymbol),
+e.tableView},_initMutationTableView:function(t,e,n,i,a){var o=this,r=o.$el.find(".mutation-table-container");r.show();var l=new MutationDetailsTableView({el:r,config:{loaderImage:o.options.config.loaderImage},model:{geneSymbol:t,mutations:e,dataProxies:n,dataManager:i,tableOpts:a}});return l.render(),l},initMutationInfoView:function(t){var e=this,n=e.$el.find(".mutation-info-panel-container");n.show();var i={mutations:e.model.mutationData,infoPanelOpts:t},a=new MutationInfoPanelView({el:n,model:i});return a.render(),e.infoView=a,e.dispatcher.trigger(MutationDetailsEvents.INFO_PANEL_INIT,e.infoView),a},addResetCallback:function(t){var e=this,n=e.$el.find(".mutation-details-filter-reset");n.click(t)},showFilterInfo:function(){this.$el.find(".mutation-details-filter-info").slideDown()},hideFilterInfo:function(){this.$el.find(".mutation-details-filter-info").slideUp()},showNoDataInfo:function(){this.$el.find(".mutation-details-no-data-info").slideDown()},hideNoDataInfo:function(){this.$el.find(".mutation-details-no-data-info").slideUp()}}),Mutation3dView=Backbone.View.extend({initialize:function(t){this.options=t||{},this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e=(t.model.geneSymbol,BackboneTemplateCache.getTemplateFn("mutation_3d_view_template")),n=e({});this.$el.html(n),this.format()},format:function(){var t=this,e=t.$el.find(".mutation-3d-vis");e.attr("disabled","disabled");var n=function(n){if(n)e.removeAttr("disabled");else{var i=t.model.geneSymbol,a="No structure data for "+i,o={content:{text:a},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow cc-ui-tooltip"},position:{my:"bottom center",at:"top center",viewport:$(window)}};t.$el.qtip(o)}},i=t.model.pdbProxy,a=t.model.uniprotId;i.hasPdbData(a,n)},addInitCallback:function(t){var e=this,n=e.$el.find(".mutation-3d-vis");n.click(t)},resetView:function(){var t=this,e=t.$el.find(".mutation-3d-vis");e.click()},isVisible:function(){var t=this;return t.$el.is(":visible")}}),Mutation3dVisInfoView=Backbone.View.extend({render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("mutation_3d_vis_info_template"),n=e(t.model);t.$el.html(n),t.format()},format:function(){var t=this,e=t.model.pdbInfo,n=t.model.molInfo;null==e||0==e.length?t.$el.find(".mutation-3d-pdb-info").hide():t._addExpander(".mutation-3d-pdb-info"),null==n||0==n.length?t.$el.find(".mutation-3d-mol-info").hide():t._addExpander(".mutation-3d-mol-info")},_addExpander:function(t){var e=this,n={slicePoint:40,widow:2,expandPrefix:" ",expandText:"[...]",userCollapseText:"[^]",moreClass:"expander-read-more",lessClass:"expander-read-less",detailClass:"expander-details",expandEffect:"fadeIn",collapseEffect:"fadeOut"};e.$el.find(t).expander(n)}}),Mutation3dVisView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif",helpImage:"images/help.png",border:{top:0,left:0}}};this.options=jQuery.extend(!0,{},e,t),this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("mutation_3d_vis_template"),n=e({loaderImage:t.options.config.loaderImage,helpImage:t.options.config.helpImage});t.$el.html(n),t.format()},format:function(){var t=this,e=t.options.mut3dVis,n=t.$el;n.hide(),t.hideResidueWarning(),t.hideNoMapWarning();var i=t.$el.find(".mutation-3d-vis-help-content"),a=BackboneTemplateCache.getTemplateFn("3Dmol_basic_interaction");i.html(a({})),i.hide(),null!=e&&e.updateContainer(n),t.$el.find(".mutation-3d-close").click(function(){t.hideView()}),t.$el.find(".mutation-3d-minimize").click(function(){null!=e&&e.toggleSize()}),t._initMutationControls(),t._initProteinControls(),t._initButtons(),n.draggable({handle:".mutation-3d-info-title",stop:function(e,i){var a=parseInt(n.css("top")),o=parseInt(n.css("left"));at?100+t:100+5*t},a=function(t,e){n&&n.zoomTo(i(e.value))};e.slider({value:0,min:-80,max:80,stop:a,slide:a})},updateView:function(t,e,n){var i=this,a=i.options.mut3dVis,o=i.options.pdbProxy,r=function(t){n.positionMap=t,a.show(),i.refreshView(e,n),i.pdbId=e,i.chain=n},l=function(a){var l={pdbId:e,chainId:n.chainId,pdbInfo:"",molInfo:""};if(a&&a[e]){var s=PdbDataUtil.generatePdbInfoSummary(a[e],n.chainId);l.pdbInfo=s.title,l.molInfo=s.molecule}var u=new Mutation3dVisInfoView({el:i.$el.find(".mutation-3d-info"),model:l});u.render(),o.getPositionMap(t,n,r)};o.getPdbInfo(e,l)},refreshView:function(t,e){var n=this,i=n.options.mut3dVis;n.hideResidueWarning(),n.hideNoMapWarning();var a=function(t){0==t.length?n.showNoMapWarning():n.hideNoMapWarning()};if(null==t&&null==e||t==n.pdbId&&e==n.chain){var o=i.refresh();a(o),n.dispatcher.trigger(MutationDetailsEvents.VIEW_3D_STRUCTURE_RELOADED)}else n.showLoader(),setTimeout(function(){var o=i.reload(t,e,function(){n.hideLoader(),n.dispatcher.trigger(MutationDetailsEvents.VIEW_3D_STRUCTURE_RELOADED)});a(o)},50)},_initMutationColorInfo:function(){var t=this,e=t.$el.find(".mutation-type-color-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_type_color_tip_template"),i=n({}),a=t._generateTooltipOpts(i);a.style.classes+=" qtip-wide",e.qtip(a)},_initProteinColorInfo:function(){var t=this,e=t.$el.find(".protein-struct-color-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_structure_color_tip_template"),i=n({}),a=t._generateTooltipOpts(i);a.style.classes+=" qtip-wide",e.qtip(a)},_initSideChainInfo:function(){var t=this,e=t.$el.find(".display-side-chain-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_side_chain_tip_template"),i=n({}),a=t._generateTooltipOpts(i);e.qtip(a)},_initHideNonProteinInfo:function(){var t=this,e=t.$el.find(".display-non-protein-help"),n=BackboneTemplateCache.getTemplateFn("mutation_3d_non_protein_tip_template"),i=n({}),a=t._generateTooltipOpts(i);e.qtip(a)},_generateTooltipOpts:function(t){return{content:{text:t},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow"},position:{my:"top right",at:"bottom center",viewport:$(window)}}},minimizeView:function(){var t=this,e=t.options.mut3dVis;e&&e.minimize()},maximizeView:function(){var t=this,e=t.options.mut3dVis;e&&e.maximize()},resetPanelPosition:function(){var t=this,e=t.$el;e.css({left:"",position:"",top:t.options.config.border.top})},hideView:function(){var t=this,e=t.options.mut3dVis;null!=e&&e.hide(),t.dispatcher.trigger(MutationDetailsEvents.VIEW_3D_PANEL_CLOSED)},isVisible:function(){var t=this,e=t.options.mut3dVis;return e.isVisible()},focusView:function(t){var e=this,n=e.options.mut3dVis;return t?n.focusOn(t):(n.resetFocus(),!0)},highlightView:function(t,e){var n=this,i=n.options.mut3dVis;return i.highlight(t,e)},resetHighlight:function(){var t=this,e=t.options.mut3dVis;e.resetHighlight()},showLoader:function(){var t=this,e=t.$el.find(".mutation-3d-vis-loader"),n=t.$el.find(".mutation-3d-vis-container"),i=n.css("height");0!==i&&"0px"!==i&&(t._actualHeight=i,n.css("height",0)),e.show()},hideLoader:function(){var t=this,e=t.$el.find(".mutation-3d-vis-loader"),n=t.$el.find(".mutation-3d-vis-container");e.hide(),n.css("height",t._actualHeight)},showResidueWarning:function(t,e){var n=this,i=n.$el.find(".mutation-3d-residue-warning"),a=n.$el.find(".mutation-3d-unmapped-info");n.$el.find(".mutation-3d-nomap-warning").is(":visible")||(e>1?a.text(t+" of the selections"):a.text("Selected mutation"),i.show())},hideResidueWarning:function(){var t=this,e=t.$el.find(".mutation-3d-residue-warning");e.hide()},showNoMapWarning:function(){var t=this,e=t.$el.find(".mutation-3d-nomap-warning");e.show()},hideNoMapWarning:function(){var t=this,e=t.$el.find(".mutation-3d-nomap-warning");e.hide()}}),MutationCustomizePanelView=Backbone.View.extend({initialize:function(t){this.options=t||{}},render:function(){var t=this,e=t.options.diagram,n={minY:2,maxY:e.getInitialMaxY()},i=BackboneTemplateCache.getTemplateFn("mutation_customize_panel_template"),a=i(n);t.$el.html(a),t.format()},format:function(){var t=this,e=t.options.diagram;t.$el.hide();var n=t.$el.find(".diagram-customize-close"),i=t.$el.find(".diagram-y-axis-slider"),a=t.$el.find(".diagram-y-axis-limit-input");n.click(function(e){e.preventDefault(),t.toggleView()}),a.val(e.getMaxY()),i.slider({value:e.getMaxY(),min:2,max:e.getInitialMaxY(),change:function(t,n){var i=n.value;return i>e.getThreshold()?(i=e.getThreshold(),void $(this).slider("value",i)):(a.val(i),e.updateOptions({maxLengthY:i}),void e.rescaleYAxis())},slide:function(t,e){a.val(e.value)}}),a.keypress(function(t){var n=13;if(t.keyCode==n){var o=a.val(),r=o;isNaN(r)||r>e.getThreshold()?r=e.getThreshold():2>o&&(r=2),a.val(r),i.slider("option","value",Math.floor(r))}})},toggleView:function(){var t=this;t.$el.slideToggle()}}),MutationDetailsTableView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t),this.dispatcher={},_.extend(this.dispatcher,Backbone.Events)},render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("mutation_details_table_template"),n=e({loaderImage:t.options.config.loaderImage});t.$el.html(n),t._initMutationTable(),t.format()},_initMutationTable:function(t){var e=this,n=jQuery.extend(!0,{},e.model.tableOpts);n.el=n.el||e.$el.find(".mutation_details_table");var i=new MutationCollection(e.model.mutations),a=new MutationDetailsUtil(i),o=new MutationDetailsTable(n,e.model.geneSymbol,a,e.model.dataProxies,e.model.dataManager);return e.mutationTable=o,_.isFunction(t)&&t(e,o),e._generateRowData(o,o.getColumnOptions(),i,function(t){o.renderTable(t)}),o},_generateRowData:function(t,e,n,i){var a=[];n.each(function(n){for(var i={table:t,mutation:n},o=[i],r=0;r<_.size(e)-1;r++)o.push(null);a.push(o)}),i(a)},format:function(){},hideView:function(){var t=this;t.$el.hide()},showView:function(){var t=this;t.$el.show()},highlight:function(t){for(var e=this,n=e.$el.find(".mutation_details_table"),i=0;i0){var o=e.countMutations(n,i);a=e.generateSummary(o)}return a},_germlineMutationSummary:function(t){var e=this,n=e.model.mutationProxy.getMutationUtil(),i=e.model.geneSymbol,a=e.model.sampleArray,o=0,r="";if(a.length>0){for(var l=n.countMutations(i,a),s=0;s0&&(i.pdbInfo=": "+e),null!=n&&n.length>0&&(i.molInfo=": "+n);var a=BackboneTemplateCache.getTemplateFn("mutation_details_pdb_chain_tip_template");return a(i)}}),PdbPanelView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif",autoExpand:!0}};this.options=jQuery.extend(!0,{},e,t),this.collapseTimer=null,this.expandTimer=null},render:function(){var t=this,e=BackboneTemplateCache.getTemplateFn("pdb_panel_view_template"),n=e({});t.$el.html(n),t.pdbPanel=t._initPdbPanel(),t.format()},format:function(){var t=this;t.$el.hide();var e=t.$el.find(".expand-collapse-pdb-panel"),n=t.$el.find(".init-pdb-table"),i=t.$el.find(".pdb-table-controls"),a=t.$el.find(".triangle-down"),o=t.$el.find(".triangle");t.pdbPanel.hasMoreChains()&&(e.button({icons:{primary:"ui-icon-triangle-2-n-s"},text:!1}),e.css({width:"300px",height:"12px"}),e.click(function(){t.pdbPanel.toggleHeight()})),e.hide(),i.hide(),a.hide(),o.click(function(t){n.click()}),t.options.config.autoExpand&&(t.$el.find(".mutation-pdb-main-container").mouseenter(function(e){t.autoExpand()}),t.$el.find(".mutation-pdb-main-container").mouseleave(function(e){t.autoCollapse()}))},hideView:function(){var t=this;t.$el.slideUp()},showView:function(){var t=this;t.$el.slideDown()},initPdbTableView:function(t,e){var n=this,i={el:n.$el.find(".mutation-pdb-table-view"),config:{loaderImage:n.options.config.loaderImage},model:{geneSymbol:n.model.geneSymbol,pdbColl:t,pdbProxy:n.model.pdbProxy}};i=jQuery.extend(!0,{},n.model.pdbTableOpts,i);var a=new PdbTableView(i);return n.pdbTableView=a,a.render(e),a},addInitCallback:function(t){var e=this,n=e.$el.find(".init-pdb-table");n.click(function(e){e.preventDefault(),t(e)})},toggleTableControls:function(){var t=this;t.$el.find(".triangle").toggle()},selectDefaultChain:function(){var t=this,e=t.pdbPanel,n=e.getDefaultChainGroup();t.clearTimers(),e.restoreChainPositions(function(){e.highlight(n)})},selectChain:function(t,e){var n=this,i=n.pdbPanel;n.clearTimers(),i.restoreChainPositions(function(){i.expandToChainLevel(t,e);var n=i.getChainGroup(t,e);n&&i.highlight(n)})},getSelectedChain:function(){var t=this,e=t.pdbPanel;return e.getHighlighted()},autoCollapse:function(t){null==t&&(t=2e3);var e=this,n=e.$el.find(".expand-collapse-pdb-panel"),i=e.$el.find(".pdb-table-controls"),a=e.$el.find(".pdb-table-wrapper");e.clearTimers(),e.collapseTimer=setTimeout(function(){e.pdbPanel.minimizeToHighlighted(),n.slideUp(),i.slideUp(),a.slideUp()},t)},autoExpand:function(t){null==t&&(t=400);var e=this,n=e.$el.find(".expand-collapse-pdb-panel"),i=e.$el.find(".pdb-table-controls"),a=e.$el.find(".pdb-table-wrapper");e.clearTimers(),e.expandTimer=setTimeout(function(){e.pdbPanel.restoreToFull(),e.pdbPanel.hasMoreChains()&&n.slideDown(),i.slideDown(),a.slideDown(),null!=e.pdbTableView&&e.pdbTableView.refreshView()},t)},toggleScrollBar:function(t){var e=this,n=e.$el.find(".mutation-pdb-panel-container");t>0?(n.css("max-height",t),n.css("overflow",""),n.css("overflow-y","scroll")):(n.css("max-height",""),n.css("overflow-y",""),n.css("overflow","hidden"))},scrollToSelected:function(){var t=this,e=t.$el.find(".mutation-pdb-panel-container");e.scrollTo($(".pdb-selection-rectangle-group"),{axis:"y",duration:800,offset:-150})},clearTimers:function(){var t=this;null!=t.collapseTimer&&clearTimeout(t.collapseTimer),null!=t.expandTimer&&clearTimeout(t.expandTimer)},_initPdbPanel:function(){var t=this,e=t.model.pdbColl,n=t.model.pdbProxy,i=t.options.diagram,a={el:t.$el.find(".mutation-pdb-panel-container"),maxHeight:200},o=null;null!=i&&(o=i.xScale,a.marginLeft=i.options.marginLeft,a.marginRight=i.options.marginRight),a=jQuery.extend(!0,{},t.model.pdbPanelOpts,a);var r=new MutationPdbPanel(a,e,n,o);return r.init(),r}}),PdbTableView=Backbone.View.extend({initialize:function(t){var e={config:{loaderImage:"images/ajax-loader.gif"}};this.options=jQuery.extend(!0,{},e,t)},render:function(t){var e=this,n=BackboneTemplateCache.getTemplateFn("pdb_table_view_template"),i=n({loaderImage:e.options.config.loaderImage});e.$el.html(i),e._initPdbTable(t),e.format()},format:function(){var t=this;t.$el.hide()},hideView:function(){var t=this;t.$el.slideUp()},showView:function(){var t=this;t.$el.slideDown()},toggleView:function(){var t=this;t.$el.slideToggle()},refreshView:function(){var t=this;t.pdbTable.getDataTable().fnAdjustColumnSizing()},resetFilters:function(){var t=this;t.pdbTable.cleanFilters()},selectChain:function(t,e){var n=this;null!=n.pdbTable&&n.pdbTable.selectRow(t,e)},scrollToSelected:function(){var t=this,e=t.pdbTable.getSelectedRow(),n=t.$el.find(".dataTables_scrollBody");n.scrollTo($(e),{axis:"y",duration:800})},_initPdbTable:function(t){var e=this,n=e.model.pdbColl,i=e.model.pdbProxy,a=jQuery.extend(!0,{},e.model.tableOpts);a.el=a.el||e.$el.find(".pdb-chain-table");var o=new MutationPdbTable(a);return e.pdbTable=o,_.isFunction(t)&&t(e,o),e._generateRowData(o.getColumnOptions(),n,i,function(t){o.renderTable(t),e.$el.find(".pdb-chain-table-loader").hide()}),o},_generateRowData:function(t,e,n,i){var a=[],o=[];e.each(function(t){o.push(t.pdbId)}),n.getPdbInfo(o.join(" "),function(n){e.each(function(e){e.chains.each(function(i){for(var o={pdbId:e.pdbId,chain:i,organism:PdbDataUtil.getOrganism(n[e.pdbId],i.chainId),summary:PdbDataUtil.generatePdbInfoSummary(n[e.pdbId],i.chainId)},r=[o],l=0;l<_.size(t)-1;l++)r.push(null);a.push(r)})}),i(a)})}}),PredictedImpactTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){var t=function(t){var e=!0;return(null==t||"NA"==t||0==t.length)&&(e=!1),e},e=this.model.xvia;t(e)||this.$el.find(".mutation-assessor-main-link").hide();var n=this.model.pdbLink;t(n)||this.$el.find(".mutation-assessor-3d-link").hide();var i=this.model.msaLink;t(i)||this.$el.find(".mutation-assessor-msa-link").hide()},compileTemplate:function(){var t={linkOut:this.model.xvia,msaLink:this.model.msaLink,pdbLink:this.model.pdbLink,impact:this.model.impact},e=BackboneTemplateCache.getTemplateFn("mutation_details_fis_tip_template");return e(t)}}),RegionTipView=Backbone.View.extend({render:function(){var t=this.compileTemplate();this.$el.html(t),this.format()},format:function(){},compileTemplate:function(){var t={identifier:this.model.identifier,type:this.model.type.toLowerCase(),description:this.model.description,start:this.model.start,end:this.model.end,pfamAccession:this.model.pfamAccession,mutationAlignerInfo:this.model.mutationAlignerInfo},e=BackboneTemplateCache.getTemplateFn("mutation_details_region_tip_template");return e(t)}});ClinicalDataProxy.prototype=new AbstractDataProxy,ClinicalDataProxy.prototype.constructor=ClinicalDataProxy,MutationAlignerDataProxy.prototype=new AbstractDataProxy,MutationAlignerDataProxy.prototype.constructor=MutationAlignerDataProxy,MutationDataProxy.prototype=new AbstractDataProxy,MutationDataProxy.prototype.constructor=MutationDataProxy,PancanMutationDataProxy.prototype=new AbstractDataProxy,PancanMutationDataProxy.prototype.constructor=PancanMutationDataProxy,PdbDataProxy.prototype=new AbstractDataProxy,PdbDataProxy.prototype.constructor=PdbDataProxy,PfamDataProxy.prototype=new AbstractDataProxy,PfamDataProxy.prototype.constructor=PfamDataProxy,PortalDataProxy.prototype=new AbstractDataProxy,PortalDataProxy.prototype.constructor=PortalDataProxy,VariantAnnotationDataProxy.prototype=new AbstractDataProxy,VariantAnnotationDataProxy.prototype.constructor=VariantAnnotationDataProxy,MutationDetailsTable.prototype=new AdvancedDataTable,MutationDetailsTable.prototype.constructor=MutationDetailsTable,MutationDiagram.prototype.defaultOpts={el:"#mutation_diagram_d3",elWidth:740,elHeight:180,marginLeft:45,marginRight:30,marginTop:30,marginBottom:60,labelTop:"",labelTopFont:"sans-serif",labelTopFontColor:"#2E3436",labelTopFontSize:"12px",labelTopFontWeight:"bold",labelTopMargin:2,labelX:!1,labelXFont:"sans-serif",labelXFontColor:"#2E3436",labelXFontSize:"12px",labelXFontWeight:"normal",labelY:"# Mutations",labelYFont:"sans-serif",labelYFontColor:"#2E3436",labelYFontSize:"12px",labelYFontWeight:"normal",minLengthX:0,minLengthY:5,maxLengthX:1/0,maxLengthY:1/0,seqFillColor:"#BABDB6",seqHeight:14,seqPadding:5,regionHeight:24,regionFont:"sans-serif",regionFontColor:"#FFFFFF",regionFontSize:"12px",regionTextAnchor:"middle",showRegionText:!0,showStats:!1,multiSelectKeycode:16,lollipopLabelCount:1,lollipopLabelThreshold:2,lollipopFont:"sans-serif",lollipopFontColor:"#2E3436",lollipopFontSize:"10px",
+lollipopTextAnchor:"auto",lollipopTextPadding:8,lollipopTextAngle:0,lollipopFillColor:{missense:"#008000",truncating:"#000000",inframe:"#8B4513",fusion:"#8B00C9",other:"#8B00C9","default":"#BB0000"},lollipopBorderColor:"#BABDB6",lollipopBorderWidth:.5,lollipopSize:30,lollipopHighlightSize:100,lollipopStrokeWidth:1,lollipopStrokeColor:"#BABDB6",lollipopShapeRegular:"circle",lollipopShapeSpecial:"circle",xAxisPadding:10,xAxisTickIntervals:[100,200,400,500,1e3,2e3,5e3,1e4,2e4,5e4],xAxisTicks:8,xAxisTickSize:6,xAxisStroke:"#AAAAAA",xAxisFont:"sans-serif",xAxisFontSize:"10px",xAxisFontColor:"#2E3436",yAxisPadding:5,yAxisLabelPadding:15,yAxisTicks:10,yAxisTickIntervals:[1,2,5,10,20,50,100,200,500],yAxisTickSize:6,yAxisStroke:"#AAAAAA",yAxisFont:"sans-serif",yAxisFontSize:"10px",yAxisFontColor:"#2E3436",yAxisAutoAdjust:!0,animationDuration:1e3,fadeDuration:1500,pileupConverter:!1,lollipopTipFn:function(t,e,n){var i=new LollipopTipView({model:e});i.setShowStats(n);var a=i.compileTemplate(),o={content:{text:a},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow cc-ui-tooltip"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,o)},regionTipFn:function(t,e,n){var i={identifier:e.metadata.identifier,type:e.type,description:e.metadata.description,start:e.metadata.start,end:e.metadata.end,pfamAccession:e.metadata.accession,mutationAlignerInfo:""};n.getMutationAlignerData({pfamAccession:e.metadata.accession},function(e){if(null!=e&&null!=e.linkToMutationAligner&&e.linkToMutationAligner.length>0){var n=BackboneTemplateCache.getTemplateFn("mutation_aligner_info_template");i.mutationAlignerInfo=n({linkToMutationAligner:e.linkToMutationAligner})}var a=new RegionTipView({model:i}),o=a.compileTemplate(),r={content:{text:o},hide:{fixed:!0,delay:100,event:"mouseout"},show:{event:"mouseover"},style:{classes:"qtip-light qtip-rounded qtip-shadow qtip-lightyellow"},position:{my:"bottom left",at:"top center",viewport:$(window)}};cbio.util.addTargetedQTip(t,r)})}},MutationDiagram.prototype.updateOptions=function(t){var e=this;e.options=jQuery.extend(!0,{},e.options,t),e.updateGlobals()},MutationDiagram.prototype.rescaleYAxis=function(t){var e=this;e.updateGlobals(),e.svg.select(".mut-dia-y-axis").remove(),e.drawYAxis(e.svg,e.yScale,e.yMax,e.options,e.bounds),t||e.updatePlot()},MutationDiagram.prototype.updateGlobals=function(t){var e=this;t=t||e.options;var n=e.initialPileups;t.yAxisAutoAdjust&&(n=e.pileups);var i=e.maxCount=e.calcMaxCount(n),a=e.xMax=e.calcXMax(t,e.data),o=e.yMax=e.calcYMax(t,i);e.bounds=this.calcBounds(t),e.xScale=this.xScaleFn(e.bounds,a),e.yScale=this.yScaleFn(e.bounds,o)},MutationDiagram.prototype.updateSequenceData=function(t){var e=this;e.data.sequence=t},MutationDiagram.prototype.initDiagram=function(){var t=this,e=$(t.options.el)[0],n=d3.select(e),i=t.bounds=t.calcBounds(t.options);t.mutationPileupMap=PileupUtil.mapToMutations(t.initialPileups);var a=t.createSvg(n,t.options.elWidth,t.options.elHeight);t.svg=a,t.drawDiagram(a,i,t.options,t.data),t.addDefaultListeners()},MutationDiagram.prototype.calcBounds=function(t){var e={};return e.width=t.elWidth-(t.marginLeft+t.marginRight),e.height=t.elHeight-(t.marginBottom+t.marginTop),e.x=t.marginLeft,e.y=t.elHeight-t.marginBottom,e},MutationDiagram.prototype.drawDiagram=function(t,e,n,i){var a=this,o=(parseInt(i.sequence.length),a.initialPileups||PileupUtil.convertToPileups(i.mutations,n.pileupConverter)),r=a.maxCount=a.calcMaxCount(o),l=a.xMax=a.calcXMax(n,i),s=a.yMax=a.calcYMax(n,r),u=i.sequence.regions,c=a.generateSequenceTooltip(i),d=a.xScale=a.xScaleFn(e,l),p=a.yScale=a.yScaleFn(e,s);a.drawXAxis(t,d,l,n,e),0!=n.labelX,a.drawYAxis(t,p,s,n,e),0!=n.labelY&&(a.yAxisLabel=a.drawYAxisLabel(t,n,e)),0!=n.topLabel&&(a.topLabel=a.drawTopLabel(t,n,e));t.append("rect").attr("fill","#FFFFFF").attr("opacity",0).attr("x",e.x).attr("y",e.y-e.height).attr("width",e.width).attr("height",e.height).attr("class","mut-dia-background");a.drawPlot(t,o,n,e,d,p);var m=a.drawSequence(t,n,e);m.attr("title",c);for(var h=0,f=u.length;f>h;h++)a.drawRegion(t,u[h],n,e,d)},MutationDiagram.prototype.xScaleFn=function(t,e){return d3.scale.linear().domain([0,e]).range([t.x,t.x+t.width])},MutationDiagram.prototype.yScaleFn=function(t,e){return d3.scale.linear().domain([0,e]).range([t.y,t.y-t.height])},MutationDiagram.prototype.calcXMax=function(t,e){var n=parseInt(e.sequence.length);return Math.min(t.maxLengthX,Math.max(n,t.minLengthX))},MutationDiagram.prototype.calcYMax=function(t,e){return Math.min(t.maxLengthY,Math.max(e,t.minLengthY))},MutationDiagram.prototype.generateSequenceTooltip=function(t){var e="",n=parseInt(t.sequence.length);return t.sequence.metadata.identifier&&(e+=t.sequence.metadata.identifier,t.sequence.metadata.description&&(e+=", "+t.sequence.metadata.description)),e+=" ("+n+"aa)"},MutationDiagram.prototype.drawPlot=function(t,e,n,i,a,o){var r=this,l=r.gLabel;null===l&&(l=t.append("g").attr("class","mut-dia-lollipop-labels"),r.gLabel=l);var s=r.gLine;null===s&&(s=t.append("g").attr("class","mut-dia-lollipop-lines"),r.gLine=s);var u=r.gData;null===u&&(u=t.append("g").attr("class","mut-dia-lollipop-points"),r.gData=u);for(var c=0;co)break}return i},MutationDiagram.prototype.getTickValues=function(t,e){for(var n=[],i=0;t>i;)n.push(i),i+=e/2;return n.push(t),n},MutationDiagram.prototype.drawXAxis=function(t,e,n,i,a){var o=this,r=o.calcTickInterval(i.xAxisTickIntervals,n,i.xAxisTicks),l=o.getTickValues(n,r),s=function(t){return t==n?t+" aa":t%r!=0?"":n-t>r/3?t:""},u=i.xAxisTickSize,c=d3.svg.axis().scale(e).orient("bottom").tickValues(l).tickFormat(s).tickSize(u,u/2,0),d=a.y+i.regionHeight+i.xAxisPadding,p=t.append("g").attr("class","mut-dia-x-axis").attr("transform","translate(0,"+d+")").call(c);return o.formatAxis(".mut-dia-x-axis",i.xAxisStroke,i.xAxisFont,i.xAxisFontSize,i.xAxisFontColor),p},MutationDiagram.prototype.drawYAxis=function(t,e,n,i,a){var o=this,r=o.calcTickInterval(i.yAxisTickIntervals,n,i.yAxisTicks),l=o.getTickValues(n,2*r),s=function(t){var e="";return t===n?(e=t,o.maxCount>n&&(e=">"+t)):0===t&&(e=t),e},u=i.yAxisTickSize,c=d3.svg.axis().scale(e).orient("left").tickValues(l).tickFormat(s).tickSize(u,u/2,0),d=a.x-i.yAxisPadding,p=t.append("g").attr("class","mut-dia-y-axis").attr("transform","translate("+d+",0)").call(c);return o.formatAxis(".mut-dia-y-axis",i.yAxisStroke,i.yAxisFont,i.yAxisFontSize,i.yAxisFontColor),p},MutationDiagram.prototype.drawTopLabel=function(t,e,n){var i=e.labelTopMargin,a=e.marginTop/2,o=t.append("text").attr("fill",e.labelTopFontColor).attr("text-anchor","start").attr("x",i).attr("y",a).attr("class","mut-dia-top-label").style("font-family",e.labelTopFont).style("font-size",e.labelTopFontSize).style("font-weight",e.labelTopFontWeight).text(e.labelTop);return o},MutationDiagram.prototype.drawYAxisLabel=function(t,e,n){var i=n.x-e.yAxisPadding-e.yAxisTickSize-e.yAxisLabelPadding,a=n.y-n.height/2,o=t.append("text").attr("fill",e.labelYFontColor).attr("text-anchor","middle").attr("x",i).attr("y",a).attr("class","mut-dia-y-axis-label").attr("transform","rotate(270, "+i+","+a+")").style("font-family",e.labelYFont).style("font-size",e.labelYFontSize).style("font-weight",e.labelYFontWeight).text(e.labelY);return o},MutationDiagram.prototype.formatAxis=function(t,e,n,i,a){var o=d3.selectAll(t+" line");o.style("fill","none").style("stroke",e).style("shape-rendering","crispEdges"),o=d3.selectAll(t+" path"),o.style("fill","none").style("stroke",e).style("shape-rendering","crispEdges"),o=d3.selectAll(t+" text"),o.attr("fill",a).style("font-family",n).style("font-size",i)},MutationDiagram.prototype.drawLollipop=function(t,e,n,i,a,o,r){var l=this,s=i.lollipopShapeRegular,u=n.count,c=n.location,d=o(c),p=r(u);u>i.maxLengthY&&(s=i.lollipopShapeSpecial,p=r(i.maxLengthY));var m=l.getLollipopFillColor(i,n);l.updateColorMap(n,m);var h=t.append("path").attr("d",d3.svg.symbol().size(i.lollipopSize).type(s)).attr("transform","translate("+d+","+p+")").attr("fill",m).attr("stroke",i.lollipopBorderColor).attr("stroke-width",i.lollipopBorderWidth).attr("id",n.pileupId).attr("class","mut-dia-data-point").attr("opacity",0);l.fadeIn(h),h.datum(n);var f=i.lollipopTipFn;f(h,n,i.showStats);var g=e.append("line").attr("x1",d).attr("y1",p).attr("x2",d).attr("y2",l.calcSequenceBounds(a,i).y).attr("stroke",i.lollipopStrokeColor).attr("stroke-width",i.lollipopStrokeWidth).attr("class","mut-dia-data-line").attr("opacity",0);return l.fadeIn(g),{dataPoint:h,line:g}},MutationDiagram.prototype.updateColorMap=function(t,e){for(var n=this,i=0;it.options.maxLengthY&&(n=t.options.lollipopShapeSpecial),n};return e},MutationDiagram.prototype.getLollipopFillColor=function(t,e){var n,i=t.lollipopFillColor;if(_.isFunction(i))n=i(e);else if(_.isString(i))n=i;else{var a=PileupUtil.groupMutationsByMainType(e);n=0===a.length?i["default"]:i[a[0].type]}return n},MutationDiagram.prototype.drawLollipopLabels=function(t,e,n,i,a){var o=this,r=function(t,e){var i=e;if("auto"==i.toLowerCase()){var a=t.attr("x")-t.node().getComputedTextLength()/2;i=a1){for(var u=e[0].count,c=0;cl&&c>s&&(l=0)}for(var d=0;l>d&&d1&&e[d].counti&&(t=t.substring(0,3)+"..",r.text(t),r.node().getComputedTextLength()>i&&(r.remove(),r=null)),r},MutationDiagram.prototype.drawSequence=function(t,e,n){var i=this.calcSequenceBounds(n,e);return t.append("rect").attr("fill",e.seqFillColor).attr("x",i.x).attr("y",i.y).attr("width",i.width).attr("height",i.height).attr("class","mut-dia-sequence")},MutationDiagram.prototype.calcMaxCount=function(t){var e=-1;return t.length>0&&(e=t[0].count),e},MutationDiagram.prototype.calcSequenceBounds=function(t,e){var n=t.x,i=t.y+Math.abs(e.regionHeight-e.seqHeight)/2+e.seqPadding,a=t.width,o=e.seqHeight;return{x:n,y:i,width:a,height:o}},MutationDiagram.prototype.updatePlot=function(t){var e=this,n=e.pileups,i=[];return t&&(i=PileupUtil.convertToPileups(t,e.options.pileupConverter),e.pileups=n=i,e.mutationPileupMap=PileupUtil.mapToMutations(n)),e.cleanPlotArea(),e.mutationColorMap={},e.options.yAxisAutoAdjust&&e.rescaleYAxis(!0),e.drawPlot(e.svg,n,e.options,e.bounds,e.xScale,e.yScale),_.each(_.keys(e.listeners),function(t){var n=e.svg.selectAll(t);_.each(_.keys(e.listeners[t]),function(i){n.on(i,e.listeners[t][i])})}),e.highlighted={},e.dispatcher.trigger(MutationDetailsEvents.DIAGRAM_PLOT_UPDATED),e.isFiltered()},MutationDiagram.prototype.cleanPlotArea=function(){var t=this,e=t.gLabel.selectAll("text"),n=t.gLine.selectAll("line"),i=t.gData.selectAll(".mut-dia-data-point");t.fadeOut(e,function(t){$(t).remove()}),t.fadeOut(n,function(t){$(t).remove()}),t.fadeOut(i,function(t){$(t).remove()})},MutationDiagram.prototype.resetPlot=function(){var t=this;t.updatePlot(t.data.mutations),t.dispatcher.trigger(MutationDetailsEvents.DIAGRAM_PLOT_RESET)},MutationDiagram.prototype.updateTopLabel=function(t){var e=this;(void 0==t||null==t)&&(t=""),e.topLabel.text(t)},MutationDiagram.prototype.addListener=function(t,e,n){var i=this;i.svg.selectAll(t).on(e,n),null==i.listeners[t]&&(i.listeners[t]={}),i.listeners[t][e]=n},MutationDiagram.prototype.removeListener=function(t,e){var n=this;n.svg.selectAll(t).on(e,null),n.listeners[t]&&n.listeners[t][e]&&delete n.listeners[t][e]},MutationDiagram.prototype.addDefaultListeners=function(){var t=this;t.addListener(".mut-dia-background","click",function(e,n){var i=!t.isHighlighted()||t.multiSelect;i||(t.clearHighlights(),t.dispatcher.trigger(MutationDetailsEvents.ALL_LOLLIPOPS_DESELECTED))}),t.addListener(".mut-dia-data-point","click",function(e,n){t.isHighlighted(this)?(t.removeHighlight(this),t.multiSelect||t.clearHighlights(),t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_DESELECTED,e,n)):(t.multiSelect||t.clearHighlights(),t.highlight(this),t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_SELECTED,e,n))}),t.addListener(".mut-dia-data-point","mouseout",function(e,n){t.isHighlighted(this)||t.resizeLollipop(d3.select(this),t.options.lollipopSize),t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_MOUSEOUT,e,n)}),t.addListener(".mut-dia-data-point","mouseover",function(e,n){t.isHighlighted(this)||t.resizeLollipop(d3.select(this),t.options.lollipopHighlightSize),t.dispatcher.trigger(MutationDetailsEvents.LOLLIPOP_MOUSEOVER,e,n)});var e=function(e,n){t.multiSelect&&d3.event.preventDefault()};t.addListener(".mut-dia-data-point","mousedown",e),t.addListener(".mut-dia-background","mousedown",e),$(window).on("keydown",function(e){e.keyCode==t.options.multiSelectKeycode&&(t.multiSelect=!0)}),$(window).on("keyup",function(e){e.keyCode==t.options.multiSelectKeycode&&(t.multiSelect=!1)})},MutationDiagram.prototype.isHighlighted=function(t){var e=this,n=!1;if(void 0==t)n=!_.isEmpty(e.highlighted);else{var i=d3.select(t),a=i.datum().location;void 0!=e.highlighted[a]&&(n=!0)}return n},MutationDiagram.prototype.clearHighlights=function(){var t=this,e=t.gData.selectAll(".mut-dia-data-point");t.resizeLollipop(e,t.options.lollipopSize),t.highlighted={}},MutationDiagram.prototype.highlightMutation=function(t){var e=this,n=e.mutationPileupMap[t],i=e.svg.select("#"+n);i.length>0&&e.highlight(i[0][0])},MutationDiagram.prototype.highlight=function(t){var e=this,n=d3.select(t);e.resizeLollipop(n,e.options.lollipopHighlightSize);var i=n.datum().location;e.highlighted[i]=n},MutationDiagram.prototype.removeHighlight=function(t){var e=this,n=d3.select(t);e.resizeLollipop(n,e.options.lollipopSize);var i=n.datum().location;delete e.highlighted[i]},MutationDiagram.prototype.resizeLollipop=function(t,e){var n=this;t.transition().ease("elastic").duration(n.options.animationDuration).attr("d",d3.svg.symbol().size(e).type(n.getLollipopShapeFn()))},MutationDiagram.prototype.fadeIn=function(t,e){var n=this;t.transition().style("opacity",1).duration(n.options.fadeDuration).each("end",function(){_.isFunction(e)&&e(this)})},MutationDiagram.prototype.fadeOut=function(t,e){var n=this;t.transition().style("opacity",0).duration(n.options.fadeDuration).each("end",function(){_.isFunction(e)&&e(this)})},MutationDiagram.prototype.getSelectedElements=function(){var t=this;return _.values(t.highlighted)},MutationDiagram.prototype.isFiltered=function(){var t=this,e=!1;return PileupUtil.countMutations(t.pileups)3D visualizer basic interaction
diff --git a/build/mutationMapperTemplates.js b/build/mutationMapperTemplates.js
index 037e80e..bfadc56 100644
--- a/build/mutationMapperTemplates.js
+++ b/build/mutationMapperTemplates.js
@@ -5,7 +5,7 @@ window["backbone-template"]["mutationViews"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape;
with (obj) {
-__p += '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
+__p += '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
}
return __p
diff --git a/src/js/data/ClinicalDataProxy.js b/src/js/data/ClinicalDataProxy.js
index 3a48f89..a43ad37 100644
--- a/src/js/data/ClinicalDataProxy.js
+++ b/src/js/data/ClinicalDataProxy.js
@@ -41,7 +41,7 @@ function ClinicalDataProxy(options)
// default options
var _defaultOpts = {
- servletName: "api/clinicaldata",
+ servletName: "api-legacy/clinicaldata",
subService: {
patients: "patients"
}
diff --git a/src/js/data/MutationDataProxy.js b/src/js/data/MutationDataProxy.js
index 963367c..a6b8341 100644
--- a/src/js/data/MutationDataProxy.js
+++ b/src/js/data/MutationDataProxy.js
@@ -44,7 +44,8 @@ function MutationDataProxy(options)
var _defaultOpts = {
servletName: "getMutationData.json",
geneList: "", // list of target genes (genes of interest) as a string
- params: {} // fixed servlet params
+ params: {}, // fixed servlet params
+ paramsPromise: null // alternative servlet params as a promise object
};
// merge options with default options to use defaults for missing values
@@ -160,38 +161,41 @@ function MutationDataProxy(options)
callback(mutationData);
};
- // some (or all) data is missing,
- // send ajax request for missing genes
- if (genesToQuery.length > 0)
- {
- var servletParams = _options.params;
-
- // add genesToQuery to the servlet params
- servletParams.geneList = genesToQuery.join(" ");
-
- // retrieve data from the server
- //$.post(_options.servletName, servletParams, process, "json");
- var ajaxOpts = {
- type: "POST",
- url: _options.servletName,
- data: servletParams,
- success: process,
- error: function() {
- console.log("[MutationDataProxy.getMutationData] " +
- "error retrieving mutation data for genetic profiles: " + servletParams.geneticProfiles);
- process([]);
- },
- dataType: "json"
- };
-
- self.requestData(ajaxOpts);
- }
- // data for all requested genes already cached
- else
- {
- // just forward the data to the callback function
- callback(mutationData);
- }
+ var paramsPromise = _options.paramsPromise ||
+ (new $.Deferred()).resolve(_options.params);
+
+ paramsPromise.then(function(servletParams) {
+ // some (or all) data is missing,
+ // send ajax request for missing genes
+ if (genesToQuery.length > 0)
+ {
+ // add genesToQuery to the servlet params
+ servletParams.geneList = genesToQuery.join(" ");
+
+ // retrieve data from the server
+ //$.post(_options.servletName, servletParams, process, "json");
+ var ajaxOpts = {
+ type: "POST",
+ url: _options.servletName,
+ data: servletParams,
+ success: process,
+ error: function() {
+ console.log("[MutationDataProxy.getMutationData] " +
+ "error retrieving mutation data for genetic profiles: " + servletParams.geneticProfiles);
+ process([]);
+ },
+ dataType: "json"
+ };
+
+ self.requestData(ajaxOpts);
+ }
+ // data for all requested genes already cached
+ else
+ {
+ // just forward the data to the callback function
+ callback(mutationData);
+ }
+ });
}
}