Skip to content

Commit

Permalink
Update tests to work with CIF files
Browse files Browse the repository at this point in the history
  • Loading branch information
dacarlin authored and padix-key committed Jan 22, 2025
1 parent f1c12f6 commit 8cbd650
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/biotite/database/alphafold/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def fetch(ids, target_path=None, format="pdb", overwrite=False, verbose=False):
metadata_response = requests.get(f"{_fetch_url}/{id}")
assert_valid_response(metadata_response.status_code)
metadata_json = metadata_response.json()[0]
print(metadata_json)
# a list of length 1 is always returned
file_url = metadata_json[f"{format}Url"]
file_response = requests.get(file_url)
Expand Down
26 changes: 25 additions & 1 deletion tests/database/test_alphafold.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import tempfile
import pytest
import biotite.database.alphafold as alphafold
import biotite.structure.io.pdb as pdb
import biotite.structure.io.pdb as pdb
import biotite.structure.io.pdbx as pdbx
from biotite.database import RequestError
from ..util import cannot_connect_to

Expand Down Expand Up @@ -44,3 +45,26 @@ def test_fetch_invalid(format):
)


@pytest.mark.skipif(
cannot_connect_to(ALPHAFOLD_URL),
reason="AlphaFold is not available"
)
@pytest.mark.parametrize("format", ["pdb", "cif"])
def test_fetch_multiple(format):
acc = ["P12345", "P12345"]
files = alphafold.fetch(
acc, target_path=tempfile.gettempdir(), format=format, overwrite=True
)
print(files)
for file in files:
if format == "pdb":
pdb_file = pdb.PDBFile.read(file)
structure = pdb_file.get_structure()
assert len(structure) > 0
elif format == "cif":
cif_file = pdbx.PDBxFile.read(file)
assert "citation_author" in cif_file.keys()




0 comments on commit 8cbd650

Please sign in to comment.