Download libs/utils/io_pdb.py from QPromaQ/Docking_project: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/main/libs/utils/io_pdb.py
- Command line
-
hf download hf://datasets/QPromaQ/Docking_project/libs/utils/io_pdb.py
-
curl -L -o io_pdb.py https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/main/libs/utils/io_pdb.py
1.03 kB
| from __future__ import annotations | |
| from pathlib import Path | |
| from typing import Any, Dict | |
| from Bio.PDB import MMCIFParser, PDBParser | |
| def load_structure(path: str | Path, structure_id: str = "target") -> Any: | |
| """Load PDB or mmCIF structure object using Biopython.""" | |
| source = Path(path) | |
| suffix = source.suffix.lower() | |
| if suffix in {".pdb", ".ent"}: | |
| parser = PDBParser(QUIET=True) | |
| return parser.get_structure(structure_id, str(source)) | |
| if suffix in {".cif", ".mmcif"}: | |
| parser = MMCIFParser(QUIET=True) | |
| return parser.get_structure(structure_id, str(source)) | |
| raise ValueError(f"Unsupported structure extension: {source}") | |
| def summarize_structure(path: str | Path) -> Dict[str, int]: | |
| structure = load_structure(path) | |
| residues = [r for r in structure.get_residues() if r.id[0] == " "] | |
| atoms = list(structure.get_atoms()) | |
| chains = list(structure.get_chains()) | |
| return {"residue_count": len(residues), "atom_count": len(atoms), "chain_count": len(chains)} | |