CIFTools.js
A JavaScript library for handling text and binary CIF files.
Install / Use
/learn @dsehnal/CIFTools.jsREADME
What is CIFTools.js
CIFTools.js is a library for handling CIF files as defined by the specification here. It provides tools for reading and writing CIF files. Additionally, it supports an efficient binary encoding of CIF, called BinaryCIF.
Getting Started
CIFTools.js can be used both in the browser and on server (with Node.js). It is recommended to use TypeScript for building apps based on CIFTools.js (or any other non-trivial JavaScript app for that matter), because you will get code completion and type checking.
Check the examples directory for several basic use cases. For a more complicated use
case, please check the mmCIF reader in the LiteMol project.
Short example
In browser, include the library:
<script src="CIFTools.js" />
In Node.js:
var CIFTools = require('./lib/CIFTools.js/'); // or just 'CIFTools' if you place it in the /node_modules directory.
To parse text CIF, use:
var parsed = CIFTools.Text.parse(inputString);
For BinaryCIF, use:
var parsed = CIFTools.Binary.parse(inputArrayBuffer);
To get data from the result:
if (parsed.isError) {
// report error:
console.log(parsed.toString());
return;
}
var data = parsed.result.dataBlocks[0];
var _atom_site = data.getCategory('_atom_site');
var Cartn_x = _atom_site.getColumn('Cartn_x');
// gets a float value from the 1st row
var floatValue = Cartn_x.getFloat(0);
// the last residue sequence id
var intValue = _atom_site.getColumn('label_seq_id').getInteger(_atom_site.rowCount - 1);
var stringValue = data.getCategory('_entry').getColumn('id').getString(0);
Building
Install Node.js (tested on version 6.6.0).
npm install -g gulp
npm install
gulp
License
This project is licensed under the MIT license. See the LICENSE file for more info.
Support
If you have any questions, do not hesitate to email the author or use the GitHub forum.
Related Skills
node-connect
341.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
