Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update models #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/protein_ligand_embedder/model_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from torch_geometric.loader import DataLoader
from DockingModels import EquivariantElucidatedDiffusion
from datasets import Dataset
from torch_scatter import scatter, scatter_mean


class ProteinLigandWrapper(nn.Module):
Expand Down Expand Up @@ -37,11 +38,11 @@ def get_emnbeddings(
tqdm_dataloader = tqdm(dataloader)
for batch in tqdm_dataloader:
batch = batch.to(self.diffusion_model.device)
_, x_t = self.diffusion_model.sample(batch, num_steps, dtype)
lig_seq_len = torch.bincount(batch['ligand'].batch).tolist()
lig_coords = torch.split(x_t, lig_seq_len)

col_emb.append(lig_coords)
x_t, rec_node_attr, lig_node_attr = self.diffusion_model.sample(batch, num_steps, dtype)
rec_node_attr = scatter_mean(rec_node_attr, batch['receptor'].batch, dim=0)
lig_node_attr = scatter_mean(lig_node_attr, batch['ligand'].batch, dim=0)
embedding = torch.cat([lig_node_attr, rec_node_attr], dim=1)
col_emb.append(embedding)
emb_dict['embedding'] = col_emb

return Dataset.from_dict(emb_dict)