diff --git a/modules/mol/alg/pymod/chain_mapping.py b/modules/mol/alg/pymod/chain_mapping.py index 7ee8ff5fc95fd2460868362145902c60149a8f02..f5e10d58c80624c56635169228f69cf557309919 100644 --- a/modules/mol/alg/pymod/chain_mapping.py +++ b/modules/mol/alg/pymod/chain_mapping.py @@ -1499,6 +1499,13 @@ class ChainMapper: else: raise RuntimeError("This shouldnt happen") + if len(polypep_seqs) == 0 and len(polynuc_seqs) == 0: + raise RuntimeError(f"No chain fulfilled minimum length requirement " + f"to be considered in chain mapping " + f"({self.min_pep_length} for peptide chains, " + f"{self.min_nuc_length} for nucleotide chains) " + f"- mapping failed") + # select for chains for which we actually extracted the sequence chain_names = [s.GetAttachedView().chains[0].name for s in polypep_seqs] chain_names += [s.GetAttachedView().chains[0].name for s in polynuc_seqs] diff --git a/modules/mol/alg/tests/test_chain_mapping.py b/modules/mol/alg/tests/test_chain_mapping.py index 36a633b09479e89aa81297cfb45326b4262fea69..8c8846aba8a3de61c6a52991c33041186b00219e 100644 --- a/modules/mol/alg/tests/test_chain_mapping.py +++ b/modules/mol/alg/tests/test_chain_mapping.py @@ -353,6 +353,13 @@ class TestChainMapper(unittest.TestCase): aln.GetSequence(1).GetString()) + def test_misc(self): + + # check for triggered error when no chain fulfills length threshold + ref = _LoadFile("3l1p.1.pdb").Select("cname=A and rnum<8") + self.assertRaises(Exception, ChainMapper, ref) + + if __name__ == "__main__": from ost import testutils if testutils.SetDefaultCompoundLib():