rugnux live maps: one unit cell centred on the model; the viewer opens on all of it

/rugnux/map.ccp4 now serves one unit cell of map, centred on the model, instead of the model's box plus
5 A; along an axis where the model reaches further than the cell (a predicted model with long termini
in a small cell), the model plus 5 A instead, so that all of it has density. The Mol* viewer opens on
the whole cell and the model (map radius 0); a radius still draws the maps only around the centre of
view, Coot-style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
(cherry picked from commit 1c1e1d96359f112d6820d972005e9f7eca4ebd50)
This commit is contained in:
leonarski_f committed 2026-10-22 20:18:51 +02:00
1 parent 90bbba33bc
commit ee016d3d13
9 files changed
+69 -36

No files matched your search

+3 -3
View File
@@ -3641,9 +3641,9 @@ paths:
summary: Get an electron-density map of the last rugnux live run
description: |
The map of the placed model (`/rugnux/model.cif`) in CCP4 format (mode 2, float), made from the map
coefficients written to `_maps.mtz`. It covers the box around the model plus 5 A on every side, sampled
every d_min/3; the mean and RMS in its header are those of the whole unit cell, so contour levels in
sigma are the usual ones.
coefficients written to `_maps.mtz`. It covers one unit cell centred on the model - along an axis where
the model reaches further than the cell, the model plus 5 A instead - sampled every d_min/3; the mean and
RMS in its header are those of the unit cell, so contour levels in sigma are the usual ones.
parameters:
- in: query
name: type
+4 -4
View File
@@ -872,9 +872,9 @@ metadata (entities, sequences, references, authors, software) kept. Kept as long
</div></button></div><div><button class="sc-kzqdkY gnmLmb" disabled=""><strong class="sc-dSIIpw bpEYcE">404<!-- --> </strong><div class="sc-eeDRCY sc-eBMEME sc-dCFHLb gTGgei kekOtA kCaLQd"><p>The last rugnux live run placed no model</p>
</div></button></div></div></div><div class="sc-iGgWBj sc-gsFSXq ibAZSi eDeKjd"><div class="sc-ejfMa-d bNUPQg"><button class="sc-EgOXT cFEcOl"><span type="get" class="sc-eZYNyq qGfV http-verb get">get</span><span class="sc-iEXKAA gUNSDu">/rugnux/model.cif</span><svg class="sc-cwHptR iVFMLx" style="margin-right:-25px" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></button><div aria-hidden="true" class="sc-dlWCHZ kWacYr"><div class="sc-hHOBiw cndTNO"><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Test Jungfraujoch system</p>
</div><div tabindex="0" role="button"><div class="sc-kWtpeL gEncxT"><span>http://localhost:5232</span>/rugnux/model.cif</div></div></div></div></div></div></div></div><div id="/paths/~1rugnux~1map.ccp4/get" data-section-id="/paths/~1rugnux~1map.ccp4/get" class="sc-dcJsrY cqVkUp"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh"><a class="sc-jlZhew kbdRLs" href="#/paths/~1rugnux~1map.ccp4/get" aria-label="/paths/~1rugnux~1map.ccp4/get"></a>Get an electron-density map of the last rugnux live run<!-- --> </h2><div class="sc-bVVIoq icSMtY"><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>The map of the placed model (<code>/rugnux/model.cif</code>) in CCP4 format (mode 2, float), made from the map
coefficients written to <code>_maps.mtz</code>. It covers the box around the model plus 5 A on every side, sampled
every d_min/3; the mean and RMS in its header are those of the whole unit cell, so contour levels in
sigma are the usual ones.</p>
coefficients written to <code>_maps.mtz</code>. It covers one unit cell centred on the model - along an axis where
the model reaches further than the cell, the model plus 5 A instead - sampled every d_min/3; the mean and
RMS in its header are those of the unit cell, so contour levels in sigma are the usual ones.</p>
</div></div><div class="sc-jaXxmE eqYzvz"><div class="sc-iMTnTL fkPTul"><h5 class="sc-dAlyuH sc-hwdzOV jbQuod JjoyL">Authorizations:</h5><svg class="sc-cwHptR iZRiKW" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></div><div class="sc-krNlru gkwgxc"><span class="sc-jMakVo bPNrjo"><span class="sc-ihgnxF jlNGfN"><i>bearerAuth</i></span></span></div></div><div><h5 class="sc-dAlyuH jbQuod">query<!-- --> Parameters</h5><table class="sc-dAbbOL ccPhmY"><tbody><tr class="last "><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="type"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">type</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">string</span></div><div><span class="sc-Nxspf cXxAXt"> <!-- -->Default:<!-- --> </span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">&quot;2fofc&quot;</span></div><div><span class="sc-Nxspf cXxAXt"> <!-- -->Enum<!-- -->:</span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">&quot;2fofc&quot;</span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">&quot;fofc&quot;</span> </div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p><code>2fofc</code>: the 2mFo-DFc map; <code>fofc</code>: the mFo-DFc difference map</p>
</div></div></div></td></tr></tbody></table></div><div><h3 class="sc-fMMURN egoxtT">Responses</h3><div><button class="sc-kzqdkY jgSwKD"><svg class="sc-cwHptR hWEnWx" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg><strong class="sc-dSIIpw bpEYcE">200<!-- --> </strong><div class="sc-eeDRCY sc-eBMEME sc-dCFHLb gTGgei kekOtA kCaLQd"><p>Map</p>
</div></button></div><div><button class="sc-kzqdkY bXzzUN"><svg class="sc-cwHptR cSkZlF" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg><strong class="sc-dSIIpw bpEYcE">400<!-- --> </strong><div class="sc-eeDRCY sc-eBMEME sc-dCFHLb gTGgei kekOtA kCaLQd"><p>Unknown map type</p>
@@ -1113,7 +1113,7 @@ then image might be replaced in the buffer between calling /images and /image.cb
</div></button></div></div></div><div class="sc-iGgWBj sc-gsFSXq ibAZSi eDeKjd"><div class="sc-ejfMa-d bNUPQg"><button class="sc-EgOXT cFEcOl"><span type="get" class="sc-eZYNyq qGfV http-verb get">get</span><span class="sc-iEXKAA gUNSDu">/version</span><svg class="sc-cwHptR iVFMLx" style="margin-right:-25px" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></button><div aria-hidden="true" class="sc-dlWCHZ kWacYr"><div class="sc-hHOBiw cndTNO"><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Test Jungfraujoch system</p>
</div><div tabindex="0" role="button"><div class="sc-kWtpeL gEncxT"><span>http://localhost:5232</span>/version</div></div></div></div></div></div></div></div></div><div class="sc-dExYaf gZbfaQ"></div></div></div>
<script>
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.3","info":{"title":"Jungfraujoch","description":"API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland).\nJungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU.\nJungfraujoch uses FPGA boards to acquire data at high data rates.\n\n# License Clarification\n\nWhile this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply**\nwhen this file is used solely to generate OpenAPI clients or when implementing applications that\ninteract with the API. Generated client code and applications using this API definition are not\nsubject to the GPL license requirements and may be distributed under terms of your choosing.\n\nThis exception is similar in spirit to the Linux Kernel's approach to userspace API headers and\nthe GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that\nuser programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not\nderivative works of the kernel and are not subject to the terms of the GPL.\n\nThis exception is intended to allow wider use of this API specification without imposing GPL\nrequirements on applications that merely interact with the API, regardless of whether they\ncommunicate through network calls or other mechanisms.\n","version":"1.0.0-rc.178","contact":{"name":"Filip Leonarski (Paul Scherrer Institute)","email":"filip.leonarski@psi.ch"},"license":{"name":"GPL-3.0","url":"https://www.gnu.org/licenses/gpl-3.0.html"}},"servers":[{"url":"http://localhost:5232","description":"Test Jungfraujoch system"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Per-dataset secret. `/start` may carry one or more equivalent `tokens`; while the current\ndataset has any, the operations marked with this scheme require `Authorization: Bearer <token>`\nand answer 401 otherwise. A dataset started without `tokens` is not protected and the header is ignored.\n"}},"parameters":{"binning":{"in":"query","name":"binning","required":false,"schema":{"default":1,"type":"integer"},"description":"Binning of frames for the plot (0 = default binning)"},"experimental_coord":{"in":"query","name":"experimental_coord","required":false,"schema":{"type":"boolean","default":false},"description":"If measurement has goniometer axis defined, plot X-axis will represent rotation angle\nIf measurement has grid scan defined, plot X-axis and Y-axis will represent grid position, Z will be used as the final value\nFor still measurement the number is ignored\n"},"azint_unit":{"in":"query","name":"azint_unit","required":false,"schema":{"type":"string","enum":["Q_recipA","d_A","two_theta_deg"],"default":"Q_recipA"},"description":"Unit used for azim int.\n"},"fill_value":{"in":"query","name":"fill","required":false,"schema":{"type":"number","format":"float"},"description":"Fill value for elements that were missed during data collection\n"},"plot_type":{"in":"query","name":"type","required":true,"description":"Type of requested plot","schema":{"type":"string","enum":["bkg_estimate","spindle_blind_fraction","azint","azint_1d","spot_count","spot_count_low_res","spot_count_indexed","spot_count_ice","indexing_rate","indexing_lattice_count","indexing_unit_cell_length","indexing_unit_cell_angle","profile_radius","mosaicity","b_factor","error_pixels","saturated_pixels","image_collection_efficiency","receiver_delay","receiver_free_send_buf","strong_pixels","roi_sum","roi_mean","roi_max_count","roi_pixels","roi_weighted_x","roi_weighted_y","packets_received","max_pixel_value","resolution_estimate","pixel_sum","processing_time","beam_center_x","beam_center_y","integrated_reflections","image_scale_factor","image_scale_cc","compression_ratio","ice_ring_score"]}},"roi":{"in":"query","name":"roi","required":false,"schema":{"type":"string","minLength":1},"description":"Name of ROI for which plot is requested"},"image_id":{"in":"query","name":"id","required":false,"schema":{"type":"integer","format":"int64","default":-1,"minimum":-2},"description":"Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer"},"saturation":{"in":"query","name":"saturation","required":false,"schema":{"type":"number","format":"float","minimum":-32767,"maximum":32767},"description":"Saturation value to set contrast in the preview image; if not provided, then autocontrast procedure is used"},"background":{"in":"query","name":"background","required":false,"schema":{"type":"number","format":"float","default":0,"minimum":-32767,"maximum":32767},"description":"Background value to set contrast in the preview image"},"show_spots":{"in":"query","name":"show_spots","schema":{"type":"boolean","default":true},"description":"Show spot finding results on the image"},"show_predictions":{"in":"query","name":"show_predictions","schema":Line truncated
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.3","info":{"title":"Jungfraujoch","description":"API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland).\nJungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU.\nJungfraujoch uses FPGA boards to acquire data at high data rates.\n\n# License Clarification\n\nWhile this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply**\nwhen this file is used solely to generate OpenAPI clients or when implementing applications that\ninteract with the API. Generated client code and applications using this API definition are not\nsubject to the GPL license requirements and may be distributed under terms of your choosing.\n\nThis exception is similar in spirit to the Linux Kernel's approach to userspace API headers and\nthe GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that\nuser programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not\nderivative works of the kernel and are not subject to the terms of the GPL.\n\nThis exception is intended to allow wider use of this API specification without imposing GPL\nrequirements on applications that merely interact with the API, regardless of whether they\ncommunicate through network calls or other mechanisms.\n","version":"1.0.0-rc.178","contact":{"name":"Filip Leonarski (Paul Scherrer Institute)","email":"filip.leonarski@psi.ch"},"license":{"name":"GPL-3.0","url":"https://www.gnu.org/licenses/gpl-3.0.html"}},"servers":[{"url":"http://localhost:5232","description":"Test Jungfraujoch system"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Per-dataset secret. `/start` may carry one or more equivalent `tokens`; while the current\ndataset has any, the operations marked with this scheme require `Authorization: Bearer <token>`\nand answer 401 otherwise. A dataset started without `tokens` is not protected and the header is ignored.\n"}},"parameters":{"binning":{"in":"query","name":"binning","required":false,"schema":{"default":1,"type":"integer"},"description":"Binning of frames for the plot (0 = default binning)"},"experimental_coord":{"in":"query","name":"experimental_coord","required":false,"schema":{"type":"boolean","default":false},"description":"If measurement has goniometer axis defined, plot X-axis will represent rotation angle\nIf measurement has grid scan defined, plot X-axis and Y-axis will represent grid position, Z will be used as the final value\nFor still measurement the number is ignored\n"},"azint_unit":{"in":"query","name":"azint_unit","required":false,"schema":{"type":"string","enum":["Q_recipA","d_A","two_theta_deg"],"default":"Q_recipA"},"description":"Unit used for azim int.\n"},"fill_value":{"in":"query","name":"fill","required":false,"schema":{"type":"number","format":"float"},"description":"Fill value for elements that were missed during data collection\n"},"plot_type":{"in":"query","name":"type","required":true,"description":"Type of requested plot","schema":{"type":"string","enum":["bkg_estimate","spindle_blind_fraction","azint","azint_1d","spot_count","spot_count_low_res","spot_count_indexed","spot_count_ice","indexing_rate","indexing_lattice_count","indexing_unit_cell_length","indexing_unit_cell_angle","profile_radius","mosaicity","b_factor","error_pixels","saturated_pixels","image_collection_efficiency","receiver_delay","receiver_free_send_buf","strong_pixels","roi_sum","roi_mean","roi_max_count","roi_pixels","roi_weighted_x","roi_weighted_y","packets_received","max_pixel_value","resolution_estimate","pixel_sum","processing_time","beam_center_x","beam_center_y","integrated_reflections","image_scale_factor","image_scale_cc","compression_ratio","ice_ring_score"]}},"roi":{"in":"query","name":"roi","required":false,"schema":{"type":"string","minLength":1},"description":"Name of ROI for which plot is requested"},"image_id":{"in":"query","name":"id","required":false,"schema":{"type":"integer","format":"int64","default":-1,"minimum":-2},"description":"Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer"},"saturation":{"in":"query","name":"saturation","required":false,"schema":{"type":"number","format":"float","minimum":-32767,"maximum":32767},"description":"Saturation value to set contrast in the preview image; if not provided, then autocontrast procedure is used"},"background":{"in":"query","name":"background","required":false,"schema":{"type":"number","format":"float","default":0,"minimum":-32767,"maximum":32767},"description":"Background value to set contrast in the preview image"},"show_spots":{"in":"query","name":"show_spots","schema":{"type":"boolean","default":true},"description":"Show spot finding results on the image"},"show_predictions":{"in":"query","name":"show_predictions","schema":Line truncated
var container = document.getElementById('redoc');
Redoc.hydrate(__redoc_state, container);
+3 -3
View File
@@ -4081,9 +4081,9 @@ This endpoint does not need any parameter.
Get an electron-density map of the last rugnux live run
The map of the placed model (`/rugnux/model.cif`) in CCP4 format (mode 2, float), made from the map
coefficients written to `_maps.mtz`. It covers the box around the model plus 5 A on every side, sampled
every d_min/3; the mean and RMS in its header are those of the whole unit cell, so contour levels in
sigma are the usual ones.
coefficients written to `_maps.mtz`. It covers one unit cell centred on the model - along an axis where
the model reaches further than the cell, the model plus 5 A instead - sampled every d_min/3; the mean and
RMS in its header are those of the unit cell, so contour levels in sigma are the usual ones.
### Example
@@ -814,9 +814,9 @@ export const getRugnuxMapCcp4QueryKey = (options?: Options<getRugnuxMapCcp4Data>
* Get an electron-density map of the last rugnux live run
*
* The map of the placed model (`/rugnux/model.cif`) in CCP4 format (mode 2, float), made from the map
* coefficients written to `_maps.mtz`. It covers the box around the model plus 5 A on every side, sampled
* every d_min/3; the mean and RMS in its header are those of the whole unit cell, so contour levels in
* sigma are the usual ones.
* coefficients written to `_maps.mtz`. It covers one unit cell centred on the model - along an axis where
* the model reaches further than the cell, the model plus 5 A instead - sampled every d_min/3; the mean and
* RMS in its header are those of the unit cell, so contour levels in sigma are the usual ones.
*
*/
export const getRugnuxMapCcp4Options = (options?: Options<getRugnuxMapCcp4Data>) => queryOptions<getRugnuxMapCcp4Response, getRugnuxMapCcp4Error, getRugnuxMapCcp4Response, ReturnType<typeof getRugnuxMapCcp4QueryKey>>({
+3 -3
View File
@@ -456,9 +456,9 @@ export const getRugnuxModelCif = <ThrowOnError extends boolean = false>(options?
* Get an electron-density map of the last rugnux live run
*
* The map of the placed model (`/rugnux/model.cif`) in CCP4 format (mode 2, float), made from the map
* coefficients written to `_maps.mtz`. It covers the box around the model plus 5 A on every side, sampled
* every d_min/3; the mean and RMS in its header are those of the whole unit cell, so contour levels in
* sigma are the usual ones.
* coefficients written to `_maps.mtz`. It covers one unit cell centred on the model - along an axis where
* the model reaches further than the cell, the model plus 5 A instead - sampled every d_min/3; the mean and
* RMS in its header are those of the unit cell, so contour levels in sigma are the usual ones.
*
*/
export const getRugnuxMapCcp4 = <ThrowOnError extends boolean = false>(options?: Options<getRugnuxMapCcp4Data, ThrowOnError>): RequestResult<getRugnuxMapCcp4Responses, getRugnuxMapCcp4Errors, ThrowOnError> => (options?.client ?? client).get<getRugnuxMapCcp4Responses, getRugnuxMapCcp4Errors, ThrowOnError>({
@@ -13,11 +13,12 @@ import {authHeaders, noteResponse} from "../auth";
// The model rugnux live placed, with its 2mFo-DFc and mFo-DFc maps, in a Mol* viewer (headless plugin: the
// render core and state tree, no Mol* UI). Mol* is only loaded with this component (React.lazy in
// RugnuxPage). The broker serves the maps cut to the box around the model, with the whole cell's mean and
// RugnuxPage). The broker serves the maps with the whole cell's mean and
// RMS in their headers, so the contour levels in sigma are the usual crystallographic ones.
//
// As in Coot, the maps are drawn only within a radius of the centre of view, which follows the camera (a click
// on an atom centres it): over the whole model the mesh at 1 sigma is a solid block.
// The broker serves one unit cell of each map, centred on the model (more where the model is wider than the
// cell), and the view opens on all of it. As in Coot, a radius can be set instead: the maps are then drawn only
// within it around the centre of view, which follows the camera (a click on an atom centres it).
const COLOR_2FOFC = 0x3b6fd6;
const COLOR_FOFC_POS = 0x2ca02c;
@@ -116,7 +117,7 @@ function RugnuxStructureViewer({resultKey}: { resultKey: string }) {
const [sigma1, setSigma1] = useState(3.0);
const [show2, setShow2] = useState(true);
const [show1, setShow1] = useState(true);
const [radius, setRadius] = useState(10);
const [radius, setRadius] = useState(0);
// The levels as they are when a map is loaded, without making the loading depend on them.
const levels = useRef({sigma2, sigma1, show2, show1, radius});
levels.current = {sigma2, sigma1, show2, show1, radius};
@@ -204,15 +205,12 @@ function RugnuxStructureViewer({resultKey}: { resultKey: string }) {
await plugin.builders.structure.representation.addRepresentation(c,
{type: 'ball-and-stick', color: 'element-symbol'});
}
// The centre of view on the model, zoomed in to about the maps' sphere, before the maps: they
// are drawn around it.
// The model's centre, which a map radius is first drawn around.
plugin.managers.camera.reset(undefined, 0);
const target = plugin.canvas3d?.camera.state.target;
if (target)
Vec3.copy(centre.current, target);
const l = levels.current;
plugin.managers.camera.focusSphere(Sphere3D.create(Vec3.clone(centre.current), Math.max(l.radius, 10) + 4),
{durationMs: 0});
const clip = sphereClip(centre.current, l.radius);
if (map2) {
maps.current.twofofc = await loadMap(plugin, map2, "2mFo-DFc", [l.sigma2], [COLOR_2FOFC], clip);
@@ -224,6 +222,13 @@ function RugnuxStructureViewer({resultKey}: { resultKey: string }) {
setVisible(plugin, maps.current.fofc, l.show1);
setHasFofc(true);
}
// The view opens on all of it - the cell of map the broker serves and the model - or, with a map
// radius set, on the sphere of map around the model's centre.
if (l.radius > 0)
plugin.managers.camera.focusSphere(Sphere3D.create(Vec3.clone(centre.current), l.radius + 4),
{durationMs: 0});
else
plugin.managers.camera.reset(undefined, 0);
} catch (e) {
if (!abort.signal.aborted)
setError(e instanceof Error ? e.message : String(e));
@@ -306,13 +311,13 @@ function RugnuxStructureViewer({resultKey}: { resultKey: string }) {
</Stack>
<Stack direction="row" spacing={2} alignItems="center" sx={{maxWidth: 520}}>
<Typography sx={{whiteSpace: "nowrap"}}>
Maps within {radius > 0 ? `${radius} Å` : "the whole box"}</Typography>
Maps within {radius > 0 ? `${radius} Å of the centre` : "the whole cell"}</Typography>
<Slider value={radius} min={0} max={30} step={1} size="small"
onChange={(_, v) => setRadius(v as number)} aria-label="Map radius"/>
</Stack>
<Typography variant="body2" color="text.secondary">
Left drag rotates, right drag pans, wheel zooms, a click on an atom centres it; the maps are drawn
around the centre of view (radius 0: the whole box, the model plus 5 Å).
Left drag rotates, right drag pans, wheel zooms, a click on an atom centres it. The maps cover one unit
cell around the model; with a radius set they are drawn only that far around the centre of view.
</Typography>
</Stack>
);
+10 -1
View File
@@ -3,6 +3,7 @@
#include "RugnuxStructure.h"
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstring>
@@ -71,7 +72,15 @@ std::string RugnuxStructure::Map(RugnuxMapType type) const {
gemmi::Structure st = *model;
st.cell = mtz.unit_cell;
map.set_extent(gemmi::calculate_fractional_box(st, MAP_MARGIN_A));
const gemmi::Box<gemmi::Fractional> model_box = gemmi::calculate_fractional_box(st, MAP_MARGIN_A);
gemmi::Box<gemmi::Fractional> box;
for (int i = 0; i < 3; i++) {
const double centre = (model_box.minimum.at(i) + model_box.maximum.at(i)) / 2;
const double half = std::max(0.5, (model_box.maximum.at(i) - model_box.minimum.at(i)) / 2);
box.minimum.at(i) = centre - half;
box.maximum.at(i) = centre + half - 1e-9; // one cell is exactly one cell of grid points
}
map.set_extent(box);
std::string out(4 * map.ccp4_header.size() + sizeof(float) * map.grid.data.size(), '\0');
memcpy(out.data(), map.ccp4_header.data(), 4 * map.ccp4_header.size());
+4 -3
View File
@@ -29,14 +29,15 @@ class RugnuxStructure {
mutable std::optional<std::string> model_cif;
mutable std::optional<std::string> map_2fofc, map_fofc;
public:
// How far around the model the maps reach.
// How far the maps reach beyond the model where it is wider than the cell.
static constexpr double MAP_MARGIN_A = 5.0;
RugnuxStructure(std::shared_ptr<const gemmi::Structure> model, const UnitCell &cell,
const gemmi::SpaceGroup &space_group, std::optional<MtzTable> coefficients);
bool HasMaps() const;
std::string ModelCif() const;
// A CCP4 map (mode 2) on the box around the model, MAP_MARGIN_A wider on every side, sampled every d_min/3; the
// header's mean and RMS are those of the whole cell. Empty where there are no map coefficients.
// A CCP4 map (mode 2), sampled every d_min/3, on one unit cell centred on the model - along an axis the model
// reaches further than the cell, on the model plus MAP_MARGIN_A instead, so that all of it has density. The
// header's mean and RMS are those of the cell. Empty where there are no map coefficients.
std::string Map(RugnuxMapType type) const;
};
+23 -5
View File
@@ -60,10 +60,11 @@ namespace {
}
// The fractional position of the highest point of a CCP4 map read from `bytes`; lowest where `lowest`.
gemmi::Fractional Extremum(const std::string &bytes, bool lowest, size_t &points) {
gemmi::Fractional Extremum(const std::string &bytes, bool lowest, size_t &points, size_t &cell_points) {
gemmi::Ccp4<float> map;
map.read_ccp4_from_memory(bytes.data(), bytes.size(), "test");
points = map.grid.data.size();
cell_points = static_cast<size_t>(map.header_i32(8)) * map.header_i32(9) * map.header_i32(10);
const auto start = map.header_3i32(5);
const auto sampling = map.header_3i32(8);
size_t best = 0;
@@ -87,19 +88,36 @@ TEST_CASE("RugnuxStructure_MapPeaksAtTheAtom", "[RugnuxLive]") {
const std::string bytes = structure.Map(type);
REQUIRE(bytes.size() > 1024);
CHECK(bytes.substr(208, 4) == "MAP ");
size_t points = 0;
const gemmi::Fractional peak = Extremum(bytes, type == RugnuxMapType::FoFc, points);
size_t points = 0, cell_points = 0;
const gemmi::Fractional peak = Extremum(bytes, type == RugnuxMapType::FoFc, points, cell_points);
// Within one grid step (d_min/3 = 0.67 A, i.e. at most 0.022 of these cells).
CHECK(peak.x == Catch::Approx(ATOM_FRACT.x).margin(0.025));
CHECK(peak.y == Catch::Approx(ATOM_FRACT.y).margin(0.025));
CHECK(peak.z == Catch::Approx(ATOM_FRACT.z).margin(0.025));
// A box of 2 x 5 A around the atom, not the 30-odd A cell.
CHECK(points < 20 * 20 * 20);
// One unit cell (centred on the model, which is smaller than the cell).
CHECK(points == cell_points);
// Cached: the same bytes again.
CHECK(structure.Map(type) == bytes);
}
}
TEST_CASE("RugnuxStructure_MapCoversAModelWiderThanTheCell", "[RugnuxLive]") {
// A second atom 1.4 cells along a from the first: the map reaches along a over both, plus the margin.
auto st = OneAtomModel();
gemmi::Atom far = st->models[0].chains[0].residues[0].atoms[0];
far.name = "CB";
far.pos = st->cell.orthogonalize(gemmi::Fractional(ATOM_FRACT.x + 1.4, ATOM_FRACT.y, ATOM_FRACT.z));
st->models[0].chains[0].residues[0].atoms.push_back(far);
const RugnuxStructure structure(st, TEST_CELL, *gemmi::find_spacegroup_by_name("P 1"), PointCoefficients());
const std::string bytes = structure.Map(RugnuxMapType::TwoFoFc);
gemmi::Ccp4<float> map;
map.read_ccp4_from_memory(bytes.data(), bytes.size(), "test");
const double a_span_A = TEST_CELL.a * map.grid.nu / map.header_i32(8);
CHECK(a_span_A == Catch::Approx(1.4 * TEST_CELL.a + 2 * RugnuxStructure::MAP_MARGIN_A).margin(1.5));
CHECK(map.grid.nv == map.header_i32(9)); // one cell along b and c
CHECK(map.grid.nw == map.header_i32(10));
}
TEST_CASE("RugnuxStructure_ModelCif", "[RugnuxLive]") {
const RugnuxStructure structure(OneAtomModel(), TEST_CELL, *gemmi::find_spacegroup_by_name("P 1"), {});
CHECK(!structure.HasMaps());