Category Transforms#
Transforms operating on Biotite’s CIFBlock and CIFCategory objects.
These transforms are used to extract information from the CIFBlock and return a dictionary containing processed information.
- atomworks.io.transforms.categories.category_to_df(cif_block_or_category: CIFBlock | BinaryCIFBlock | CIFCategory | BinaryCIFCategory, category: str | None = None) DataFrame | None[source]#
Convert CIF component to pandas DataFrame.
Accepts either
(CIFBlock, category_name)or(CIFCategory)directly. Supports both text CIF and binary CIF (BinaryCIF) formats.- Parameters:
cif_block_or_category –
CIFBlock,BinaryCIFBlock, orCIFCategory|BinaryCIFCategorycategory – Category name when passing CIFBlock/BinaryCIFBlock, omit when passing CIFCategory
- Returns:
DataFrame containing the category data, or None if category doesn’t exist (CIFBlock mode only)
- atomworks.io.transforms.categories.category_to_dict(cif_block_or_category: CIFBlock | BinaryCIFBlock | CIFCategory | BinaryCIFCategory, category: str | None = None) dict[str, ndarray][source]#
Convert CIF component to dict mapping column names to numpy arrays.
Accepts either
(CIFBlock, category_name)or(CIFCategory)directly. Supports both text CIF and binary CIF (BinaryCIF) formats.- Parameters:
cif_block_or_category –
CIFBlock,BinaryCIFBlock, orCIFCategory|BinaryCIFCategorycategory – Category name when passing CIFBlock/BinaryCIFBlock, omit when passing CIFCategory
- Returns:
Dict mapping column names to numpy arrays
- atomworks.io.transforms.categories.extract_crystallization_details(crystal_dict: dict) dict[str, list[float] | None][source]#
Extracts crystallization details from the crystallization dictionary.
- Parameters:
crystal_dict – Dictionary for the exptl_crystal_grow CIF category.
- Returns:
“pH”: A list of two floats [min_pH, max_pH], or None if unavailable.
- Return type:
A dictionary with crystallization details. Currently includes
- atomworks.io.transforms.categories.get_ligand_of_interest_info(cif_block: CIFBlock) dict[source]#
Extract ligand of interest information from a CIF block.
- Reference:
- atomworks.io.transforms.categories.get_metadata_from_category(cif_block: CIFBlock, fallback_id: str | None = None) dict[source]#
Extract metadata from the CIF block. If the entry.id field is not present in the CIF block, the fallback_id is used instead (e.g., the filename of the CIF).
- From RCSB CIF files, this function extracts:
ID (e.g., PDB ID)
Method (e.g., X-ray, NMR, etc.)
Deposition date (initial)
Release date (smallest revision date)
Resolution (e.g., 5.0, 3.0, etc.)
Chem comp type (elements of atomworks.constants.CHEM_COMP_TYPES)
- For custom CIF files (e.g., distillation), this function extracts:
Extra metadata (all other categories)
- Parameters:
cif_block (CIFBlock) – The CIF block to extract metadata from.
fallback_id (str) – A fallback ID to use if the entry.id field is not present in the CIF block.