diff --git a/modules/mol/alg/pymod/chain_mapping.py b/modules/mol/alg/pymod/chain_mapping.py index 234c6f631a90a276b7c4ae77e5882c625a7f3aec..7189b3e9dfe3a3387715849332d5e7d6801a4c40 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