CIFBlock
#
- class biotite.structure.io.pdbx.CIFBlock(categories=None, name=None)[source]#
Bases:
_Component
,MutableMapping
This class represents a block in a
CIFFile
.Categories can be accessed and modified like a dictionary. The values are
CIFCategory
objects.- Parameters:
- categoriesdict, optional
The categories of the block. The keys are the category names and the values are the
CIFCategory
objects. By default, an empty block is created.- namestr, optional
The name of the block. This is only used for serialization and is automatically set, when the
CIFBlock
is added to aCIFFile
. It only needs to be set manually, when the block is directly serialized.
- Attributes:
- namestr
The name of the block.
Notes
The category names do not include the leading underscore character. This character is automatically added when the category is serialized.
Examples
>>> # Add category on creation >>> block = CIFBlock({"foo": CIFCategory({"some_column": 1})}, name="baz") >>> # Add category later on >>> block["bar"] = CIFCategory({"another_column": [2, 3]}) >>> # Access a column >>> print(block["bar"]["another_column"].as_array()) ['2' '3'] >>> print(block.serialize()) data_baz # _foo.some_column 1 # loop_ _bar.another_column 2 3 #
- static deserialize(text)#
Create this component by deserializing the given content.
- Parameters:
- contentstr or dict
The content to be deserialized. The type of this parameter depends on the file format. In case of CIF files, this is the text of the lines that represent this component. In case of BinaryCIF files, this is a dictionary parsed from the MessagePack data.
- serialize()#
Convert this component into a Python object that can be written to a file.
- Returns:
- contentstr or dict
The content to be serialized. The type of this return value depends on the file format. In case of CIF files, this is the text of the lines that represent this component. In case of BinaryCIF files, this is a dictionary that can be encoded into MessagePack.
- static subcomponent_class()#
Get the class of the components that are stored in this component.
- Returns:
- subcomponent_classtype
The class of the subcomponent. If this component already represents the lowest level, i.e. it does not contain subcomponents,
None
is returned.
- static supercomponent_class()#
Get the class of the component that contains this component.
- Returns:
- supercomponent_classtype
The class of the supercomponent. If this component present already the highest level, i.e. it is not contained in another component,
None
is returned.