Skip to content

Commit 805ecb5

Browse files
authored
Merge pull request #836 from padix-key/gallery-fixes
Hotfix: Fox documentation build
2 parents 89e450e + 40a5f5f commit 805ecb5

File tree

6 files changed

+55
-13
lines changed

6 files changed

+55
-13
lines changed

doc/examples/scripts/sequence/annotation/plasmid_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import biotite.sequence.io.genbank as gb
2626

2727
PLASMID_URL = (
28-
"https://media.addgene.org/snapgene-media/v2.0.0/sequences/12250/"
29-
"9998fdbe-051f-4dc6-ba0f-24e65127a0c5/addgene-plasmid-26092-sequence-12250.gbk"
28+
"https://media.addgene.org/snapgene-media/v3.0.0/sequences/466943/"
29+
"17c6ce2c-cf6d-46e8-a4c9-58cd4a4760b6/addgene-plasmid-26092-sequence-466943.gbk"
3030
)
3131

3232

doc/tutorial/database/rcsb.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ They can be included in search results by adding ``"computational"`` to the
139139
.. jupyter-execute::
140140

141141
query = (
142-
rcsb.FieldQuery("rcsb_polymer_entity.pdbx_description", contains_phrase="Hexokinase")
142+
rcsb.FieldQuery("rcsb_polymer_entity.pdbx_description", contains_phrase="Lysozyme")
143143
& rcsb.FieldQuery(
144144
"rcsb_entity_source_organism.scientific_name", exact_match="Homo sapiens"
145145
)
146146
)
147-
ids = rcsb.search(query, content_types=("experimental", "computational"))
147+
ids = rcsb.search(query, content_types=("computational",))
148148
print(ids)
149149

150150
The returned four-character IDs are the RCSB PDB IDs of experimental structures

src/biotite/database/afdb/download.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Adopted from https://www.uniprot.org/help/accession_numbers
1919
# adding the optional 'AF-' prefix and '-F1' suffix used by RCSB
2020
_UNIPROT_PATTERN = (
21-
r"^(?P<prefix>AF-)?"
21+
r"^(?P<prefix>(AF-)|(AF_AF))?"
2222
r"(?P<id>[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2})"
2323
r"(?P<suffix>-?F1)?$"
2424
)
@@ -34,8 +34,8 @@ def fetch(ids, format, target_path=None, overwrite=False, verbose=False):
3434
----------
3535
ids : str or iterable object of str
3636
A single ID or a list of IDs of the file(s) to be downloaded.
37-
They can be either UniProt IDs (e.g. ``P12345``) or AlphaFold DB IDs
38-
(e.g. ``AF-P12345F1``).
37+
They can be either UniProt IDs (e.g. ``P12345``), AlphaFold DB IDs
38+
(e.g. ``AF-P12345-F1``) or computational RCSB IDs (e.g. ``AF_AFP12345F1``).
3939
format : {'pdb', 'pdbx', 'cif', 'mmcif', 'bcif', 'fasta'}
4040
The format of the files to be downloaded.
4141
target_path : str, optional
@@ -145,7 +145,10 @@ def _get_file_url(id, format):
145145
The URL of the file to be downloaded.
146146
"""
147147
uniprot_id = _extract_id(id)
148-
metadata = requests.get(f"{_METADATA_URL}/{uniprot_id}").json()
148+
try:
149+
metadata = requests.get(f"{_METADATA_URL}/{uniprot_id}").json()
150+
except requests.exceptions.JSONDecodeError:
151+
raise RequestError("Received malformed JSON response")
149152
if len(metadata) == 0:
150153
raise RequestError(f"ID {id} is invalid")
151154
# A list of length 1 is always returned, if the response is valid

src/biotite/structure/io/pdb/convert.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"list_assemblies",
1717
"get_assembly",
1818
"get_unit_cell",
19+
"get_symmetry_mates",
1920
]
2021

2122
import warnings

tests/database/test_afdb.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import tempfile
66
import pytest
77
import biotite.database.afdb as afdb
8+
import biotite.database.rcsb as rcsb
89
import biotite.structure.io.pdb as pdb
910
import biotite.structure.io.pdbx as pdbx
1011
from biotite.database import RequestError
@@ -15,15 +16,20 @@
1516

1617
@pytest.mark.skipif(cannot_connect_to(AFDB_URL), reason="AlphaFold DB is not available")
1718
@pytest.mark.parametrize("as_file_like", [False, True])
18-
@pytest.mark.parametrize("entry_id", ["P12345", "AF-P12345-F1", "AF-P12345F1"])
19+
@pytest.mark.parametrize(
20+
"entry_id", ["P12345", "AF-P12345-F1", "AF-P12345F1", "AF_AFP12345F1"]
21+
)
1922
@pytest.mark.parametrize("format", ["pdb", "cif", "bcif"])
2023
def test_fetch(as_file_like, entry_id, format):
2124
"""
2225
Check if files in different formats can be downloaded by being able to parse them.
2326
Also ensure that the downloaded file refers to the given input ID
2427
"""
2528
path = None if as_file_like else tempfile.gettempdir()
26-
file_path_or_obj = afdb.fetch(entry_id, format, path, overwrite=True)
29+
try:
30+
file_path_or_obj = afdb.fetch(entry_id, format, path, overwrite=True)
31+
except RequestError:
32+
pytest.skip("AFDB is probably busy")
2733
if format == "pdb":
2834
file = pdb.PDBFile.read(file_path_or_obj)
2935
pdb.get_structure(file)
@@ -37,6 +43,34 @@ def test_fetch(as_file_like, entry_id, format):
3743
assert file.block["struct_ref"]["pdbx_db_accession"].as_item() == "P12345"
3844

3945

46+
def test_fetch_cross_id():
47+
"""
48+
Test if :func:`afdb.fetch()` works with AlphaFold DB cross-references
49+
in search results from :func:`rcsb.search()`.
50+
"""
51+
UNIPROT_ID = "P12345"
52+
53+
ids = rcsb.search(
54+
rcsb.FieldQuery(
55+
"rcsb_entry_info.structure_determination_methodology",
56+
exact_match="computational",
57+
)
58+
& rcsb.FieldQuery(
59+
"rcsb_polymer_entity_container_identifiers"
60+
".reference_sequence_identifiers"
61+
".database_accession",
62+
exact_match=UNIPROT_ID,
63+
),
64+
content_types=("computational",),
65+
)
66+
assert len(ids) == 1
67+
try:
68+
pdbx_file = pdbx.CIFFile.read(afdb.fetch(ids[0], "cif"))
69+
except RequestError:
70+
pytest.skip("AFDB is probably busy")
71+
assert pdbx_file.block["struct_ref"]["pdbx_db_accession"].as_item() == UNIPROT_ID
72+
73+
4074
@pytest.mark.skipif(cannot_connect_to(AFDB_URL), reason="AlphaFold DB is not available")
4175
def test_fetch_multiple():
4276
"""

tests/test_doctest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@
8686
pytest.param(
8787
"biotite.database.afdb",
8888
[],
89-
marks=pytest.mark.skipif(
90-
cannot_connect_to(AFDB_URL), reason="AlphaFold DB is not available"
91-
),
89+
marks=[
90+
pytest.mark.skipif(
91+
cannot_connect_to(AFDB_URL), reason="AlphaFold DB is not available"
92+
),
93+
# TODO: Check if AFDB tests in CI are still flaky
94+
pytest.mark.skip("Currently, AFDB is regularly busy"),
95+
],
9296
),
9397
pytest.param(
9498
"biotite.database.uniprot",

0 commit comments

Comments
 (0)