From 3e327e6eb6e0df768fffae861efd3e8fc25e6588 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Fri, 31 May 2024 16:36:07 +0200
Subject: [PATCH] mmcif writer: add _chem_comp.name

---
 modules/io/doc/mmcif.rst           | 1 +
 modules/io/src/mol/mmcif_writer.cc | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst
index 43618968f..1cd557a5f 100644
--- a/modules/io/doc/mmcif.rst
+++ b/modules/io/doc/mmcif.rst
@@ -1788,6 +1788,7 @@ a mmCIF file according to `mmcif_pdbx_v50 <https://mmcif.wwpdb.org/dictionaries/
 
   * id
   * type
+  * name
 
 * `_atom_type <https://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v50.dic/Categories/atom_type.html>`_
 
diff --git a/modules/io/src/mol/mmcif_writer.cc b/modules/io/src/mol/mmcif_writer.cc
index 77de1177a..6ea364aa8 100644
--- a/modules/io/src/mol/mmcif_writer.cc
+++ b/modules/io/src/mol/mmcif_writer.cc
@@ -696,6 +696,7 @@ namespace {
     ost::io::StarWriterLoopDesc desc("_chem_comp");
     desc.Add("id");
     desc.Add("type");
+    desc.Add("name");
     ost::io::StarWriterLoopPtr sl(new ost::io::StarWriterLoop(desc));
     return sl;    
   }
@@ -978,7 +979,7 @@ namespace {
         unique_compounds.insert(het_it.second.begin(), het_it.second.end());
       }
     }
-    std::vector<ost::io::StarWriterValue> comp_data(2);
+    std::vector<ost::io::StarWriterValue> comp_data(3);
     for(auto mon_id: unique_compounds) {
       comp_data[0] = ost::io::StarWriterValue::FromString(mon_id);
       ost::conop::CompoundPtr comp = compound_lib->FindCompound(mon_id,
@@ -986,9 +987,11 @@ namespace {
       if(comp) {
         String type = ChemClassToChemCompType(comp->GetChemClass());
         comp_data[1] = ost::io::StarWriterValue::FromString(type);
+        comp_data[2] = ost::io::StarWriterValue::FromString(comp->GetName());
       } else {
         String type = ChemClassToChemCompType(ost::mol::ChemClass::UNKNOWN);
         comp_data[1] = ost::io::StarWriterValue::FromString(type);
+        comp_data[2] = ost::io::StarWriterValue::FromString("");
       }
       chem_comp_ptr->AddData(comp_data);
     }
-- 
GitLab