From 9be6149642d7a2fcac3f0077e25f9254d7bd20ee Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Tue, 20 Sep 2022 16:58:35 +0200 Subject: [PATCH] chain mapping: Deal with corner case in GetRepr --- modules/mol/alg/pymod/chain_mapping.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/mol/alg/pymod/chain_mapping.py b/modules/mol/alg/pymod/chain_mapping.py index 234c6f631..7189b3e9d 100644 --- a/modules/mol/alg/pymod/chain_mapping.py +++ b/modules/mol/alg/pymod/chain_mapping.py @@ -1247,14 +1247,19 @@ class ChainMapper: check_resnames = False, no_intrachain = only_interchain) + if lDDT is None: + lDDT = 0.0 # that means, that we have not a single valid contact + # in lDDT. For the code below to work, we just set it + # to a terrible score => 0.0 + if len(scored_mappings) == 0: scored_mappings.append((lDDT, mapping)) elif len(scored_mappings) < topn: scored_mappings.append((lDDT, mapping)) - scored_mappings.sort(reverse=True) + scored_mappings.sort(reverse=True, key=lambda x: x[0]) elif lDDT > scored_mappings[-1][0]: scored_mappings.append((lDDT, mapping)) - scored_mappings.sort(reverse=True) + scored_mappings.sort(reverse=True, key=lambda x: x[0]) scored_mappings = scored_mappings[:topn] # finalize and return -- GitLab