CIF/STAR file support for Python
Project description
PyCIFRW Readme
Introduction
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).
Conformance
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).
Supported Platforms
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.
Installation
See file [INSTALLATION](https://github.com/jamesrhester/pycifrw/blob/development/INSTALLATION).
License
PyCIFRW is made available using the Python 2.0 license. The full text is [here](https://github.com/jamesrhester/pycifrw/blob/development/LICENSE)
Use
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.
Example
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
Example programs
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PyCifRW-4.4.6.tar.gz
.
File metadata
- Download URL: PyCifRW-4.4.6.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02bf5975e70ab71540bff62fbef3e8354ac707a0f0ab914a152047962891ef15 |
|
MD5 | ad9bd137aed76984f8474559abab0805 |
|
BLAKE2b-256 | 5708e0811d3a6bd0895fef98a0341ba2bd4556c8bbc7287ea01f1a8db96214f6 |
File details
Details for the file PyCifRW-4.4.6-cp311-cp311-manylinux_2_5_x86_64.whl
.
File metadata
- Download URL: PyCifRW-4.4.6-cp311-cp311-manylinux_2_5_x86_64.whl
- Upload date:
- Size: 160.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a89844ed5811700f995d1913a248d29d5745078ffd0f957b7e0574d74a48d0df |
|
MD5 | 1dade1576e5565b978232ee62e550c27 |
|
BLAKE2b-256 | 6eb6b429e4f48960b19480111ed3812e0cd53be810f190a1f8c652e99149d47a |