cif |
index |
module for reading and writing mmCif files.
This module allows for reading/writing of arbitrary Cif data. Data is
stored in a three-level hierarchy. The base level is Datablock. For
PDBx files, these blocks are named by PDB ID, e.g. "1GB1", each
introduced by lines starting with data_BLOCKNAME, where BLOCKNAME is
replaced by the name of the block. Each datablock consists of multiple
categories, e.g. citation and atom_site, the later of which contains
atomic coordinate information. Categories are introduced in a cif file
with lines starting with _CATEGORYNAME, where CATEGORYNAME is replaced
with the name of the category. In the cif file, each category contains
one or more item names separated from the category name by a "."
character. Within a category each item can contain a single value, or
a list of values when the category is begun with a line starting with
the string "loop_". Within a single category, all items have the same
number of values. An item example is the Cartesian x atomic coordinate
given by the category.item: _atom_site.Cartn_x. Item/value specifications
are separated by white space. White space within a value must be
quoted. Items which consist of multiple lines begin with the sequence
"\n;" and end with the sequence "\n;\n"
This module can also load nmrStar-formatted files: saveframes
introduced by \nsave_ are read in as datablocks. Additionally,
zero-length value list are supported.
The toplevel object type is Cif:
Constructor:
Cif()
Methods:
size() - the number of datablocks loaded
keys() - return an (ordered) list of datablock names.
getDatablock(string) - return the named datablock
addDatablock(string,
datablock) - add a new, named CifDatablock.
clear() - clear all datablocks.
parse(string) - load cif entries by parsing a Cif-formatted string
asString() - return a string representation of the Cif
object. For elements in which the category
name is nullCategoryName, the name and the
following '.' are omitted.
Accessors:
[Values are read using form quantity(), while they are set using the
form setQuantity(value).]
modelToRead - which mmCIF model (_atom_site.pdbx_PDB_model_num)
to read. Default value of -1 specifies all models.
numDatablocksToRead - How many datablocks to read. One can specify
which blocks to read using datablocksToRead.
However, it's frequently more convenient to
specify 1 for this. The default value of -1
specifies all datablocks.
useTrailingPound - after each _loop category, print a line consisting
solely of the '#' character.
useTrailingStop - after each _loop category, print a line consisting
of the literal "stop_"
useTrailingSave - at the end of each save frame, print a line
consisting of the literal "save_"
catsUseLoops - controls write-out behavior such that
categories after the first include all items in
loops. This seems to be required for NEF files.
Members:
datablocksToRead - if specified, only read the named datablocks.
setDatablocksToRead(list) Use the set accessor in the Python interface.
categoriesToRead - if specified, only read the named categories.
setCategoriesToRead(list) Use the set accessor in the Python interface.
nullCategoryName - the category name given for entries with no '.'
In addition to the getDatablock method, the __getitem__ method has
been defined such that, e.g.
data = Cif(); data.parse(input)
block = data['1GB1']
will return the appropriate datablock. New datablocks can be added using the
__set_item__ method:
data['1GB1'] = datablock
The CifDatablock Object:
Constructor:
CifDatablock()
Methods:
size() - the number of categories present
keys() - an ordered list of category names
getCategory(string) - return the specified category
addCategory(string,
category) - add a new, named CifCategory
isSaveframe() - whether this block is actually a saveframe.
Saveframes which are read in have a
begin with a category including the literal
"category" with an identifying name. The NEF
convention is that the identifying name is
same as that of this category.
setIsSaveFrame(val) - (for writing), specify whether the datablock is
actually a saveframe.
asTable(list) - Special case for when there is a single category
named nullCategoryName. Then this method returns
asTable for that single category.
clear() - clear all categories
In addition to the getCategory method, categories can be accessed via
__getitem__, or __getattr__: e.g.
block['atom_site'] or block.atom_site
New Categories can be added using the __set_item__ method:
block['atom_site'] = category
The CifCategory Object:
Constructor:
CifCategory()
Methods:
size() - the number of items present
keys() - an ordered list of item names
getValues(string) - return the values associated with the specified
item name.
addKey(string) - add the specified item name
addValue(key, - add a value to the item list associated with the
value) specified item name.
clear() - clear all items.
clearValues() - resize all value lists to zero size.
asTable(list) - The argument is a sequence of item names. The return
value is a list of sequences of the form
[ value1_i, value2_i, ... ]
where valueN_i corresponds to getValues(itemN)[i].
In addition to the getValues method, items can be access via
__getitem__ and __getattr__ methods: e.g.
block['atom_site']['Cartn_x']
or
block.atom_site.Cartn_x
As a special case, when the category name is Cif::nullCategoryName,
access to items is simplified to block.Cartn_x.
New Objects containing single values can be added using the __set_item__method:
category['name'] = "a value"
Module Functions
unknownValue() - return string which represents unknown values (?)
inapplicableValue - return string which represents inapplicable values (.)
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
Classes | ||||||||||||||||||||||||||||||||||
|
Functions | ||
|
Data | ||
cvar = <Swig global variables> |