diff --git a/lib/cryptosite/bmi_feature_parser.py b/lib/cryptosite/bmi_feature_parser.py index 29e4134..176988d 100644 --- a/lib/cryptosite/bmi_feature_parser.py +++ b/lib/cryptosite/bmi_feature_parser.py @@ -12,8 +12,12 @@ def get_cnc(apo): subprocess.check_call(["fpocket", "-f", apo + '.pdb']) - with open('%s_out/%s_out.pdb' % (apo, apo)) as data: - D = data.readlines() + try: + with open('%s_out/%s_out.pdb' % (apo, apo)) as data: + D = data.readlines() + except FileNotFoundError: + # If fpocket finds no pockets, it does not create the output directory + return {}, ('1', '1') Pockets = {} for d in D: diff --git a/test/input/test-no-pockets.pdb b/test/input/test-no-pockets.pdb new file mode 100644 index 0000000..3509bc0 --- /dev/null +++ b/test/input/test-no-pockets.pdb @@ -0,0 +1 @@ +ATOM 265 O ILE A 65 -6.422 41.658 49.431 1.00 19.63 O diff --git a/test/test_bmi_feature_parser.py b/test/test_bmi_feature_parser.py index b93c7fd..2fed2ad 100644 --- a/test/test_bmi_feature_parser.py +++ b/test/test_bmi_feature_parser.py @@ -24,6 +24,15 @@ def test_get_cnc(self): self.assertEqual(len(res), 8) self.assertEqual(num, ('1', '1')) + def test_get_cnc_no_pockets(self): + """Test get_cnc() function with PDB containing no pockets""" + with utils.temporary_working_directory(): + shutil.copy(os.path.join(TOPDIR, 'test', 'input', + 'test-no-pockets.pdb'), '1abc.pdb') + res, num = bmi_feature_parser.get_cnc('1abc') + self.assertEqual(len(res), 0) + self.assertEqual(num, ('1', '1')) + def test_get_cnc_pockets(self): """Test get_cnc() parsing of pocket information""" with utils.temporary_working_directory():