diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc
index aa6595bc2dd209756ab721c582db7f8ec4b4856d..bddfecc1b72ac81cf466cd0cad885b2125899710 100644
--- a/modules/io/pymod/export_mmcif_io.cc
+++ b/modules/io/pymod/export_mmcif_io.cc
@@ -152,6 +152,11 @@ void export_mmcif_io()
     .def("Write", &WrapStarWriterWrite, (arg("data_name"), arg("filename")))
   ;
 
+  class_<ChainNameGenerator>("ChainNameGenerator", init<>())
+    .def("Get", &ChainNameGenerator::Get)
+    .def("Reset", &ChainNameGenerator::Reset)
+    ;
+
   class_<MMCifWriterEntity>("MMCifWriterEntity", no_init)
     .def("FromPolymer", &MMCifWriterEntity::FromPolymer).staticmethod("FromPolymer")
     .def("AddHet", &MMCifWriterEntity::AddHet, (arg("rnum"), arg("mon_id")))
diff --git a/modules/io/src/mol/mmcif_writer.cc b/modules/io/src/mol/mmcif_writer.cc
index 18df1a76670555dd6532141c400f7a00a9ecc983..77de1177ac69bc1414c7e2fdc8318bafdd03c27a 100644
--- a/modules/io/src/mol/mmcif_writer.cc
+++ b/modules/io/src/mol/mmcif_writer.cc
@@ -24,52 +24,6 @@
 
 namespace {
 
-  // generates as many chain names as you want (potentially multiple characters)
-  struct ChainNameGenerator{
-    ChainNameGenerator() { 
-      chain_names = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
-      n_chain_names = chain_names.size();
-      indices.push_back(-1);
-    }
-
-    String Get() {
-      int idx = indices.size() - 1;
-      indices[idx] += 1;
-      bool more_digits = false;
-      while(idx >= 0) {
-        if(indices[idx] >= n_chain_names) {
-          indices[idx] = 0;
-          if(idx>0) {
-            indices[idx-1] += 1;
-            --idx;
-          } else {
-            more_digits = true;
-            break;
-          }
-        } else {
-          break;
-        }
-      }
-      if(more_digits) {
-        indices.insert(indices.begin(), 0);
-      }
-      String ch_name(indices.size(), 'X');
-      for(uint i = 0; i < indices.size(); ++i) {
-        ch_name[i] = chain_names[indices[i]];
-      }
-      return ch_name;
-    }
-
-    void Reset() {
-      indices.clear();
-      indices.push_back(-1);
-    }
-
-    String chain_names;
-    int n_chain_names;
-    std::vector<int> indices;
-  };
-
   void CheckValidEntityPolyType(const String& entity_poly_type) {
     std::unordered_set<std::string> s = {"cyclic-pseudo-peptide",
                                          "other",
@@ -1066,7 +1020,7 @@ namespace {
                                  "is not mmcif_conform");
     }
 
-    ChainNameGenerator chain_name_gen;
+    ost::io::ChainNameGenerator chain_name_gen;
 
     std::set<String> unique_compounds;
     for(auto res_list: res_lists) {
@@ -1465,6 +1419,45 @@ namespace {
 
 namespace ost { namespace io {
 
+ChainNameGenerator::ChainNameGenerator() {
+  chain_names = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
+  n_chain_names = chain_names.size();
+  indices.push_back(-1);
+}
+
+String ChainNameGenerator::Get() {
+  int idx = indices.size() - 1;
+  indices[idx] += 1;
+  bool more_digits = false;
+  while(idx >= 0) {
+    if(indices[idx] >= n_chain_names) {
+      indices[idx] = 0;
+      if(idx>0) {
+        indices[idx-1] += 1;
+        --idx;
+      } else {
+        more_digits = true;
+        break;
+      }
+    } else {
+      break;
+    }
+  }
+  if(more_digits) {
+    indices.insert(indices.begin(), 0);
+  }
+  String ch_name(indices.size(), 'X');
+  for(uint i = 0; i < indices.size(); ++i) {
+    ch_name[i] = chain_names[indices[i]];
+  }
+  return ch_name;
+}
+
+void ChainNameGenerator::Reset() {
+  indices.clear();
+  indices.push_back(-1);
+}
+
 MMCifWriterEntity MMCifWriterEntity::FromPolymer(const String& entity_poly_type,
                                                  const std::vector<String>& mon_ids,
                                                  conop::CompoundLibPtr compound_lib) {
diff --git a/modules/io/src/mol/mmcif_writer.hh b/modules/io/src/mol/mmcif_writer.hh
index edfd50b7f65c51e14988278ea93ed82dcc312031..3c150672dcca8fd68161bc6ec0733fa43474170c 100644
--- a/modules/io/src/mol/mmcif_writer.hh
+++ b/modules/io/src/mol/mmcif_writer.hh
@@ -30,6 +30,18 @@
 
 namespace ost { namespace io {
 
+// generates as many chain names as you want (potentially multiple characters)
+struct ChainNameGenerator{
+  ChainNameGenerator();
+
+  String Get();
+
+  void Reset();
+
+  String chain_names;
+  int n_chain_names;
+  std::vector<int> indices;
+};
 
 struct MMCifWriterEntity {