Source code for boltz_data.external.rcsb
"""RCSB PDB API integration functions."""
import gemmi
import requests
from boltz_data.cif import read_single_cif_from_file
[docs]
def get_current_rcsb_pdb_ids() -> list[str]:
"""Fetch the list of current PDB IDs from RCSB PDB."""
url = "https://data.rcsb.org/rest/v1/holdings/current/entry_ids"
response = requests.get(url, timeout=30)
data: list[str] = response.json()
return data
[docs]
def get_mmcif_from_rcsb(*, pdb_id: str) -> gemmi.cif.Block:
"""
Download and parse an mmCIF file from RCSB PDB.
Args:
pdb_id: The PDB identifier to download.
Returns:
The parsed mmCIF block.
"""
url = f"https://files.rcsb.org/download/{pdb_id}.cif.gz"
return read_single_cif_from_file(url)