Commit f6aefce
committed
Add electron density and cryo-EM map fetching with a fallback chain
Adds org.biojava.nbio.structure.io.density, which downloads and caches density
maps the same way LocalPDBDirectory caches coordinate files, and hands back a
File that a viewer can contour. Closes #947.
Several services publish density for the PDB and they differ enormously in size
for the same entry, so rather than picking one, sources are tried in order until
one answers. The order is smallest-adequate-first, because the smallest form is
usually perfectly good to look at:
X-ray: RCSB density server -> PDBe CCP4 -> PDBe density server
-> wwPDB map coefficients (disabled by default)
cryo-EM: RCSB density server -> PDBe density server -> EMDB primary map
For 1cbs a density server slice is about a tenth the size of the equivalent pair
of CCP4 files. For the map behind 6hu9 it is 3.7 MB against a 106 MB primary
map. A size limit, 256 MiB by default, is checked against the size EMDB itself
reports before any of the body is transferred, and exceeding it is not an error:
the chain simply falls back to a smaller representation.
wwPDB map coefficients are supported for completeness, since they are the route
RCSB documents now that edmaps.rcsb.org has shut down, but they are structure
factors rather than a sampled grid and cannot be displayed without a Fourier
transform. They are therefore disabled by default, and DensityFileFormat carries
an isJmolLoadable() flag so that a viewer can refuse them rather than silently
drawing nothing.
Notes on the design:
* A source that has nothing for an entry is skipped and the next is tried, but
any other transport failure aborts the chain. A network outage must never be
reported as "this entry has no density". When every source is exhausted,
NoDensityMapException carries the reason from each one, so a caller can say
why rather than just that it failed.
* A density server response contains both the 2Fo-Fc and the Fo-Fc blocks, so
the two kinds share one cache entry instead of downloading the identical file
twice. Which block to read is a display-time decision.
* Cryo-EM entries are found through their EMDB identifier, looked up from EMDB's
search API with RCSB as a fallback. That lookup also yields the contour level
the depositors recommend, which is how an EM map should be contoured; it is
attached to the result whichever source supplied the voxels. The experimental
method is never inferred from resolution, which BioJava parses incorrectly for
some cryo-EM entries (#1000).
* Ccp4Header checks for the MAP stamp at byte 208, so a server that answers with
an error page and HTTP 200 produces a clean cache miss rather than a corrupt
cache entry.
* Cached results are fully described by a .meta sidecar, so LOCAL_ONLY requests
are served without opening a connection.
DemoFetchElectronDensity exercises all three outcomes: an X-ray entry, a cryo-EM
entry resolved through EMDB, and an entry deposited without structure factors.1 parent 2a57e19 commit f6aefce
20 files changed
Lines changed: 3616 additions & 0 deletions
File tree
- biojava-structure/src/main/java
- demo
- org/biojava/nbio/structure/io/density
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments