From 0665a173eac4663b6841671b8486c3dd45466d8e Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Wed, 19 Jun 2024 11:36:06 +0200
Subject: [PATCH] Return None in case of no contacts in QS-score

The score is simply not valid and returning 0.0 as done before is incorrect.
Delegates further treatment of the problem to the caller which might want to
say: if both structures are monomer, I still give it a value of 1. Or, to
extend that definition, if I reproduced the correct stoichiometry, I still
give it a value of 1.
---
 modules/mol/alg/pymod/qsscore.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/mol/alg/pymod/qsscore.py b/modules/mol/alg/pymod/qsscore.py
index 9b95f56fb..3b32746d6 100644
--- a/modules/mol/alg/pymod/qsscore.py
+++ b/modules/mol/alg/pymod/qsscore.py
@@ -255,6 +255,8 @@ class QSScorerResult:
     def QS_best(self):
         """ QS_best - the actual score as described in formula section above
 
+        Returns None if there are no contacts in the compared structures
+
         :type: :class:`float`
         """
         nominator = self.weighted_scores
@@ -262,12 +264,14 @@ class QSScorerResult:
         if denominator != 0.0:
             return nominator/denominator
         else:
-            return 0.0
+            return None
 
     @property
     def QS_global(self):
         """ QS_global - the actual score as described in formula section above
 
+        Returns None if there are no contacts in the compared structures
+
         :type: :class:`float`
         """
         nominator = self.weighted_scores
@@ -275,7 +279,7 @@ class QSScorerResult:
         if denominator != 0.0:
             return nominator/denominator
         else:
-            return 0.0
+            return None
 
 
 class QSScorer:
-- 
GitLab