JsCifBrowser is a JavaScript codebase for viewing and applying dictionary Relational Expression Language (dREL) methods to Crystallographic Information Files (CIFs). To read and process local CIF and dictionary files within a web-browser it requires the HTML5 file reading extensions. The file access API is supported by several modern browsers, alegedly including Internet Explorer IE10. The Google Chrome browser requires the command line option "--allow-file-access-from-files" to switch local file access on.
Some of the dREL algorithms are numerically demanding, particularly if they involve looped data tables. Consequently a relatively efficient JavaScript engine is prefferable, such as SpiderMonkey in Firefox, or even better, the V8 engine in Chrome. Although this App is handled by Safari, the processing speed is a little inconvenient for general use.
This version is intended and designed to run purely locally, i.e. there is little point sticking it on a webserver someplace because it doesn't load remote dictionaries, or CIF files.
Point your HTML5 web browser at either the src/index.html file for a dictionary hierarchy inspired view, or src/interp.html for a more customary flat view of your CIF data.
A few basic things you might like to try.
load every dictionary file from data/ddlm simultaneously (shift click shift click in Firefox file browser popup ) load the nick.cif data file navigate the hierarchy and eval a few unknowns. Note that you can just choose the top-level dictionary cif.dic, and you will be prompted to load all of its dependencies as they are being resolved. The latter approach is a little tedious, though necessary to work within the Web Browser security model.
Now that DDLm has aliases implemented, potentially you could load DDLm and a CIF-1.0 file like xtest0.cif and evaluate some missing items. But the results will be a mixed DDL CIF :-/
Potentially you could try to load a DDL2 dictionary and corresponding CIF, but that might be quite boring.
Potentially you could try to load a DDL1 dictionary and a corresponding CIF, but that might also be quite boring. (Recently tested and loading and linking now seems to work)
In this view, it is essential to load your dictionary(s) before you read in your CIF. Loading the CIF establishes all the cross linking and categorisation of the various data attributes, vital for building the hierarchy. When the CIF is loaded it is displayed simply as an abbreviated list of data_block_names. Selecting the "[+]" links should permit individual blocks to be navigated as desired.
In addition, for each data_block_name, there is a "Gen"(erate) control that permits certain categories to be "calculated" via their category Evaluation methods (e.g. model_site) Hover the mouse cursor over the Gen control for a second or so to activate the popup, then choose the desired category. Categories below the marker line in the popup list are missing and have no Evaluation method so will just be added as empty categories.
Similarly, for sub categories and sub-sub categories there are "Add" controls to add absent sub-categories or missing data_items to selective categories.
If particular data items have an associated dictionary Evaluation method then you may like to simply click the "Eval" control and sit back in amazement as various "Alert" windows pop up to annoy you. Various "Evaluation" methods are being harvested from the loaded dictionary, transformed to javascript, compiled and evaluated as necessary.
In this mode a default, pre-parsed dictionary is pre-loaded with the page. You can optionally load an alternative dictionary if you wish, but you should do this before loading your CIF.
Because there are no hierarchical cues regarding possible missing categories or attributes, you will need to remember them and enter them as text strings into the command menu. These commands only apply to a single CIF data_block, so you will need to choose the relevant data_block from the selector first. Category commands like "geom_bond" should have the desired effect.
To use this software from the command line in a Linux or Mac environment you need to have Node.js suite installed. Node.js is built on Google Chrome's V8 JavaScript engine and is prebuilt and packaged for various computing platforms (e.g. as "node" in Ubuntu, or "nodejs" in Debian)
When a CIF file is read it is tokenized and parsed using a STAR grammar built by Jison. The output is a Javascript hierarchical object rendered to text as a JSON object.
cd data ../src/util/star_reader.js nick.cif
Similarly we can read a CIF dictionary and render it as JSON, albeit with a wrapper layer to assist with loading:
cd data ../src/util/dic2json.js core_3.dic
For folks specifically interested in the parsing of dREL expressions, the expression parser can be invoked directly to see a JSON representation of the Abstract Syntax Tree as well as the transformed JavaScript as follows:
cd src/drel ./ast.js ./ex1.drel
But more usefully, we can write a script like drel.js, provide it with a dictionary and a CIF data file and ask it to evaluate a few things programmatically:
cd data ../src/util/drel.js ../dic/ddlm/cif.dic nick.cif
This implementation uses