PageSourceSearch

https://www.cancerhotspots.org/src/js/render/ClassificationRender.js

js cancerhotspots.org collected 2026-10-03 21:18:44 UTC 3,345 bytes, 90 lines download raw bytes

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 ClassificationRender(options)
37{
38    var _defaultOpts = {
39        templateId: "span_class",
40        displayValue: {
41            "LL": "L<sub>L</sub>",
42            "LH": "L<sub>H</sub>",
43            "Cluster-exclusive": "Not coupled to hotspot",
44            "Hotspot-linked": "Coupled to hotspot",
45            "Hotspot": "Single-residue hotspot"
46        },
47        tooltipValue: {
48            "Cluster-exclusive": "3D cluster residue NOT coupled to a single-residue hotspot",
49            "Hotspot-linked": "3D cluster residue coupled to a single-residue hotspot",
50            "Hotspot": "Single-residue hotspot"
51        },
52        style: {}
53    };
54
55    // merge options with default options to use defaults for missing values
56    var _options = jQuery.extend(true, {}, _defaultOpts, options);
57
58    function render(data, type)
59    {
60        if (data == null) {
61            return "";
62        }
63
64        var value = data.value || data;
65        var classification = data.classification || data;
66
67        var templateFn = _.template($("#" + _options.templateId).html());
68        var display = _options.displayValue[value] || value;
69        var style = _options.style[classification] ||
70                    ViewUtils.getClassStyle(classification) ||
71                    classification || "";
72
73        return templateFn({display: display, style: style});
74    }
75
76    function postRender(td, cellData, rowData, row, col)
77    {
78        var tooltipOpts = TooltipUtils.defaultTooltipOpts();
79        tooltipOpts.content = _options.tooltipValue[cellData];
80
81        if (!_.isEmpty(tooltipOpts.content))
82        {
83            cbio.util.addTargetedQTip(
84                $(td).find('.hotspot-classification'), tooltipOpts);
85        }
86    }
87
88    this.render = render;
89    this.postRender = postRender;
90}

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.