npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mtz

v0.1.0

Published

MTZ reflection data to density map (structural biology)

Downloads

3

Readme

MTZ reader in WebAssembly

The MTZ file format is used for the storage of reflection data -- the data from diffraction experiments in macromolecular crystallography.

This library is primarily intended for web-based molecular viewers. It can read MTZ file and transform map coefficients (reciprocal space) to a density map (real space).

  • It is part of GEMMI (license: MPL 2.0), and it is built on the C++ code documented here.
  • It uses PocketFFT (license: MIT) for discrete Fourier transform.
  • It uses Emscripten to compile C++ to WASM + JS

Emscripten is run with option MODULARIZE, which wraps everything in a function which produces a module instance:

var module = GemmiMtz();

WASM code needs to be first compiled. To wait until everything is ready use a promise-like then method:

GemmiMtz().then(function(module) {
  mtz = module.readMtz(array_buffer);
  ...
  mtz.delete();
});

The readMtz function above takes ArrayBuffer with the content of an MTZ files and returns Mtz object with:

  • cell -- object representing unit cell with properties corresponding to cell parameters (a, b, c, alpha, beta, gamma),
  • calculate_map_from_labels(f_label: string, phi_label: string) -- calculates a map by transforming map coefficients from the requested columns; returns Float32Array (length == nx * ny * nz) representing density values on the grid,
  • calculate_map(diff_map: Boolean) -- calculates a map with default labels:
    • FWT/PHWT or 2FOFCWT/PH2FOFCWT for normal map (diff_map===false),
    • DELFWT/PHDELWT or FOFCWT/PHFOFCWT for difference map,
  • last_error -- contains error message if the functions above return null,
  • nx, ny, nz -- dimension of the last calculated map (necessary to interpret the flat array as a 3D array),
  • rmsd -- also a property of the last calculated map,
  • delete() -- frees the allocated memory (inside the WebAssembly instance's memory).

calculate_map returns a map as a Float32Array view of the WASM memory. This view is invalidated when the next map is calculated, so you may want to copy it first.

You can see it in action on https://uglymol.github.io/view/