From 654a0bdc6624692a22df37256d6e95bc8ae26934 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Thu, 9 Mar 2023 11:25:55 +0100
Subject: [PATCH] bugfix: guard np.mean from empty list as input

---
 modules/mol/alg/pymod/scoring.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/mol/alg/pymod/scoring.py b/modules/mol/alg/pymod/scoring.py
index 3bb9a762a..e3ad3ad8c 100644
--- a/modules/mol/alg/pymod/scoring.py
+++ b/modules/mol/alg/pymod/scoring.py
@@ -1095,11 +1095,17 @@ class Scorer:
         # - the two above including nonmapped_interfaces => set DockQ to 0.0
         scores = np.array(self._dockq_scores)
         weights = np.array(self._native_contacts)
-        self._dockq_ave = np.mean(scores)
+        if len(scores) > 0:
+            self._dockq_ave = np.mean(scores)
+        else:
+            self._dockq_ave = 0.0
         self._dockq_wave = np.sum(np.multiply(weights/np.sum(weights), scores))
         scores = np.append(scores, [0.0]*len(self._nonmapped_interfaces))
         weights = np.append(weights, self._nonmapped_interfaces_contacts)
-        self._dockq_ave_full = np.mean(scores)
+        if len(scores) > 0:
+            self._dockq_ave_full = np.mean(scores)
+        else:
+            self._dockq_ave_full = 0.0
         self._dockq_wave_full = np.sum(np.multiply(weights/np.sum(weights),
                                                    scores))
 
-- 
GitLab