Skip to content

Commit

Permalink
Handle fpocket finding no pockets
Browse files Browse the repository at this point in the history
If fpocket finds no pockets, it does not
create the output directory, so handle this.
  • Loading branch information
benmwebb committed Sep 22, 2023
1 parent 8b2776b commit 8b3b2de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/cryptosite/bmi_feature_parser.py
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions 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
9 changes: 9 additions & 0 deletions test/test_bmi_feature_parser.py
Expand Up @@ -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():
Expand Down

0 comments on commit 8b3b2de

Please sign in to comment.