From c7f3da8a19671dbdd4621079622633c7b30cfb15 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Wed, 24 Jan 2024 08:43:21 +0100 Subject: [PATCH] mmcif writer: allow to pre-define entities in io.SaveMMCIF --- modules/io/doc/mmcif.rst | 6 ++++-- modules/io/pymod/__init__.py | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index fefd64b7b..0a648960c 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -1956,7 +1956,9 @@ To see it all in action: (:class:`ost.StringList`) Asym chain names that are assigned to this entity +.. class:: MMCifWriterEntityList + A list for :class:`MMCifWriterEntity` .. class:: MMCifWriter @@ -1979,11 +1981,11 @@ To see it all in action: starting point, i.e. chains in *ent* are matched to entities in *entity_info*. In case of no match, this list gets extended. Starts from empty list if not given. - :type entity_info: :class:`list` of :class:`MMCifWriterEntity` + :type entity_info: :class:`MMCifWriterEntityList` .. method:: GetEntities() - Returns :class:`list` of :class:`MMCifWriterEntity`. Useful to check after + Returns :class:`MMCifWriterEntityList`. Useful to check after :func:`SetStructure` has been called. Order in this list defines entity ids in written mmCIF file with zero based indexing. diff --git a/modules/io/pymod/__init__.py b/modules/io/pymod/__init__.py index caec78dae..5f011e997 100644 --- a/modules/io/pymod/__init__.py +++ b/modules/io/pymod/__init__.py @@ -457,7 +457,8 @@ def LoadMMCIF(filename, fault_tolerant=None, calpha_only=None, raise -def SaveMMCIF(ent, filename, data_name="OST_structure", mmcif_conform = True): +def SaveMMCIF(ent, filename, data_name="OST_structure", mmcif_conform = True, + entity_info = MMCifWriterEntityList()): """ Save OpenStructure entity in mmCIF format @@ -477,12 +478,16 @@ def SaveMMCIF(ent, filename, data_name="OST_structure", mmcif_conform = True): to identify and separate mmCIF entities based on :class:`ost.mol.ChemClass` of the residues in a chain. :type ent: :class:`ost.mol.EntityHandle`/:class:`ost.mol.EntityView` + :param entity_info: Advanced usage - passed as *entity_info* parameter to + :func:`MMCifWriter.SetStructure` :type filename: :class:`str` :type data_name: :class:`str` :type mmcif_conform: :class:`bool` + :type entity_info: :class:`MMCifWriterEntityList` """ writer = MMCifWriter() - writer.SetStructure(ent, mmcif_conform = mmcif_conform) + writer.SetStructure(ent, mmcif_conform = mmcif_conform, + entity_info = entity_info) writer.Write(data_name, filename) -- GitLab