Write multiple models to a PDB file. :param results: Model results. :param out_path: Output path. :param b_factors: Optional B-factors.
(
results,
out_path: str = os.path.join("test_results", "debug.pdb"),
b_factors: Optional[np.ndarray] = None,
)
| 305 | |
| 306 | |
| 307 | def write_pdb_models( |
| 308 | results, |
| 309 | out_path: str = os.path.join("test_results", "debug.pdb"), |
| 310 | b_factors: Optional[np.ndarray] = None, |
| 311 | ): |
| 312 | """Write multiple models to a PDB file. |
| 313 | |
| 314 | :param results: Model results. |
| 315 | :param out_path: Output path. |
| 316 | :param b_factors: Optional B-factors. |
| 317 | """ |
| 318 | os.makedirs(os.path.dirname(out_path), exist_ok=True) |
| 319 | with open(out_path, "w") as of: |
| 320 | for mid, result in enumerate(results): |
| 321 | protein = from_prediction( |
| 322 | result["features"], |
| 323 | result, |
| 324 | b_factors=b_factors[mid] if b_factors is not None else None, |
| 325 | ) |
| 326 | out_string = to_pdb(protein, model=mid + 1) |
| 327 | of.write(out_string) |
| 328 | of.write("END") |
| 329 | |
| 330 | |
| 331 | def write_conformer_sdf( |
no test coverage detected