Skip to content

Commit

Permalink
calendar.html: update and add choice of period
Browse files Browse the repository at this point in the history
one of 2011-2014, 2015-2018 or 2019-2022
  • Loading branch information
wojdyr committed Jul 11, 2024
1 parent 5a6fed5 commit 81a8ddb
Show file tree
Hide file tree
Showing 9 changed files with 350 additions and 116 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

These statistics serve as an example how to use `gemmi-grep`
(one of the utilities provided by the [project gemmi][1])
to quickly extract data from mmCIF files.
(one of the utilities provided by the [project gemmi][1])
to quickly extract data from mmCIF files.

The data is extracted from a local copy of the PDB archive in mmCIF format
(we rsync it once a week).
The data of interest is extracted from a local copy of the PDB archive
(mmCIF coordinate files) to a file `grep.out`:

We use `gemmi-grep` in the `extract.sh` script to extract all the needed
metadata (and some more).
Reading all the archive (34GB of compressed files) takes 20-30min.
The output is redirected to a file (`grep.out`) that is later used
$ ./extract.sh --auto

This script uses `gemmi-grep` to extract metadata to a file `grep.out`.
Reading all the archive (69GB of compressed files) takes about 30min.
The output is redirected to a file (`grep.out`) that is then used
to prepare JSON files used in our web pages.

### Filter-able statistics
Expand All @@ -30,7 +31,7 @@ https://project-gemmi.github.io/pdb-stats/

### Synchrotron work patterns

`./coldates.py >calendar.json` writes the data used in calendar.html:
`./coldates.py` prepares json files for calendar.html, see `extract.sh`.

https://project-gemmi.github.io/pdb-stats/calendar.html

Expand Down
39 changes: 34 additions & 5 deletions calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
body { font: 14px sans-serif; margin: 0; shape-rendering: crispEdges; }
h1 { text-align: center; font-size: 30px; font-weight: normal; }
h4 { text-align: center; font-size: 15px; font-weight: normal; }
h5 { text-align: center; font-size: 14px; font-weight: normal; }
h5 a { margin: 0 50px 0 50px; }
h2 { text-align: center; font-size: 18px; margin: 30px 0 0 0; }
.cal { min-height: 280px; padding-left: 50px; }
@media only screen and (max-width: 600px) { .cal { padding-left: 0; } }
Expand Down Expand Up @@ -42,7 +44,13 @@
<body>
<h1>Synchrotron Work Patterns</h1>
<h4>Data <a href="http://mmcif.wwpdb.org/dictionaries/mmcif_pdbx.dic/Items/_diffrn_detector.pdbx_collection_date.html">collection</a>
dates from <b>PDB entries released before 2021-01-21</b>.</h4>
dates from <b>PDB entries released before 2024-07-09</b>.</h4>

<h5>
<a href="#from2011">2011-2014</a>
<a href="#from2015">2015-2018</a>
<a href="#from2019">2019-2022</a>
</h5>

<div class="cal" id="APS">
<h2>APS <span style="background-image: url(flags/us.svg)"></span></h2>
Expand Down Expand Up @@ -111,7 +119,7 @@ <h2>all home sources</h2>
<div id="footnote" style="clear:both;">
This is part of the
<a href="https://project-gemmi.github.io/">project GEMMI</a>.
Uses <a href="https://bl.ocks.org/micahstubbs/89c6bd879d64aa511372064c6cf85711">this dc.js example</a>,
Uses <a href="https://bl.ocks.org/micahstubbs/89c6bd879d64aa511372064c6cf85711">this d3.js example</a>,
<a href="https://github.com/lipis/flag-icon-css">SVG flags</a> and
wwPDB data.
<p><b><a href="https://github.com/project-gemmi/pdb-stats">
Expand All @@ -122,6 +130,13 @@ <h2>all home sources</h2>
<script type="text/javascript">
"use strict";

var ystart = 2015;

const fragment = window.location.hash.slice(1);
if (fragment == "from2011" || fragment == "from2019") {
ystart = +fragment.slice(4);
}

var width = 520,
height = 60,
cellSize = 8;
Expand All @@ -144,8 +159,21 @@ <h2>all home sources</h2>
+ "H" + (w0 + 1) * cellSize + "Z";
}

d3.selectAll('h5 a')
.each(function() {
var h = this.getAttribute('href');
if (h === '#from' + ystart) {
d3.select(this).attr('href', null);
} else {
d3.select(this).on('click', function() {
window.location.href = 'calendar.html' + h;
window.location.reload();
});
}
});

var svg = d3.selectAll(".cal").selectAll("svg")
.data(d3.range(2015, 2019))
.data(d3.range(ystart, ystart+4))
.enter().append("svg")
.attr("width", width)
.attr("height", function(d, i) {
Expand Down Expand Up @@ -207,12 +235,13 @@ <h2>all home sources</h2>
"#202030", "#202020", "#1c1c1c", "#1c1c1c", "#1c1c1c",
"#000000"];

d3.json('calendar.json', function(error, json) {
d3.json('calendar'+ystart+'.json', function(error, json) {
if (error) throw error;
d3.selectAll(".cal").each(function() {
var data = {}
var syn_data = json[this.id];
for (var year = 2015; year < 2019; year++) {
for (var i = 0; i < 4; i++) {
var year = ystart + i;
var arr = syn_data[''+year];
for (var j = 0; j < arr.length; ++j) {
var key = format(new Date(year, 0, 1+j));
Expand Down
98 changes: 0 additions & 98 deletions calendar.json

This file was deleted.

98 changes: 98 additions & 0 deletions calendar2011.json

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions calendar2015.json

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions calendar2019.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion coldates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
'SOLEIL', 'PAL/PLS', 'CLSI', 'DESY']
ALL_OUTPUT = OUTPUT_SYN + ['home']

OUTPUT_YEARS = [2015, 2016, 2017, 2018]
FIRST_YEAR = int(sys.argv[1])
LAST_YEAR = int(sys.argv[2])
OUTPUT_YEARS = range(FIRST_YEAR, LAST_YEAR+1)

def days_in_year(year):
if year % 4 == 0:
Expand Down
9 changes: 6 additions & 3 deletions extract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# This web page is part of an example how to use gemmi-grep.
# gemmi-grep is an part of the GEMMI library, funded by GPhL and CCP4.

PATH="$PATH":../gemmi/build
PATH=../gemmi/build:"$PATH"
PYTHONPATH=../gemmi/build

# check that module gemmi is present
python3 -c "import gemmi"
[ "$1" = "--auto" ] && python3 -c "import gemmi"

gemmi grep --delimiter=';' \
_software.classification \
Expand Down Expand Up @@ -34,6 +35,8 @@ gemmi grep --delimiter=';' \
if [ "$1" = "--auto" ]; then
./process.py >data.json
sed -i s"/\(Last update:\) ....-..-../\1 $(date -Idate)/" xray.html
./coldates.py >calendar.json
./coldates.py 2011 2014 >calendar2011.json
./coldates.py 2015 2018 >calendar2015.json
./coldates.py 2019 2022 >calendar2019.json
sed -i s"/\(released before\) ....-..-../\1 $(date -Idate)/" calendar.html
fi
3 changes: 3 additions & 0 deletions process.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def parse_date(txt):
'NSLS': 'n NSLS (US, NY)',
'SSRF': 'h Shanghai SRF (CN)',
'Photon Factory': 'p Photon Factory (JP)',
'PHOTON FACTORY': 'p Photon Factory (JP)',
'SPring-8': '8 SPring-8 (JP)',
'BESSY': 'b BESSY (DE)',
'Australian Synchrotron': 'u Australian S. (AU)',
Expand All @@ -73,6 +74,7 @@ def parse_date(txt):
'EMBL/DESY, HAMBURG': 'D DESY (DE)',
'LNLS': 'L LNLS (BR)',
'LNLS SIRUS': 'L LNLS (BR)',
'LNLS SIRIUS': 'L LNLS (BR)',
'PETRA III EMBL c/o DESY': 'D DESY (DE)',
'PETRA II STORAGE RING': 'D DESY (DE)',
'ALBA': 'Z ALBA (ES)',
Expand Down Expand Up @@ -104,6 +106,7 @@ def parse_date(txt):
'LCLS': 'F SLAC (US, CA)',
'SLAC': 'F SLAC (US, CA)',
'SLAC LCLS': 'F SLAC (US, CA)',
'SwissFEL ARAMIS': 'F SwissFEL (CH)',

# ?
'SYNCHROTRON': '?',
Expand Down

0 comments on commit 81a8ddb

Please sign in to comment.