Skip to content

Commit

Permalink
Support PDB codes in PDB-IHM
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Aug 22, 2024
1 parent 55975d9 commit 73f3af7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/foxs/submit_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def handle_pdb(pdb_code, pdb_file, job):
show_filename=os.path.basename(pdb_file.filename))
return [saved_fname], saved_fname
elif pdb_code:
fname = saliweb.frontend.get_pdb_chains(pdb_code, job.directory,
formats=["PDB", "MMCIF"])
fname = saliweb.frontend.get_pdb_chains(
pdb_code, job.directory, formats=["PDB", "MMCIF", "IHM"])
return [os.path.basename(fname)], os.path.basename(fname)
else:
raise InputValidationError("Error in protein input: please specify "
Expand Down
34 changes: 31 additions & 3 deletions test/frontend/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ def make_test_pdb(tmpdir):
fh.close()


def make_test_mmcif(tmpdir):
os.mkdir(os.path.join(tmpdir, 'xy'))
with gzip.open(os.path.join(tmpdir, 'xy', '1xyz.cif.gz'), 'wt') as fh:
def make_test_mmcif(tmpdir, ihm=False):
if ihm:
os.mkdir(os.path.join(tmpdir, 'zz'))
os.mkdir(os.path.join(tmpdir, 'zz', '1zza'))
os.mkdir(os.path.join(tmpdir, 'zz', '1zza', 'structures'))
fname = os.path.join(tmpdir, 'zz', '1zza', 'structures', '1zza.cif.gz')
else:
os.mkdir(os.path.join(tmpdir, 'xy'))
fname = os.path.join(tmpdir, 'xy', '1xyz.cif.gz')

with gzip.open(fname, 'wt') as fh:
fh.write("""
loop_
_atom_site.group_PDB
Expand Down Expand Up @@ -186,6 +194,7 @@ def test_submit_pdb_code_pdb(self):
foxs.app.config['DIRECTORIES_INCOMING'] = incoming
foxs.app.config['PDB_ROOT'] = pdb_root
foxs.app.config['MMCIF_ROOT'] = pdb_root
foxs.app.config['IHM_ROOT'] = pdb_root

make_test_pdb(pdb_root)

Expand All @@ -203,6 +212,7 @@ def test_submit_pdb_code_mmcif(self):
foxs.app.config['DIRECTORIES_INCOMING'] = incoming
foxs.app.config['PDB_ROOT'] = pdb_root
foxs.app.config['MMCIF_ROOT'] = pdb_root
foxs.app.config['IHM_ROOT'] = pdb_root

make_test_mmcif(pdb_root)

Expand All @@ -213,6 +223,24 @@ def test_submit_pdb_code_mmcif(self):
self.assertEqual(rv.status_code, 503)
self.assertIn(b'Your job has been submitted', rv.data)

def test_submit_pdb_code_ihm(self):
"""Test submit with a PDB code (PDB-IHM format)"""
with tempfile.TemporaryDirectory() as incoming:
with tempfile.TemporaryDirectory() as pdb_root:
foxs.app.config['DIRECTORIES_INCOMING'] = incoming
foxs.app.config['PDB_ROOT'] = pdb_root
foxs.app.config['MMCIF_ROOT'] = pdb_root
foxs.app.config['IHM_ROOT'] = pdb_root

make_test_mmcif(pdb_root, ihm=True)

c = foxs.app.test_client()
rv = c.post('/job', data={'pdb': '1zza:C',
'jobname': 'myjob'},
follow_redirects=True)
self.assertEqual(rv.status_code, 503)
self.assertIn(b'Your job has been submitted', rv.data)

def test_submit_zip_file(self):
"""Test submit with zip file"""
with tempfile.TemporaryDirectory() as incoming:
Expand Down

0 comments on commit 73f3af7

Please sign in to comment.