Skip to content

Commit dc996a5

Browse files
authored
Merge pull request #816 from padix-key/extended-id
Test fetching PDB entries with extended IDs
2 parents 81823c7 + f009c5c commit dc996a5

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/biotite/database/rcsb/download.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def _assert_valid_file(response_text, pdb_id):
155155
"<title>PDB Archive over AWS</title>",
156156
"No fasta files were found.",
157157
"No valid PDB IDs were submitted.",
158+
"The requested URL was incorrect, too long or otherwise malformed.",
158159
]
159160
):
160161
raise RequestError("PDB ID {:} is invalid".format(pdb_id))

tests/database/test_rcsb.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
33
# information.
44

5-
import itertools
65
import tempfile
76
from datetime import date
87
from os.path import join
@@ -23,16 +22,27 @@
2322
TC5B_TERM = "Miniprotein Construct TC5b"
2423

2524

26-
@pytest.mark.skipif(cannot_connect_to(RCSB_URL), reason="RCSB PDB is not available")
25+
@pytest.mark.parametrize("as_file_like", [False, True])
2726
@pytest.mark.parametrize(
28-
"format, as_file_like",
29-
itertools.product(["pdb", "cif", "bcif", "fasta"], [False, True]),
27+
"format, extended_id",
28+
[
29+
pytest.param("pdb", False),
30+
pytest.param("cif", False),
31+
pytest.param("cif", True),
32+
pytest.param("bcif", False),
33+
# https://models.rcsb.org/ does not support extended PDB IDs yet
34+
pytest.param("bcif", True, marks=pytest.mark.xfail),
35+
pytest.param("fasta", False),
36+
],
3037
)
31-
def test_fetch(format, as_file_like):
38+
def test_fetch(format, as_file_like, extended_id):
39+
PDB_ID = "1aki"
40+
pdb_id = PDB_ID if not extended_id else "pdb_0000" + PDB_ID
3241
path = None if as_file_like else tempfile.gettempdir()
33-
file_path_or_obj = rcsb.fetch("1l2y", format, path, overwrite=True)
42+
file_path_or_obj = rcsb.fetch(pdb_id, format, path, overwrite=True)
3443
if format == "pdb":
3544
file = pdb.PDBFile.read(file_path_or_obj)
45+
print(file.lines)
3646
pdb.get_structure(file)
3747
elif format == "cif":
3848
file = pdbx.CIFFile.read(file_path_or_obj)

0 commit comments

Comments
 (0)