-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
372 lines (292 loc) · 10.4 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>iobio charts</title>
<style>
:root {
font-family: Arial;
//--iobio-data-color: orange;
//--iobio-data-color-secondary: blue;
}
body {
margin: 0;
}
main {
padding: 0 10px 10px 10px;
box-sizing: border-box;
}
.read-depth-container {
height: 320px;
margin-bottom: 20px;
}
.bottom-container {
display: flex;
}
.percent-row {
display: flex;
width: 40%;
flex-wrap: wrap;
gap: 20px;
align-content: flex-start;
}
iobio-percent-box {
width: 220px;
height: 220px;
}
.histogram-column {
display: flex;
width: 60%;
flex-direction: column;
gap: 20px;
}
iobio-histogram {
height: 220px;
}
#bam2-header {
display: flex;
justify-content: space-between;
align-items: center;
height: 40px;
width: 100%;
background-color: #2d8fc1;
position: sticky;
top: 0;
z-index: 1;
padding: 0 10px;
box-sizing: border-box;
}
#bam2-header h1 {
color: white;
font-size: 1.5em;
margin: 0;
padding: 5px 0;
}
#help-button {
color: white;
font-size: 1.5em;
cursor: pointer;
}
#help-button:hover {
background-color: white;
color: #2d8fc1;
}
*:not(:defined) {
opacity: 0;
}
iobio-tab {
display: flex;
gap: 10px;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<div id="bam2-header">
<h1>bam2.iobio</h1>
<span id="help-button" data-link="/help">Get Help</span>
</div>
<iobio-data-broker></iobio-data-broker>
<iobio-help-page class="route" id="help-page"></iobio-help-page>
<main id="main-content">
<iobio-bam-controls></iobio-bam-controls>
<div class='read-depth-container'>
<iobio-coverage-depth
label="Read Coverage">
</iobio-coverage-depth>
</div>
<div class='bottom-container'>
<div class="percent-row">
<iobio-panel>
<iobio-label-info-button label="Mapped Reads">
<div slot="content">
<p>This is custom content for the Mapped Reads percent box.</p>
</div>
</iobio-label-info-button>
<iobio-percent-box percent-key="mapped_reads" total-key="total_reads"></iobio-percent-box>
</iobio-panel>
<iobio-panel>
<iobio-label-info-button label="Forward Strands">
<div slot="content">
<p>This is custom content for the Forward Strands percent box.</p>
</div>
</iobio-label-info-button>
<iobio-percent-box percent-key="forward_strands" total-key="total_reads"></iobio-percent-box>
</iobio-panel>
<iobio-panel>
<iobio-label-info-button label="Proper Pairs">
<div slot="content">
<p>This is custom content for the Proper Pairs percent box.</p>
</div>
</iobio-label-info-button>
<iobio-percent-box percent-key="proper_pairs" total-key="total_reads"></iobio-percent-box>
</iobio-panel>
<iobio-panel>
<iobio-label-info-button label="Singletons">
<div slot="content">
<p>This is custom content for the Singletons percent box.</p>
</div>
</iobio-label-info-button>
<iobio-percent-box percent-key="singletons" total-key="total_reads"></iobio-percent-box>
</iobio-panel>
<iobio-panel>
<iobio-label-info-button label="Both Mates Mapped">
<div slot="content">
<p>This is custom content for the Both Mates Mapped percent box.</p>
</div>
</iobio-label-info-button>
<iobio-percent-box percent-key="both_mates_mapped" total-key="total_reads"></iobio-percent-box>
</iobio-panel>
<iobio-panel>
<iobio-label-info-button label="Duplicates">
<div slot="content">
<p>This is custom content for the Duplicates percent box.</p>
</div>
</iobio-label-info-button>
<iobio-percent-box percent-key="duplicates" total-key="total_reads"></iobio-percent-box>
</iobio-panel>
</div>
<div class='histogram-column'>
<iobio-panel>
<iobio-label-info-button label="Read Coverage Distribution">
<div slot="content">
<p>This is custom content for the Read Coverage Distribution histogram.</p>
</div>
</iobio-label-info-button>
<iobio-histogram broker-key="coverage_hist"></iobio-histogram>
</iobio-panel>
<iobio-panel>
<iobio-tabs>
<iobio-tab slot="tab">
<iobio-label-info-button label="Fragment Length" icon-position="left" slot="tab-content">
<div slot="content">
<p>This is custom content for the Fragment Length histogram.</p>
</div>
</iobio-label-info-button>
</iobio-tab>
<iobio-tab-panel slot="panel">
<iobio-histogram broker-key="frag_hist" ignore-outliers></iobio-histogram>
</iobio-tab-panel>
<iobio-tab slot="tab">
<iobio-label-info-button label="Read Length" slot="tab-content">
<div slot="content">
<p>This is custom content for the Read Length histogram.</p>
</div>
</iobio-label-info-button>
</iobio-tab>
<iobio-tab-panel slot="panel">
<iobio-histogram broker-key="length_hist" ignore-outliers></iobio-histogram>
</iobio-tab-panel>
</iobio-tabs>
</iobio-panel>
<iobio-panel>
<iobio-tabs>
<iobio-tab slot="tab">
<iobio-label-info-button label="Mapping Quality" icon-position="left" slot="tab-content">
<div slot="content">
<p>This is custom content for the Mapping Quality histogram.</p>
</div>
</iobio-label-info-button>
</iobio-tab>
<iobio-tab-panel slot="panel">
<iobio-histogram broker-key="mapq_hist"></iobio-histogram>
</iobio-tab-panel>
<iobio-tab slot="tab">
<iobio-label-info-button label="Base Quality" slot="tab-content">
<div slot="content">
<p>This is custom content for the Base Quality histogram.</p>
</div>
</iobio-label-info-button>
</iobio-tab>
<iobio-tab-panel slot="panel">
<iobio-histogram broker-key="baseq_hist"></iobio-histogram>
</iobio-tab-panel>
</iobio-tabs>
</iobio-panel>
</div>
</div>
</main>
<script type=importmap>
{
"imports": {
"d3": "https://cdn.jsdelivr.net/npm/d3@7/+esm"
}
}
</script>
<script type='module' src='./index.js'></script>
<script type='module'>
import { parseBedFile } from './coverage/src/BamData.js';
const urlParams = new URLSearchParams(window.location.search);
const source = urlParams.get("source");
let apiUrl;
let alignmentUrl;
let indexUrl;
let bedUrl;
if (source) {
// Mosaic integration
const backendMap = {
"https://mosaic.chpc.utah.edu": "https://mosaic.chpc.utah.edu/gru/api/v1",
"https://mosaic-staging.chpc.utah.edu": "https://mosaic-staging.chpc.utah.edu/gru/api/v1",
};
apiUrl = backendMap[source];
const token = urlParams.get("access_token");
const project_id = urlParams.get("project_id");
const sample_id = urlParams.get("sample_id");
const mosaicRequest = mosaicRequesterForProject(source, project_id, token);
const files = await mosaicRequest(`/samples/${sample_id}/files`);
const alignmentFile = files.data.filter(f => (f.type == 'bam' || f.type == 'cram'))[0];
const indexFile = files.data.filter(f => (f.type == 'bai' || f.type == 'crai'))[0];
const bedFile = files.data.filter(f => (f.type == 'bam-bed'))[0];
const promises = [
mosaicRequest(`/files/${alignmentFile.id}/url`),
mosaicRequest(`/files/${indexFile.id}/url`),
];
if (bedFile) {
promises.push(mosaicRequest(`/files/${bedFile.id}/url`));
}
const [ alignmentUrlRes, indexUrlRes, bedUrlRes ] = await Promise.all(promises);
alignmentUrl = alignmentUrlRes.url
indexUrl = indexUrlRes.url;
bedUrl = bedUrlRes.url;
}
else {
alignmentUrl = urlParams.get("alignment-url");
indexUrl = urlParams.get("index-url");
bedUrl = urlParams.get("bed-url");
}
const broker = document.querySelector('iobio-data-broker');
if (apiUrl) {
broker.apiUrl = apiUrl;
}
broker.alignmentUrl = alignmentUrl;
broker.indexUrl = indexUrl;
if (bedUrl) {
broker.bedUrl = bedUrl;
}
function mosaicRequesterForProject(server, projectId, token) {
async function request(path) {
const url = `${server}/api/v1/projects/${projectId}${path}`;
const res = await fetch(url, {
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + token,
}
});
return res.json();
}
return request;
}
document.addEventListener('selected-regions-change', (event) => {
broker.regions = event.detail;
});
document.addEventListener('bed-file-selected', (event) => {
console.log(event.detail)
});
document.addEventListener('bed-file-removed', (event) => {
console.log(event.detail)
});
</script>
</body>
</html>