ihmwg / python-ihm

Python package for handling IHM mmCIF and BinaryCIF files
MIT License
14 stars 7 forks source link

Adding custom records to the header #82

Closed jkosinski closed 2 years ago

jkosinski commented 2 years ago

Is it possible to add custom records to the header of the IHM file? For example, I would like to add a header with the release date:

loop_
_pdbx_audit_revision_history.ordinal 
_pdbx_audit_revision_history.data_content_type 
_pdbx_audit_revision_history.major_revision 
_pdbx_audit_revision_history.minor_revision 
_pdbx_audit_revision_history.revision_date 
1 'Structure model' 1 0 1000-01-01
#
benmwebb commented 2 years ago

I think this particular category is usually managed by the folks at the archive (e.g. PDB-Dev), but yes, it is straightforward to add additional categories to the mmCIF or BinaryCIF file. Just create a new Dumper class and pass a list of these classes as the dumpers argument to ihm.dumper.write. You can do the same thing in reverse (via a Handler class and ihm.reader.read) to read a custom category.

We ourselves add some IMP/PMI-specific categories with simulation parameters to our files. See for example _ReplicaExchangeProtocolDumper in https://github.com/salilab/pmi/blob/develop/pyext/src/mmcif.py.

jkosinski commented 2 years ago

Works for me, thanks!