(self, batch, model, plddt_model, device)
| 319 | return batch, structure, record |
| 320 | |
| 321 | def run_inference(self, batch, model, plddt_model, device): |
| 322 | # run inference for target protein |
| 323 | if self.backend == "torch": |
| 324 | noise = torch.randn_like(batch["coords"]).to(device) |
| 325 | elif self.backend == "mlx": |
| 326 | noise = mx.random.normal(batch["coords"].shape) |
| 327 | out_dict = self.sampler.sample(model, self.flow, noise, batch) |
| 328 | |
| 329 | plddt_out_module = plddt_model["plddt_out_module"] |
| 330 | plddt_latent_module = plddt_model["plddt_latent_module"] |
| 331 | |
| 332 | if plddt_latent_module is None or plddt_out_module is None: |
| 333 | plddts = None |
| 334 | else: |
| 335 | if self.backend == "torch": |
| 336 | t = torch.ones(batch["coords"].shape[0], device=device) |
| 337 | # use unscaled coords to extract latent for pLDDT prediction |
| 338 | out_feat = plddt_latent_module( |
| 339 | out_dict["denoised_coords"].detach(), t, batch |
| 340 | ) |
| 341 | plddt_out_dict = plddt_out_module( |
| 342 | out_feat["latent"].detach(), |
| 343 | batch, |
| 344 | ) |
| 345 | elif self.backend == "mlx": |
| 346 | t = mx.ones(batch["coords"].shape[0]) |
| 347 | # use unscaled coords to extract latent for pLDDT prediction |
| 348 | out_feat = plddt_latent_module(out_dict["denoised_coords"], t, batch) |
| 349 | plddt_out_dict = plddt_out_module( |
| 350 | out_feat["latent"], |
| 351 | batch, |
| 352 | ) |
| 353 | # scale pLDDT to [0, 100] |
| 354 | plddts = plddt_out_dict["plddt"] * 100.0 |
| 355 | |
| 356 | out_dict = self.processor.postprocess(out_dict, batch) |
| 357 | # sampled_coord = out_dict['denoised_coords'].detach() |
| 358 | if self.backend == "torch": |
| 359 | sampled_coord = out_dict["denoised_coords"].detach() |
| 360 | else: |
| 361 | sampled_coord = out_dict["denoised_coords"] |
| 362 | |
| 363 | return { |
| 364 | "sampled_coord": sampled_coord, |
| 365 | "pad_mask": batch["atom_pad_mask"], |
| 366 | "plddts": plddts, |
| 367 | } |
| 368 | |
| 369 | def save_result(self, structure, record, results, out_name): |
| 370 | sampled_coord = results["sampled_coord"] |
nothing calls this directly
no test coverage detected