From 5e2626ed43ae66fbb63b4daafb50b70a9117acaa Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Tue, 2 Jan 2024 10:19:27 +0100
Subject: [PATCH] fix: SCHWED-6108 read other as CHAINTYPE_POLY

This allows the mmCIF writer to save the entity_poly.type as "other"
rater than error on an unknown type.
We can do this because there is no "other" in _entity_poly.type.
Added a comment about the risks of chain_type for reading/writing mmCIF
files.
---
 modules/mol/base/src/chain_type.cc | 4 +++-
 modules/mol/base/src/chain_type.hh | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/mol/base/src/chain_type.cc b/modules/mol/base/src/chain_type.cc
index 6694aa017..0820407c7 100644
--- a/modules/mol/base/src/chain_type.cc
+++ b/modules/mol/base/src/chain_type.cc
@@ -59,7 +59,9 @@ ChainType ChainTypeFromString(StringRef identifier)
   } else if (StringRef("oligosaccharide", 15) == identifier) {
     return CHAINTYPE_OLIGOSACCHARIDE;
   } else if (StringRef("other", 5) == identifier) {
-    return CHAINTYPE_UNKNOWN;
+    // According to the mmCIF dictionary, "other" only exists in
+    // _entity_poly.type. Therefore, "other" can only be a generic polymer.
+    return CHAINTYPE_POLY;
   }
 
   throw Error("Unrecognised chain type descriptor found: '" +
diff --git a/modules/mol/base/src/chain_type.hh b/modules/mol/base/src/chain_type.hh
index 08ce4dcc6..27e1910e6 100644
--- a/modules/mol/base/src/chain_type.hh
+++ b/modules/mol/base/src/chain_type.hh
@@ -28,6 +28,11 @@
 namespace ost { namespace mol {
 
 /// \enum different kinds of chains
+///
+/// Warning: this class mixes vocabulary from _entity.type and
+// _entity_poly.type, which is more detailed. As a result it cannot be used to
+/// to read/write mmCIF entity types accurately.
+
 typedef enum {
   CHAINTYPE_POLY,           ///< polymer
   CHAINTYPE_NON_POLY,       ///< non-polymer
-- 
GitLab