Perform a forward pass through the model. :param batch: A batch dictionary. :param training: Whether the model is in training mode. :param iter_id: The current iteration ID. :param observed_block_contacts: Observed block contacts. :param contact_prediction: W
(
self,
batch: MODEL_BATCH,
iter_id: Union[int, str] = 0,
observed_block_contacts: Optional[torch.Tensor] = None,
contact_prediction: bool = True,
infer_geometry_prior: bool = False,
score: bool = False,
use_template: bool = False,
**kwargs: Dict[str, Any],
)
| 1971 | return ret |
| 1972 | |
| 1973 | def forward( |
| 1974 | self, |
| 1975 | batch: MODEL_BATCH, |
| 1976 | iter_id: Union[int, str] = 0, |
| 1977 | observed_block_contacts: Optional[torch.Tensor] = None, |
| 1978 | contact_prediction: bool = True, |
| 1979 | infer_geometry_prior: bool = False, |
| 1980 | score: bool = False, |
| 1981 | use_template: bool = False, |
| 1982 | **kwargs: Dict[str, Any], |
| 1983 | ) -> Union[MODEL_BATCH, torch.Tensor]: |
| 1984 | """Perform a forward pass through the model. |
| 1985 | |
| 1986 | :param batch: A batch dictionary. |
| 1987 | :param training: Whether the model is in training mode. |
| 1988 | :param iter_id: The current iteration ID. |
| 1989 | :param observed_block_contacts: Observed block contacts. |
| 1990 | :param contact_prediction: Whether to predict contacts. |
| 1991 | :param infer_geometry_prior: Whether to predict using a geometry prior. |
| 1992 | :param score: Whether to predict a denoised complex structure. |
| 1993 | :param use_template: Whether to use a template protein structure. |
| 1994 | :param kwargs: Additional keyword arguments. |
| 1995 | :return: Batch dictionary with outputs or ligand binding affinity. |
| 1996 | """ |
| 1997 | prepare_batch(batch) |
| 1998 | |
| 1999 | batch = self.run_encoder_stack( |
| 2000 | batch, |
| 2001 | use_template=use_template, |
| 2002 | use_plddt=self.global_cfg.use_plddt, |
| 2003 | **kwargs, |
| 2004 | ) |
| 2005 | |
| 2006 | if contact_prediction: |
| 2007 | self.run_contact_map_stack( |
| 2008 | batch, |
| 2009 | iter_id, |
| 2010 | observed_block_contacts=observed_block_contacts, |
| 2011 | **kwargs, |
| 2012 | ) |
| 2013 | |
| 2014 | if infer_geometry_prior: |
| 2015 | assert ( |
| 2016 | batch["misc"]["protein_only"] is False |
| 2017 | ), "Only protein-ligand complexes are supported for a geometry prior." |
| 2018 | self.infer_geometry_prior(batch, **kwargs) |
| 2019 | |
| 2020 | if score: |
| 2021 | batch["outputs"]["denoised_prediction"] = self.run_score_head( |
| 2022 | batch, embedding_iter_id=iter_id, **kwargs |
| 2023 | ) |
| 2024 | |
| 2025 | return batch |
| 2026 | |
| 2027 | |
| 2028 | if __name__ == "__main__": |
no test coverage detected