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

@kkitahara/cif-tools

v2.1.0

Published

ECMAScript modules for reading Crystallographic Information File (CIF).

Downloads

20

Readme

JavaScript Style Guide license pipeline status coverage report version bundle size downloads per week downloads per month downloads per year downloads total

CIFTools

ECMAScript modules for manipulating Crystallographic Information File (CIF).

Currently, following functionalities are implemented:

  • reading (from a CIF 1.1 or CIF2.0 string to a CIF object)
  • translation of a data value by using DDL1 dictionaries

New functionalities, for example,

  • writing (from a CIF object to a CIF string)
  • validation
  • support for DDL2, DDLm and dREL

may be added on (author's) demand in future.

Instllation

npm install @kkitahara/cif-tools

Examples

import { CIF, Dict } from '@kkitahara/cif-tools'

Construct a CIF object from a string

let cif = CIF.fromCIFString(`#\\#CIF_2.0
    data_my_awesome_crystal
      _cell_length_a 1.00(1)
      _cell_length_b 2.00(2)
      _cell_length_c 3.00(3)

    data_My_Ordinary_Crystal
      _cell_length_a 1.0(1)
      _cell_length_b 2.0(2)
      _cell_length_c 3.0(3)

    data_MY_AWFUL_CRYSTAL
      _CELL_LENGTH_A 1.0(10)
      _CELL_LENGTH_B 2.0(20)
      _CELL_LENGTH_C 3.0(30)
`)
cif instanceof CIF // true

Extract block codes from a CIF object

let blockCodes = CIF.getBlockCodes(cif)

blockCodes[0] // 'my_awesome_crystal'
blockCodes[1] // 'my_ordinary_crystal'
blockCodes[2] // 'my_awful_crystal'

:memo: block codes are case folded

Extract a data block from a CIF object

let block = CIF.getBlock(cif, 'my_awful_crystal')

Extract a raw data value from a block

let val = CIF.getDataValue(block, '_cell_length_a')

// A raw data value is contained in an array
val.length // 1
val[0] // '1.0(10)'

:memo: tag (data name) is case-insensitive

Get dictionaries to which blocks in a given cif corform

let dicts = Dict.getConformDicts(cif)

// A dictionary for a block
let dict = dicts['my_awful_crystal']

Translate a data value by using a dictionary

let translated = Dict.translate(dict, '_cell_length_a', val[0])
translated.value // 1
translated.su // 1

The data structure of CIF objects conforms to JSON representation of CIF information (DRAFT)

cif['CIF-JSON']['my_awesome_crystal']['_cell_length_a'][0] // '1.00(1)'

JSON.stringify

let str = JSON.stringify(cif)

JSON.parse

cif = JSON.parse(str, CIF.reviver)
cif instanceof CIF // true

ESDoc documents

For more examples, see ESDoc documents:

cd node_modules/@kkitahara/cif-tools
npm install --only=dev
npm run doc

and open doc/index.html in your browser.

Deviations from specs

  • CIF 1.1 (specification)
    • A <WhiteSpace> is inserted before the first <value> of <LoopBody>, otherwise the first <value> cannot be distinguished from the last <Tag> in loops by the lexer.
  • CIF 2.0 (specification)
    • Sequences [wspace], [comment] appear in the productions CIF2-file and wspace-data-value are replaced by [wspace [comment]], otherwise comments can follow the preceding token without any white spaces.
    • The specification does not mention the uniqueness of table keys. As for the CIF-JSON object, the keys must be unique. Therefore, the uniqueness (case sensitive manner) of the keys is required in this software.

LICENSE

© 2019 Koichi Kitahara
Apache 2.0