From 4b655995a1d4c81205460a913e7fccd5725c73af Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Fri, 12 May 2023 09:41:04 +0200
Subject: [PATCH] doc: warn about MMCifInfo dependency on seqres

---
 modules/io/doc/mmcif.rst     | 8 ++++++++
 modules/io/pymod/__init__.py | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst
index 79281e318..f629524f9 100644
--- a/modules/io/doc/mmcif.rst
+++ b/modules/io/doc/mmcif.rst
@@ -98,6 +98,12 @@ Information from mmCIF files that goes beyond structural data, is kept in a
 special container, the :class:`MMCifInfo` class. Here is a detailed description
 of the annotation available.
 
+.. note::
+
+  Some fields of the ``MMCifInfo`` container are only populated if SEQRES
+  records are read in :func:`~ost.io.LoadMMCIF` and a compound library is
+  available (see :func:`~ost.conop.GetDefaultLib`)
+
 .. class:: MMCifInfo
 
   This is the container for all bits of non-molecular data pulled from a mmCIF
@@ -291,6 +297,8 @@ of the annotation available.
   .. method:: GetPDBMMCifChainTr(pdb_chain_id)
 
     Get the translation of a certain PDB chain name to the mmCIF chain name.
+    Only works if SEQRES records are read in :func:`~ost.io.LoadMMCIF` and a
+    compound library is available (see :func:`~ost.conop.GetDefaultLib`).
 
     :param pdb_chain_id: atom_site.auth_asym_id
     :type pdb_chain_id: :class:`str`
diff --git a/modules/io/pymod/__init__.py b/modules/io/pymod/__init__.py
index 4be3ea2ca..0f8131382 100644
--- a/modules/io/pymod/__init__.py
+++ b/modules/io/pymod/__init__.py
@@ -20,6 +20,7 @@ import os, tempfile, ftplib, http.client
 
 from ._ost_io import *
 from ost import mol, geom, conop, seq
+from ost import LogWarning
 
 class IOProfiles:
   def __init__(self):
@@ -446,6 +447,11 @@ def LoadMMCIF(filename, fault_tolerant=None, calpha_only=None,
       reader.info.ConnectBranchLinks()
     #else:
     #  raise IOError("File doesn't contain any entities")
+
+    # Warn about info dependency on seqres
+    if info and not reader.seqres:
+      LogWarning("MMCifInfo is incomplete when seqres=False")
+
     if seqres and info:
       return ent, reader.seqres, reader.info
     if seqres:
-- 
GitLab