Hi Marcin,
I encountered an issue when using gemmi.Structure.update_mmcif_block() to update a CIF block after modifying a structure.
I found certain mmCIF categories present in the original file were removed from the output.
The following categories were removed from the output:
_struct_ref
_reflns_shell
_refine_ls_shell
Would it be possible to add an option to update_mmcif_block() to preserve categories that gemmi.Structure doesn't track?
For example:
st.update_mmcif_block(block, preserve_unknown_categories=True)
This issue was encountered while building a residue renaming tool for crystallographic structure files. The goal was to use gemmi.Structure's intelligent residue handling (which keeps residue IDs consistent across _atom_site, _entity, _pdbx_poly_seq_scheme, etc.) while preserving all metadata categories from the original file.
Example snippet from code
import gemmi
# Read original CIF (preserves all categories)
doc = gemmi.cif.read("input.cif")
block = doc[0]
# Read structure for modification
st = gemmi.read_structure("input.cif")
# Modify structure (e.g., rename residues)
for model in st:
for chain in model:
for residue in chain:
if residue.name == "LIG":
residue.name = "XYZ"
# Update block from modified structure
st.update_mmcif_block(block)
# Write output
doc.write_file("output.cif")
Hi Marcin,
I encountered an issue when using
gemmi.Structure.update_mmcif_block()to update a CIF block after modifying a structure.I found certain mmCIF categories present in the original file were removed from the output.
The following categories were removed from the output:
_struct_ref_reflns_shell_refine_ls_shellWould it be possible to add an option to
update_mmcif_block()to preserve categories thatgemmi.Structuredoesn't track?For example:
This issue was encountered while building a residue renaming tool for crystallographic structure files. The goal was to use
gemmi.Structure's intelligent residue handling (which keeps residue IDs consistent across_atom_site,_entity,_pdbx_poly_seq_scheme, etc.) while preserving all metadata categories from the original file.Example snippet from code