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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@atomistics/xyz

v1.0.0

Published

An xyz chemical file format parser and tools for interacting with xyz files.

Readme

@atomistics/xyz

An xyz chemical file format parser and tools for interacting with xyz files.

Install

For use in your scripts:

npm i --save @atomistics/xyz

To install it globally and use the provided cli scripts:

npm i -g @atomistics/xyz

Example

const xyz = require('@atomistics/xyz');

// xyz assumes we're going to get a trajectory, so it will return
// an array of images. Note that we grab the zeroth image.
const caffeine = xyz(`24
Caffeine
H      -3.3804130    -1.1272367     0.5733036
N       0.9668296    -1.0737425    -0.8198227
C       0.0567293     0.8527195     0.3923156
N      -1.3751742    -1.0212243    -0.0570552
C      -1.2615018     0.2590713     0.5234135
C      -0.3068337    -1.6836331    -0.7169344
C       1.1394235     0.1874122    -0.2700900
N       0.5602627     2.0839095     0.8251589
O      -0.4926797    -2.8180554    -1.2094732
C      -2.6328073    -1.7303959    -0.0060953
O      -2.2301338     0.7988624     1.0899730
H       2.5496990     2.9734977     0.6229590
C       2.0527432    -1.7360887    -1.4931279
H      -2.4807715    -2.7269528     0.4882631
H      -3.0089039    -1.9025254    -1.0498023
H       2.9176101    -1.8481516    -0.7857866
H       2.3787863    -1.1211917    -2.3743655
H       1.7189877    -2.7489920    -1.8439205
C      -0.1518450     3.0970046     1.5348347
C       1.8934096     2.1181245     0.4193193
N       2.2861252     0.9968439    -0.2440298
H      -0.1687028     4.0436553     0.9301094
H       0.3535322     3.2979060     2.5177747
H      -1.2074498     2.7537592     1.7203047
`)[0];

// The atomic numbers of each atom.
console.log(caffeine.numbers);

> [ 1, 7, 6, 7, 6, 6, 6, 7, 8, 6, 8, 1, 6, 1, 1, 1, 1, 1, 6, 6, 7, 1, 1, 1 ]

// xyz will package the positions into an ndarray.
console.log(caffeine.positions.data);

> Float64Array [  -3.380413, -1.1272367, 0.5733036, ... 1.7203047 ]

API

const xyz = require("@atomistics/xyz");

const trajectory = xyz(data);

| Parameter | Type | Description | | --------- | ------ | ------------------------------- | | data | string | xyz file chemical format string |

Returns a list of images, where each image contains the atomic numbers and atom positions:

| Name | Type | Description | | ----------------------- | ------------------------------------------- | ------------------------------------------------------------------------- | | trajectory[N].numbers | int array | An array of atomic numbers. | | trajectory[N].positions | ndarray | An ndarray of shape [atom count, 3] containing the position of each atom. |

CLI

xyz2json

xyz2json inputfile.xyz

Converts inputfile.xyz to json and prints the result to stdout.

Example:

$ xyz2json h2.xyz > h2.json
$ cat h2.json

[{"positions":[0,0,0,1,0,0],"numbers":[1,1]}]

xyz2js

xyz2js inputfile.xyz

Converts inputfile.xyz to a javascript module and prints the result to stdout.

Example:

$ xyz2js h2.xyz > h2.js
$ cat h2.js

const ndarray = require("ndarray");

const data = JSON.parse('[{"positions":[0,0,0,1,0,0],"numbers":[1,1]}]');

module.exports = data.map(d => {
  return {
    positions: ndarray(new Float64Array(d.positions), [d.positions.length/3, 3]),
    numbers: d.numbers,
  };
});