This module includes a native Python mmCIF API for data files and dictionaries along with pybind11 wrappers for the PDB C++ Core mmCIF Library.
Download the library source software from the project repository:
git clone --recurse-submodules https://github.com/rcsb/py-mmcif.git
Optionally, run test suite using the Tox test runner. The C++ library bindings have been tested on Centos 7/Ubuntu 20.04 Linux with GCC/G++ > 4.8.5 and MacOS (10.15) with > clang-900.0.39.2 using Python versions 2.7.18 and 3.9.4.
tox
Installation is via the program pip.
pip install mmcif
or from the local repository:
pip install .
To generate API documentation using Sphinx:
cd scripts
# Check Sphinx dependencies in the introductory comments to the following script.
./initdocs.sh
build_dict_cli
is a command-line tool that serves as a preprocessor for modular mmCIF dictionaries. It resolves and combines dictionary components from multiple source files using include directives specified in categories such as pdbx_include_dictionary
, pdbx_include_category
, and pdbx_include_item
.
The tool allows dictionary maintainers to:
- Combine multiple dictionary extensions (or combining extension with a parent dictionary) into a single comprehensive dictionary
- Get dictionary version of the dictionary
build_dict_cli --help
usage: build_dict_cli [-h] --op OP --input_dict_path INPUT_DICT_PATH [--output_dict_path OUTPUT_DICT_PATH] [--cleanup]
optional arguments:
-h, --help show this help message and exit
--op OP Operation (build | get_version)
--input_dict_path INPUT_DICT_PATH
Path to dictionary generator file
--output_dict_path OUTPUT_DICT_PATH
Path to output dictionary text file
--cleanup Remove include instruction categories after processing
-
--op
: Specifies the operation to performbuild
: Generates a complete dictionary by processing includesget_version
: Retrieves and outputs the version of the specified dictionary
-
--input_dict_path
: Path to the dictionary generator file that contains include directives -
--output_dict_path
: Path where the combined output dictionary will be written -
--cleanup
: If specified, removes the include instruction categories from the final output
A generator file is a special mmCIF dictionary file that primarily contains include directives. This file serves as the entry point for the dictionary build process.
# mmcif_pdbx_v50-generator.dic
data_mmcif_pdbx.dic
#
loop_
_pdbx_include_dictionary.dictionary_id
_pdbx_include_dictionary.dictionary_locator
_pdbx_include_dictionary.include_mode
_pdbx_include_dictionary.dictionary_namespace_prefix
_pdbx_include_dictionary.dictionary_namespace_prefix_replace
mmcif_pdbx_v50.dic mmcif_pdbx_v50.dic extend . .
mmcif_investigation_fraghub_ext.dic mmcif_investigation_fraghub_ext.dic extend . .
dictionary_id
: Identifier for the dictionary to be includeddictionary_locator
: File path to the dictionary (relative to the generator file)include_mode
: How to incorporate the dictionary (typically "extend")dictionary_namespace_prefix
: Namespace prefix for the included dictionary (use "." for none)dictionary_namespace_prefix_replace
: Replacement for the namespace prefix (use "." for none)
-
Prepare Dictionary Components:
- Create or obtain the dictionary files you want to combine
- Ensure all dictionary files are present in the same directory or specify the correct relative paths
-
Create a Generator File:
- Define a new mmCIF file with
_pdbx_include_dictionary
loop - List all dictionaries to be included with their proper attributes
- Define a new mmCIF file with
-
Run the Build Command:
build_dict_cli --op build --input_dict_path generator-file.dic --output_dict_path output-dictionary.dic
-
Verify the Output:
- The tool will combine all specified dictionaries into a single output file
- Check that all expected categories and items are present in the output
To combine a base PDBx dictionary with a InvestigationCIF extension dictionary:
-
Ensure both dictionaries are available in your working directory:
mmcif_pdbx_v50.dic mmcif_investigation_fraghub_ext.dic
-
Create a generator file (e.g.,
mmcif_pdbx_v50-generator-local.dic
):data_mmcif_pdbx.dic # loop_ _pdbx_include_dictionary.dictionary_id _pdbx_include_dictionary.dictionary_locator _pdbx_include_dictionary.include_mode _pdbx_include_dictionary.dictionary_namespace_prefix _pdbx_include_dictionary.dictionary_namespace_prefix_replace mmcif_pdbx_v50.dic mmcif_pdbx_v50.dic extend . . mmcif_investigation_fraghub_ext.dic mmcif_investigation_fraghub_ext.dic extend . .
-
Run the build command:
build_dict_cli --op build --input_dict_path mmcif_pdbx_v50-generator-local.dic --output_dict_path ./mmcif_investigation_fraghub.dic
-
The tool will produce
mmcif_investigation_fraghub.dic
containing the combined content of both dictionaries.
To get the version of a dictionary:
build_dict_cli --op get_version --input_dict_path mmcif_pdbx_v50.dic
This will output only the version number to stdout.