Data structure classes
containers
A collection of container classes supporting the PDBx/mmCIF storage model.
A base container class is defined which supports common features of data and definition containers. PDBx data files are organized in sections called data blocks which are mapped to data containers. PDBx dictionaries contain definition sections and data sections which are mapped to definition and data containers respectively.
Data in both PDBx data files and dictionaries are organized in data categories. In the PDBx syntax individual items or data identified by labels of the form ‘_categoryName.attribute_name’. The terms category and attribute in PDBx jargon are analogous table and column in relational data model, or class and attribute in an object oriented data model.
The DataCategory class provides base storage container for instance data and definition meta data.
- class pdbx.containers.CifName[source]
Class of utilities for CIF-style data names.
- class pdbx.containers.ContainerBase(name)[source]
Container base class for data and definition objects.
- append(obj)[source]
Add the input object to the current object catalog. An existing object of the same name will be overwritten.
- Parameters:
obj (
DataCategory
) – input object to catalog
- exists(name) bool [source]
Determine if object name exists in object catalog.
- Parameters:
name (str) – object name
- Returns:
whether object exists in object catalog
- get_object(name)[source]
Get object from object catalog.
- Parameters:
name (str) – object name
- Returns:
object or None
- Return type:
- get_object_name_list() list [source]
Get list of object names.
- Returns:
list of
DataCategory
objects
- property name: str
Get container name.
- Returns:
container name
- print_it(fobj=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, type_='brief')[source]
Dump information about container to specified file object.
- Parameters:
fobj (file) – file object for writing
type (str) – type of summary (“brief” makes it short)
- remove(current_name) bool [source]
Remove object by name.
- Parameters:
current_name (str) – name of object to remove
- Returns:
True on success or False otherwise.
- rename(current_name, new_name) bool [source]
Change the name of an object in place.
- Parameters:
current_name (str) – old name for object
new_name (str) – new name for object
- Returns:
indicator of whether renaming was successful
- replace(obj)[source]
Replace an existing object with the input object.
- Parameters:
obj (
DataCategory
) – input object to catalog
- class pdbx.containers.DataCategory(name, attribute_name_list=None, row_list=None)[source]
Methods for creating, accessing, formatting PDBx cif data categories.
- append_attribute(attribute_name)[source]
Add attribute to container.
- Parameters:
attribute_name (str) – name of attribute to add
- append_attribute_extend_rows(attribute_name)[source]
Append attribute and extend rows.
- Parameters:
attribute_name (str) – name of attribute to add
- property attribute_count: int
Get number of attributes.
- property attribute_list: list
Get list of attributes.
- property attribute_list_with_order: list
Get list of attributes in order.
- property current_attribute: str
Get current attribute.
- property current_row_index: int
Get current row index.
- dump_it(file_=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]
Dump contents of container.
- Parameters:
file (file) – file object ready for writing
- get_attribute_index(attribute_name) int [source]
Get index of given attribute.
- Parameters:
attribute_name (str) – name of attribute
- Returns:
index of attribute
- Raises:
IndexError – if attribute not found
- get_format_type_list(steps=1) str [source]
Get a formatted type list.
- Parameters:
steps (int) – step size for iterating through rows
- Returns:
formatted type list
- property get_format_type_list_x: str
Alternate version of format type list.
- get_full_row(index) list [source]
Return a full row based on the length of the the attribute list.
- Parameters:
index (int) – index of row to retrieve
- Returns:
row
- get_max_attribute_list_length(steps=1) int [source]
Get maximum length of attribute value list.
- Parameters:
steps (int) – step size for iterating through rows
- Returns:
attribute value list max length
- get_row(index) list [source]
Get specified row.
- Parameters:
index (int) – row index
- Returns:
specified row or empty array if row not found.
- get_value(attribute_name=None, row_index=None)[source]
Get value for specified attribute and row.
- Parameters:
attribute_name (str) – attribute name
row_index (int) – row index
- Returns:
attribute value
- Raises:
IndexError – if attribute not found
- get_value_formatted(attribute_name=None, row_index=None) str [source]
Get formatted version of value.
- Parameters:
attribute_name (str) – attribute name
row_index (int) – row index
- Returns:
formatted value
- get_value_formatted_by_index(attribute_index, row_index) str [source]
Get value formatted by index.
- Parameters:
attribute_name (str) – attribute name
row_index (int) – row index
- Returns:
formatted value
- invoke_attribute_method(attribute_name, method)[source]
Invoke method of current attribute.
- Parameters:
attribute_name (str) – attribute name
method (str) – name of attribute method
- invoke_category_method(method)[source]
Invoke method of current category.
- Parameters:
method (str) – name of method
- property item_name_list: list
List of attribute names as fully qualified item names.
- property max_attribute_list_length: int
Get maximum attribute list length.
- property name: str
Get container name.
- print_it(file_=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]
Print container information.
- Parameters:
file (file) – file object ready for writing
- remove_row(index) bool [source]
Remove specified row.
- Parameters:
index (int) – index of row to remove
- Returns:
True if successful, False otherwise
- rename_attribute(current_attribute_name, new_attribute_name) bool [source]
Change the name of an attribute in place.
- Parameters:
current_attribute_name (str) – current attribute name
new_attribute_name (str) – new attribute name
- Returns:
flag indicating renaming success
- replace_substring(old_value, new_value, attribute_name) bool [source]
Replace substring of value of given attribute.
- Parameters:
old_value – old attribute value
new_value – new attribute value
attribute_name (str) – name of attribute to replace
- Returns:
Boolean flag indicating success.
- replace_value(old_value, new_value, attribute_name) int [source]
Replace the value of the specified attribute.
- Parameters:
old_value – old attribute value
new_value – new attribute value
attribute_name (str) – name of attribute to replace
- Returns:
number of replacements
- property row_count: int
Get number of rows.
- property row_list: list
Get list of rows.
- class pdbx.containers.DataCategoryBase(name, attribute_name_list=None, row_list=None)[source]
Base object definition for a data category.
- get() tuple [source]
Get name, attribute name list, and row list.
- Returns:
tuple of (name, attribute name list, and row list)
- class pdbx.containers.DataContainer(name)[source]
Container class for DataCategory objects.
- class pdbx.containers.DefinitionContainer(name)[source]
Container for definitions.
- is_attribute() bool [source]
Determine if container contains item objects.
- Returns:
indicator of whether item objects are in container