From f3c20500687f836886734f7d0925daf674ea1f32 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Sun, 5 Mar 2023 17:47:23 +0100
Subject: [PATCH] compare-structures: improve error message when structure
 dumping fails

---
 actions/ost-compare-structures-new | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/actions/ost-compare-structures-new b/actions/ost-compare-structures-new
index dfee848f0..51160472a 100644
--- a/actions/ost-compare-structures-new
+++ b/actions/ost-compare-structures-new
@@ -519,8 +519,33 @@ def _Process(model, reference, args):
         out["patch_dockq"] = scorer.patch_dockq
 
     if args.dump_structures:
-        io.SavePDB(scorer.model, model.GetName() + args.dump_suffix)
-        io.SavePDB(scorer.target, reference.GetName() + args.dump_suffix)
+        try:
+            io.SavePDB(scorer.model, model.GetName() + args.dump_suffix)
+        except Exception as e:
+            if "single-letter" in str(e) and args.model_biounit is not None:
+                raise RuntimeError("Failed to dump processed model. PDB "
+                                   "format only supports single character "
+                                   "chain names. This is likely the result of "
+                                   "chain renaming when constructing a user "
+                                   "specified biounit. Dumping structures "
+                                   "fails in this case.")
+            else:
+                raise
+        try:
+            io.SavePDB(scorer.target, reference.GetName() + args.dump_suffix)
+        except Exception as e:
+            if "single-letter" in str(e) and args.reference_biounit is not None:
+                raise RuntimeError("Failed to dump processed reference. PDB "
+                                   "format only supports single character "
+                                   "chain names. This is likely the result of "
+                                   "chain renaming when constructing a user "
+                                   "specified biounit. Dumping structures "
+                                   "fails in this case.")
+            else:
+                raise
+
+
+
 
     return out
 
-- 
GitLab