1/* 2 * Copyright (c) 2016 Memorial Sloan-Kettering Cancer Center. 3 * 4 * This library is distributed in the hope that it will be useful, but WITHOUT 5 * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS 6 * FOR A PARTICULAR PURPOSE. The software and documentation provided hereunder 7 * is on an "as is" basis, and Memorial Sloan-Kettering Cancer Center has no 8 * obligations to provide maintenance, support, updates, enhancements or 9 * modifications. In no event shall Memorial Sloan-Kettering Cancer Center be 10 * liable to any party for direct, indirect, special, incidental or 11 * consequential damages, including lost profits, arising out of the use of this 12 * software and its documentation, even if Memorial Sloan-Kettering Cancer 13 * Center has been advised of the possibility of such damage. 14 */ 15 16/* 17 * This file is part of cBioPortal Cancer Hotspots. 18 * 19 * cBioPortal is free software: you can redistribute it and/or modify 20 * it under the terms of the GNU Affero General Public License as 21 * published by the Free Software Foundation, either version 3 of the 22 * License. 23 * 24 * This program is distributed in the hope that it will be useful, 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 * GNU Affero General Public License for more details. 28 * 29 * You should have received a copy of the GNU Affero General Public License 30 * along with this program. If not, see <http://www.gnu.org/licenses/>. 31 */ 32 33/** 34 * @author Selcuk Onur Sumer 35 */ 36function PdbChainsRender(options) 37{ 38 var _defaultOpts = { 39 templateId: "pdb_chains_column", 40 linkTemplateId: "cluster_pdb_link", 41 threshold: 2, 42 pValueThreshold: 0.0001, 43 dataManager: false, 44 pdbIdData: function(row) { 45 return { 46 pdbId: row["pdbId"], 47 chain: row["chain"] 48 }; 49 } 50 }; 51 52 // merge options with default options to use defaults for missing values 53 var _options = jQuery.extend(true, {}, _defaultOpts, options); 54 55 function render(data, type) 56 { 57 if (type === 'sort') 58 { 59 return _.size(data); 60 } 61 else 62 { 63 // convert map into an array and sort by count 64 var pdbChains = MutationUtils.convertToPdbList(data); 65 66 // create an array of display values 67 var values = []; 68 var linkTemplateFn = _.template($("#" + _options.linkTemplateId).html()); 69 70 _.each(_.first(pdbChains, _options.threshold), function(pdbChain) { 71 72 values.push(linkTemplateFn({ 73 pdbChain: pdbChain.pdbId + ":" + pdbChain.chain 74 })); 75 }); 76 77 if (_.size(pdbChains) > _options.threshold) 78 { 79 values.push('and ' + (_.size(pdbChains) - _options.threshold) + ' more'); 80 } 81 82 var templateFn = _.template($("#" + _options.templateId).html()); 83 return templateFn({pdbChains: values.join(", ")}); 84 } 85 86 } 87 88 function postRender(td, cellData, rowData, row, col) 89 { 90 if (_.isEmpty(cellData)) 91 { 92 // nothing to render 93 return; 94 } 95 96 var pdbIdRender = new PdbIdRender({ 97 dataManager: _options.dataManager 98 }); 99 100 var pValueRender = new DecimalValueRender({ 101 threshold: _options.pValueThreshold 102 }); 103 104 var noWrapRender = new NoWrapRender(); 105 106 // convert map into a list 107 var pdbList = MutationUtils.convertToPdbList(cellData); 108 109 var viewOpts = { 110 //templateId: '#pdb_chain_composition', 111 //dataTableTarget: ".pdb-chain-composition", 112 templateId: '#variant_composition', 113 dataTableTarget: ".variant-composition", 114 dom: "t", 115 data: pdbList, 116 order: [[2 , "asc" ], [1, "asc"]], 117 columns: [ 118 {title: "PDB Id", 119 data: _options.pdbIdData, 120 render: pdbIdRender.render, 121 createdCell: pdbIdRender.postRender}, 122 {title: "Chain", 123 data: "chain"}, 124 {id: "pValue", 125 title: noWrapRender.render("P-value"), 126 data: "pValue", 127 render: pValueRender.render} 128 ] 129 }; 130 131 addEventListeners(td); 132 133 cbio.util.addTargetedQTip($(td).find('.qtipped-text'), 134 TooltipUtils.tooltipOptions(cellData, viewOpts)); 135 } 136 137 function addEventListeners(td) 138 { 139 var pdbElem = $(td).find(".cluster-pdb"); 140 141 pdbElem.on('click', function() { 142 // show the 3D vis 143 if (_options.dataManager) 144 { 145 // select the pdb! 146 _options.dataManager.selectPdbChain($(this).text()); 147 } 148 }); 149 } 150 151 this.render = render; 152 this.postRender = postRender; 153} 154
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.