[cctbxbb] iotbx newbie question

Richard Gildea rgildea at gmail.com
Thu Nov 7 15:47:47 PST 2013


Hi Wolfram,

The build_crystal_structures() method is aimed at extracting a cctbx
xray.structure object from a small molecule cif file, and isn't aimed at
mmcif-format files, so in your case it looks through all the data blocks in
the provided CIF, can't find any suitable xray.structures, so returns an
empty dictionary. If you simply want to access the raw CIF items from the
file, then this code snippet shows how you can extract (e.g.) the Rwork
from the 1NXC cif block:

import iotbx.cif
reader = iotbx.cif.reader(file_path="1NXC.cif")
cif = reader.model()
cif_block = cif["1NXC"]
# get a single item from cif_block
print cif_block["_refine.ls_R_factor_R_work"]
# get a looped item from cif_block
print list(cif_block["_citation_author.name"])

If you want to extract the model for your crystal structure, then probably
the most useful thing to do is extract a pdb.hierarchy object (the cctbx's
internal representation of a PDB/mmCIF structure file). This functionality
can accept both PDB and mmCIF files as input:

import iotbx.pdb
# this works exactly the same for pdb files
pdb_input = iotbx.pdb.input(file_name="1NXC.cif")
pdb_hierarchy = pdb_input.construct_hierarchy()

Alternatively, if you are only reading mmCIF files, need access to both the
raw cif items and the pdb_hierarchy, and are concerned about overhead of
reading mmCIF twice (only really relevant for extremely large files), then
you can pass the cif object created above to the iotbx.pdb.mmcif.cif_input
function:

import iotbx.pdb.mmcif
pdb_input = iotbx.pdb.mmcif.cif_input(cif_object=cif)
pdb_hierarchy = pdb_input.construct_hierarchy()

Please let me know if you have any more questions about using iotbx.cif!

Cheers,

Richard


On 6 November 2013 11:38, wtempel <wtempel at gmail.com> wrote:

> Hello all,
> please consider the scenario of a manuscript that, among other things,
> describes 20 crystal structures.
> Suppose the journal editor requires a Table 1.
> I now looking for a tool to prepare such table with high accuracy and
> little effort.
> My PDB deposition workflow includes the preparation of mmcif coordinates
> with pdb_extract. The mmcif file is complete in the sense that after upload
> to RCSB-ADIT, virtually no additional information is required for
> deposition.
> My intuition was to combine CSV and IOTBX python modules and produce the
> table via input of a list of mmcif files.
> The current phenix table_1 tool provides some, but not all of that
> functionality, and I thought once familiar with the python modules, I would
> quickly write the script.
> After confirming that the example at
> http://cctbx.sourceforge.net/iotbx_cif/
> works with my cctbx installation,
> I attempted to transform that code to read in PDB mmcif coordinates:
> <code>
> test_structure = iotbx.cif.reader(
>   file_path="/tmp/1NXC.cif").build_crystal_structures()["1NXC"]
> </code>
> which throws an exception:
> <output>
> Traceback (most recent call last):
>   File "1NXC.py", line 3, in <module>
>     test_structure =
> iotbx.cif.reader(file_path="/tmp/1NXC.cif").build_crystal_structures()["1NXC"]
> KeyError: '1NXC'
> </output>
> How do I need to write the code so that it returns a python object with
> access to all the cif items?
> Thank you,
> Wolfram Tempel
>
>
> _______________________________________________
> cctbxbb mailing list
> cctbxbb at phenix-online.org
> http://phenix-online.org/mailman/listinfo/cctbxbb
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phenix-online.org/pipermail/cctbxbb/attachments/20131107/8f9a4337/attachment.htm>


More information about the cctbxbb mailing list