forked from project-gemmi/pdb-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trends.html
299 lines (274 loc) · 9.92 KB
/
trends.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Trends in X-ray data processing</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/dc.css"/>
<style>
html { margin: 0 auto; max-width: 1500px; overflow-y: scroll; }
body { font: 14px sans-serif; line-height: 20px; margin: 0; }
.clearfix:before, .clearfix:after {
display: table; line-height: 0; content: ""; }
.clearfix:after { clear: both; }
h2 { text-align: center; margin-bottom: 10px; color: #444; }
h1#loading { text-align: center; color: #aaa; font-size: 40px; }
strong { color: #333; }
a.reset { text-decoration: none; padding: 0 3px;
color: white; background: teal; }
a.reset:hover { text-decoration: underline; }
#subh { text-align:center; font-size:14px; color:#444; margin-top: 0; }
#options { text-align:center; color:#444; margin-top: 0;}
#footnote { font-size: 12px; text-align: center; color:#444; padding: 8px 0; }
#chart-facility select { min-width: 180px; min-height: 440px; }
#chart-facility { margin-right: 80px; margin-bottom: 10px; }
.dc-chart g.chart-body { clip-path: none; }
text.x-axis-label { font-size: 12px; }
</style>
</head>
<body>
<h2>Trends in the PDB entries</h2>
<p id="subh">
A different presentation of the same data as on
<a href="xray.html">the main page</a>.
<br/>X axis:
<input type="radio" id="reldate" name="date" value="release"> release
<input type="radio" id="depdate" name="date" value="deposit"> deposition date
Y axis:
<input type="radio" id="abs" name="absolute" value="y"> counts
<input type="radio" id="rel" name="absolute" value="n"> percentage
<h1 id="loading">LOADING DATA...</h1>
<div id="chart-facility" style="visibility: hidden;">
<strong>Facility</strong>
<a class="reset" href="#">reset</a>
<div class="clearfix"></div>
</div>
<div id="all-data" style="visibility: hidden;">
<div id="chart-detec">
<strong>Detector Technology</strong>
<div class="clearfix"></div>
</div>
<div id="chart-solution">
<strong>Solution Technique</strong>
<div class="clearfix"></div>
</div>
<div id="chart-reduc">
<strong>Reduction Software</strong>
<div class="clearfix"></div>
</div>
<div id="chart-scaling">
<strong>Scaling Software</strong>
<div class="clearfix"></div>
</div>
<div id="chart-refinement">
<strong>Refinement Software</strong> (before Servalcat)
<div class="clearfix"></div>
</div>
</div>
<div id="footnote" style="clear:both;">
<a href="https://github.com/project-gemmi/pdb-stats">
Source code and info...</a>
</div>
<script src="https://d3js.org/d3.v4.min.js"></script>
<!--script src="js/d3.v4.js"></script-->
<script src="js/crossfilter.js"></script>
<script src="js/dc.min.js"></script>
<script>
"use strict";
var facility_chart = dc.selectMenu('#chart-facility');
var detec_chart = dc.seriesChart('#chart-detec');
var reduc_chart = dc.seriesChart('#chart-reduc');
var scaling_chart = dc.seriesChart('#chart-scaling');
var solution_chart = dc.seriesChart('#chart-solution');
var refinement_chart = dc.seriesChart('#chart-refinement');
var params = window.location.hash.substr(1).split('&');
var PER_QUARTER = (params.indexOf('quarter') !== -1);
var DEPOS = (params.indexOf('depos') !== -1);
var YEARS = [2004, PER_QUARTER ? 2024.125 : 2024.00];
if (PER_QUARTER) YEARS[1] += 0.125;
if (DEPOS) { // deposition date
document.getElementById('depdate').checked = true;
} else {
document.getElementById('reldate').checked = true;
}
var AS_PERCENT = (params.indexOf('percent') !== -1);
if (AS_PERCENT) {
document.getElementById('rel').checked = true;
} else {
document.getElementById('abs').checked = true;
}
d3.json('data.json', function(json) {
document.getElementById("loading").innerText = "SORTING DATA...";
window.setTimeout(function() { setup(json); }, 0);
});
function setup(json) {
var SOURCES = {
'H': 'home source',
'F': 'XFEL (any)',
'?': 'synchrotron',
'-': 'unspecified',
'a': 'APS (US, IL)',
'e': 'ESRF (FR)',
'd': 'Diamond LS (UK)',
's': 'Swiss LS (CH)',
'A': 'ALS (US, Cal)',
'S': 'Stanford SRL (US)',
'n': 'NSLS (US, NY)',
'h': 'Shanghai SRF (CN)',
'p': 'Photon Factory (JP)',
'8': 'SPring-8 (JP)',
'b': 'BESSY (DE)',
'u': 'Australian S (AU)',
'f': 'SOLEIL (FR)',
'k': 'PAL/PLS (KR)',
'c': 'CLSI (CA)',
't': 'NSRRC (TW)',
'C': 'CHESS (US, NY)',
'm': 'MAX (SE)',
'D': 'DESY (DE)',
'L': 'LNLS (BR)',
'Z': 'ALBA (ES)',
'E': 'Elettra (IT)',
'B': 'Beijing SRF (CN)',
'U': 'SRS (UK)',
'I': 'Indus (IN)',
'y': 'SLAC (US, Cal)',
'K': 'KSRS (RU, Moscow)',
'z': 'CAMD (US, LA)',
'i': 'AichiSR (JP)',
'g': 'SAGA-LS (JP)',
'T': 'Siam Photon P. (TH)',
};
var DETECT = ['?', 'CCD', 'PAD', 'IP'];
var DETECT_FULL = ['Not specified', 'CCD', 'Pixel Array Detector',
'Image Plate'];
var REDUC_SOFT = { 'X':'XDS', 'H':'HKL', 'M':'Mosflm', 'd':'d*TREK',
'D':'DIALS', 'O': 'Other', '-':'unknown' };
var SCALE_SOFT = { 'A':'Aimless', 'S':'SCALA', 'H':'HKL', 'X':'XSCALE',
'd':'d*TREK', 'O': 'Other', '-':'unknown' };
var REF_SOFT = { 'R':'Refmac', 'P':'Phenix', 'B':'BUSTER', 'C': 'CNS',
'-':'other/mix' };
var STRUCT_SOL = ['known structure', 'MR', 'SAD', 'MAD', 'MIR/SIR',
'SIRAS', 'MIRAS', 'unspecified / other'];
function reuse_d0_for_date() {
var date_field = DEPOS ? 8 : 9; // d[8] is dep. date, d[9] is release date
if (PER_QUARTER) {
json.forEach(function (d) {
d[0] = ((d[date_field] >> 5) / 3) | 0;
});
} else {
json.forEach(function (d) {
d[0] = ((d[date_field] >> 5) / 12) | 0;
});
}
}
reuse_d0_for_date();
// Examples of dc.lineChart and seriesChart use a list of to items
// as dimension. For large number of rows, sorting lists inside
// dimension() is very slow, ~100x times slower than sorting numbers.
// It was too slow, so we switched to using bit manipulations instead.
var data = crossfilter();
data.add(json);
var facil_dim = data.dimension(function(d) { return d[1]; });
var detec_dim = data.dimension(function(d) { return (d[2] << 16) | d[0]; });
var solution_dim = data.dimension(function(d) { return (d[6] << 16) | d[0]; });
var reduc_dim = data.dimension(function(d) { return (d[3].charCodeAt(0) << 16) | d[0]; });
var scaling_dim = data.dimension(function(d) { return (d[3].charCodeAt(1) << 16) | d[0]; });
var ref_dim = data.dimension(function(d) { return (d[3].charCodeAt(2) << 16) | d[0]; });
d3.select('#loading').remove();
d3.select('#chart-facility').style('visibility', null);
d3.select('#all-data').style('visibility', null);
function setup_reset(chart) {
var root_el = chart.root().node();
var reset_el = root_el.getElementsByClassName('reset')[0];
reset_el.style.visibility = 'hidden';
reset_el.onclick = function() {
chart.filterAll();
dc.redrawAll();
return false;
};
}
function setup_plot(chart, dim) {
var gr = dim.group();
chart
.width(480)
.height(480)
.chart(function(c) { return dc.lineChart(c).renderDataPoints(true); })
.dimension(dim)
.group(gr)
.x(d3.scaleLinear().domain(YEARS))
.brushOn(false)
.clipPadding(10)
.elasticY(true)
.mouseZoomable(false)
.legend(dc.legend().x(60).y(30))
.keyAccessor(PER_QUARTER ? function(p) { return (p.key & 0xffff) / 4 + 1989.125; }
: function(p) { return (p.key & 0xffff) + 1989; })
.valueAccessor(function(p) {
if (AS_PERCENT) {
var key = chart.keyAccessor();
var all = chart.group().all();
var total = 0;
for (var i = 0; i < all.length; i++) {
if (key(all[i]) === key(p)) total += all[i].value;
}
return total !== 0 ? 100 * p.value / total : 0;
} else {
return p.value;
}
});
chart.xAxis().tickFormat(d3.format('d'));
chart.yAxis().tickFormat(d3.format('d'));
chart.margins().left += 10;
return chart;
}
facility_chart
.dimension(facil_dim)
.group(facil_dim.group())
.title(function(p) { return SOURCES[p.key] + ': ' + p.value; })
.order(function(a, b){ return b.value - a.value; })
.controlsUseVisibility(true)
.multiple(true).numberVisible(20);
setup_reset(facility_chart);
setup_plot(detec_chart, detec_dim)
.seriesAccessor(function(p) { return DETECT_FULL[p.key >> 16]; });
setup_plot(solution_chart, solution_dim)
.seriesAccessor(function(p) { return STRUCT_SOL[p.key >> 16]; });
setup_plot(reduc_chart, reduc_dim)
.seriesAccessor(function(p) { return REDUC_SOFT[String.fromCharCode(p.key >> 16)]; });
setup_plot(scaling_chart, scaling_dim)
.seriesAccessor(function(p) { return SCALE_SOFT[String.fromCharCode(p.key >> 16)]; });
setup_plot(refinement_chart, ref_dim)
.seriesAccessor(function(p) { return REF_SOFT[String.fromCharCode(p.key >> 16)]; });
var plots = [detec_chart, solution_chart, reduc_chart, scaling_chart, refinement_chart];
function set_x_axis_labels() {
var label = (DEPOS ? ' Deposition ' : 'Release ') + (PER_QUARTER ? 'Quarter' : 'Year');
for (var i = 0; i < plots.length; ++i) {
plots[i].xAxisLabel(label);
}
}
set_x_axis_labels();
var on_resize = function() {
dc.renderAll();
};
on_resize();
d3.select(window).on('resize', on_resize);
d3.selectAll('input').on('change', function() {
if (this.name === 'date') {
DEPOS = (this.value === 'deposit');
reuse_d0_for_date();
// removing and readding all data might be inefficient,
// but it's fast enough and I don't know a simpler way.
data.remove(function() { return true; });
data.add(json);
set_x_axis_labels();
dc.renderAll();
} else if (this.name === 'absolute') {
AS_PERCENT = (this.value === 'n');
dc.renderAll();
}
});
}
</script>
</body>
</html>