diff --git a/frontend/foxs/submit_page.py b/frontend/foxs/submit_page.py index 9e2407e..80f045f 100644 --- a/frontend/foxs/submit_page.py +++ b/frontend/foxs/submit_page.py @@ -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 " diff --git a/test/frontend/test_submit.py b/test/frontend/test_submit.py index 075ce8f..8a2aaa3 100644 --- a/test/frontend/test_submit.py +++ b/test/frontend/test_submit.py @@ -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 @@ -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) @@ -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) @@ -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: