-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
238 lines (215 loc) · 10.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ComplexViewer Demo</title>
<meta content="ComplexViewer Demo" name="ComplexViewer Demo">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<!-- css -->
<link href="./css/reset.css" rel="stylesheet" type='text/css'>
<link href="./css/style.css" rel="stylesheet" type='text/css'>
<link href="./css/demo.css" rel="stylesheet" type='text/css'>
<!--libraries-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.2.2/d3.v3.min.js"></script>
<script src="./dist/complexviewer.js" type="text/javascript"></script>
<!-- example data info -->
<script src="./data/index.js" type="text/javascript"></script>
</head>
<body>
<!-- Main -->
<div class="main">
<div class="controls space-between">
<div class="top-bar">
<!-- <h1>-->
<i class="fa fa-github" onclick="window.location = 'https://github.com/MICommunity/ComplexViewer';"
title="GitHub project"></i>
<a href="https://doi.org/10.1093/bioinformatics/btx497" target="_blank"
title="Publication">ComplexViewer</a>
<!-- </h1>-->
</div>
<div class="top-bar">
<label for="dataSets">Example:</label>
<select id="dataSets" onChange="loadData();"></select>
</div>
</div>
<div class="centre">
<div class="middleDiv">
<div class="innerMiddleDiv">
<div id="networkDiv"></div>
<div class="legend">
<table class="symbols">
<tr>
<td>
<img src="./src/imgs/key-svg/molecule-set.svg">
</td>
<td>Molecule Set</td>
</tr>
<tr>
<td>
<img src="./src/imgs/key-svg/small-molecule.svg">
</td>
<td>Bioactive Entity</td>
</tr>
<tr>
<td>
<img src="./src/imgs/key-svg/gene.svg">
</td>
<td>Gene</td>
</tr>
<tr>
<td>
<img src="./src/imgs/key-svg/dna.svg">
</td>
<td>DNA</td>
</tr>
<tr>
<td>
<img src="./src/imgs/key-svg/rna.svg">
</td>
<td>RNA</td>
</tr>
<tr>
<td>
<img src="./src/imgs/key-svg/protein-circle.svg">
<img src="./src/imgs/key-svg/protein-bar.svg">
</td>
<td>Protein <br> (click to toggle)</td>
</tr>
</table>
<div class="controls protein-buttons"><p class="protein-expand-label">Proteins: </p>
<button class="btn btn-1 btn-1a" onclick="cv.expandAll();">Expand All</button>
<button class="btn btn-1 btn-1a" onclick="cv.collapseAll();">Collapse All</button>
</div>
<div id="colors"></div>
</div><!-- legend -->
</div> <!-- innerMiddleDiv -->
<div>
<div class="controls space-between">
<div class="">
<input type="checkbox" id="mifeatures" name="mifeatures" value="MI Features" checked
autocomplete="off"
onchange="setAnnotations(this);">
<label for="mifeatures"> MI Features</label>
<input type="checkbox" id="uniprotkb" name="uniprotkb" value="UniprotKB"
autocomplete="off"
onchange="setAnnotations(this);">
<label for="uniprotkb"> UniprotKB Domains</label>
<input type="checkbox" id="superfamily" name="superfamily" value="Superfamily"
autocomplete="off"
onchange="setAnnotations(this);">
<label for="superfamily"> Superfamily</label>
<input type="checkbox" id="interactor" name="interactor" value="Interactor"
autocomplete="off"
onchange="setAnnotations(this);">
<label for="interactor"> Interactor</label>
</div>
<div class="">
<button class="btn btn-1 btn-1a" onclick="cv.autoLayout();" style="display:inline">Layout
</button>
<button class="btn btn-1 btn-1a" onclick="exportSVG();" style="display:inline">Export Graphic
</button>
</div>
</div>
</div> <!-- bottom bar -->
</div> <!-- middleDiv -->
</div> <!-- centreDiv -->
<div class="logo-bar space-between">
<a class="logo" href="https://rappsilberlab.org/" target="_blank"><img src="images/logos/rappsilber-logo.png"
alt="Rappsilber Laboratory"></a>
<a class="logo" href="https://www.ed.ac.uk/" target="_blank"><img src="./images/logos/eduni.jpeg"
alt="Edinburgh University"></a>
<a class="logo" href="https://www.wcb.ed.ac.uk/" target="_blank"><img src="images/logos/wtccb.png"
alt="Wellcome Trust Centre for Cell Biology"></a>
<a class="logo" href="https://www.ebi.ac.uk/" target="_blank"><img src="images/logos/ebi-logo.jpeg"
alt="European Bioinformatics Institute"></a>
<a class="logo" href="https://intermine.org/" target="_blank"><img src="./images/logos/intermine.png"
alt="Intermine"></a>
<a class="logo" href="https://www.cam.ac.uk/" target="_blank"><img src="./images/logos/cambridge-blue.png"
alt="Cambridge University"></a>
</div>
</div><!-- main-->
<script type="text/javascript">
//<![CDATA[
for (var i = 0; i < exampleIndex.length; i++) {
var example = exampleIndex[i];
const dataSetsSelect = document.getElementById("dataSets");
const opt = document.createElement("option");
opt.value = example.ac;
opt.innerHTML = example.name;
dataSetsSelect.appendChild(opt);
}
const networkTargetDiv = document.getElementById("networkDiv");
cv = new complexviewer.App(networkTargetDiv);
//hover listener example
// cv.addHoverListener(function (participantArr) {
// console.log("HOVER: ", participantArr);
// });
//expand listener example
cv.addExpandListener(function (participantArr) {
console.log("EXPANDED: ", participantArr);
});
loadData();
function loadData() {
cv.clear();
const dataSetsSelect = document.getElementById("dataSets");
const path = `./data/${dataSetsSelect.options[dataSetsSelect.selectedIndex].value}.json`;
d3.json(path, function (data) {
cv.readMIJSON(data);
makeLegend(cv.getColorKeyJson());
});
}
function setAnnotations(checkbox) {
var json = cv.showAnnotations(checkbox.value, checkbox.checked);
console.log(json);
makeLegend(json);
}
// you can use code below as template to make legend from json
function makeLegend(json) {
const div = document.getElementById("colors");
div.textContent = "";
const colorTable = document.createElement("table");
for (let majorClass in json) {
const tr = colorTable.insertRow();
const headerCell = tr.insertCell();
headerCell.textContent = majorClass;
headerCell.colSpan = 3;
for (let legendEntry of json[majorClass]) {
const tr = colorTable.insertRow();
if (legendEntry.certain && legendEntry.uncertain) {
const tc1 = tr.insertCell();
tc1.style.backgroundColor = legendEntry.certain.color;
tc1.style.width = "45px";
const tc2 = tr.insertCell();
const color = legendEntry.uncertain.color
tc2.style.background = "repeating-linear-gradient(45deg, #ffffff, #ffffff 6px, "+color+" 6px, "+color+" 12px)";
tc2.style.width = "45px";
}
else if (legendEntry.certain) {
const tc1 = tr.insertCell();
tc1.style.backgroundColor = legendEntry.certain.color;
tc1.style.width = "90px";
tc1.colSpan = 2;
}
else if (legendEntry.uncertain) {
const tc1 = tr.insertCell();
const color = legendEntry.uncertain.color
tc1.style.background = "repeating-linear-gradient(45deg, #ffffff, #ffffff 6px, "+color+" 6px, "+color+" 12px)";
tc1.style.width = "90px";
tc1.colSpan = 2;
}
const tc3 = tr.insertCell();
tc3.style.paddingLeft = "10px";
tc3.textContent = legendEntry.name;
}
}
div.appendChild(colorTable);
}
function exportSVG() {
const dataSetsSelect = document.getElementById("dataSets");
const fileName = dataSetsSelect.options[dataSetsSelect.selectedIndex].value + ".svg"
cv.downloadSVG(fileName);
}
//]]>
</script>
</body>
</html>