CIF/STAR file support for Python
PyCIFRW provides support for reading and writing CIF (Crystallographic Information Format) files using Python. It was developed at the Australian National Beamline Facility (ANBF), run by the Australian Synchrotron Research Program (ASRP), as part of a larger project to provide CIF input/output capabilities for data collection. It is now (Nov 2022) maintained and developed within the Australian Nuclear Science and Technology Organisation (ANSTO).
The specifications found in Vol G of the International Tables for Crystallography were used as a reference for CIF 1.0/1.1 syntax. http://dx.doi.org/10.1107/S1600576715021871 was used as the CIF 2.0 reference.
PyCifRW has been tested on the IUCr sample CIF1.1 trip files located at http://www.iucr.org/iucr-top/cif/developers/trip and fails or successfully reads as it is supposed to (note that ciftest5 contains characters now forbidden in CIFs).
PyCIFRW is written entirely in Python, and so should run wherever Python runs. Any failures on Mac, Windows or Linux should be communicated to the author, either through the Github issues tracker (http://github.com/jamesrhester/pycifrw/issues) or email.
The source code of a C extension module is also included in the distribution. This module accelerates CIF file reading. From time to time system-dependent installation packages are generated containing precompiled versions of this module.
See file [INSTALLATION](https://github.com/jamesrhester/pycifrw/blob/development/INSTALLATION).
PyCIFRW is made available using the Python 2.0 license. The full text is [here](https://github.com/jamesrhester/pycifrw/blob/development/LICENSE)
See the various files in the docs directory for details of the interface. Essentially, CIF files look like python dictionaries, with each entry in the dictionary corresponding to a data block. The blocks themselves are also dictionaries, with each data name being a single entry in the dictionary, so for example, cf[‘si_std’][‘_diffrn_meas_wavelength’] will return the value of _diffrn_meas_wavelength in the data block named si_std of the Cif file object cf.
To read in a CIF:
from CifFile import ReadCif cf = ReadCif(‘jun_01_2.cif’)
to access information in a CIF
wav = cf[‘si_std’][‘_diffrn_meas_wavelength’]
to set a value
cf[‘si_std’][‘_diffrn_meas_wavelength’] = 1.54
The file ‘TestPyCIFRW.py’ in the source distribution contains around 170 tests of PyCIFRW functionality and is a good source of examples for using both simple and advanced PyCIFRW interfaces.
The “Programs” directory in the source distribution contains simple example programs. Of interest are validate_cif.py which validates a data files against data dictionaries (execute this file at a terminal prompt without arguments for a help message) and output_asciidoc.py which will convert a DDLm dictionary into an asciidoc document that can then be converted to HTML or other presentation formats.
PYCIFRW License Agreement (Python License, Version 2)
1. This LICENSE AGREEMENT is between the Australian Nuclear Science and Technology Organisation (“ANSTO”), and the Individual or Organization (“Licensee”) accessing and otherwise using this software (“PyCIFRW”) in source or binary form and its associated documentation.
2. Subject to the terms and conditions of this License Agreement, ANSTO hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use PyCIFRW alone or in any derivative version, provided, however, that this License Agreement and ANSTO’s notice of copyright, i.e., “Copyright (c) 2001-2014 ANSTO; All Rights Reserved” are retained in PyCIFRW alone or in any derivative version prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on or incorporates PyCIFRW or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to PyCIFRW.
4. ANSTO is making PyCIFRW available to Licensee on an “AS IS” basis. ANSTO MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, ANSTO MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYCIFRW WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
5. ANSTO SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYCIFRW FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYCIFRW, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material breach of its terms and conditions.
7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between ANSTO and Licensee. This License Agreement does not grant permission to use ANSTO trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party.
8. By copying, installing or otherwise using PyCIFRW, Licensee agrees to be bound by the terms and conditions of this License Agreement.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for PyCifRW-4.4.6-cp311-cp311-manylinux_2_5_x86_64.whl