From faa3024a8485fc66cba44c96e4c252f1b7a856d0 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Sun, 21 Jan 2024 21:18:01 +0100
Subject: [PATCH] mmcif writer: correctly guess _entity.type "branched"

If all residues in a chain are saccharides in some form, the
respective _entity.type should be "branched"
---
 modules/io/src/mol/mmcif_writer.cc | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/io/src/mol/mmcif_writer.cc b/modules/io/src/mol/mmcif_writer.cc
index 4ad71c449..1b3bcf548 100644
--- a/modules/io/src/mol/mmcif_writer.cc
+++ b/modules/io/src/mol/mmcif_writer.cc
@@ -199,9 +199,7 @@ namespace {
     // - polymer
     // - water
 
-    // this function is overly simplistic and won't identify macrolid or
-    // branched => explicitely checks for water, everything else is either
-    // non-polymer or polymer depending on number of residues
+    // this function is overly simplistic and won't identify macrolid
 
     std::set<char> chem_classes;
     for(auto res: res_list) {
@@ -221,6 +219,15 @@ namespace {
       return "non-polymer";
     }
 
+    std::set<char> branched_set;
+    branched_set.insert(ost::mol::ChemClass::L_SACCHARIDE);
+    branched_set.insert(ost::mol::ChemClass::D_SACCHARIDE);
+    branched_set.insert(ost::mol::ChemClass::SACCHARIDE);
+    branched_set.insert(chem_classes.begin(), chem_classes.end());
+    if(branched_set.size() == 3) {
+      return "branched";
+    }
+
     return "polymer";
   }
 
-- 
GitLab