generatebio / chroma

A generative model for programmable protein design
Apache License 2.0
627 stars 74 forks source link

Design multiple sequences for the same input structure #48

Closed prateekbansal97 closed 2 months ago

prateekbansal97 commented 2 months ago

Hello,

Thanks for Chroma! It is a pretty great tool.

I do have a query - is there a way to design multiple sequences (say 10) for the same input structure? I am new to Chroma and have tried running the design code multiple times with the same structure, but it gives out the same output.

Any help in this matter would be appreciated. Thank you!

Here is the code I am using (same as the one in the README)

protein = Protein(f'/path/to/protein.pdb',device='cuda')
protein = chroma.design(protein)
protein.to(f"output_path.pdb")
wujiewang commented 2 months ago

Hey, thanks for the question.

I think you can do this by parsing a batch of backbones by calling

X_designed, C, S_designed = chroma.design_network.sample(X.cuda(), C.cuda(), sampling_method="potts")

where X has shpe (Nbatch x Nres x 4 x 3) and C has shape (Nbatch x Nres)

prateekbansal97 commented 2 months ago

Hi @wujiewang ,

Thanks for the reply.

In this case, I generated X and C using X, C, S = protein.to_XCS() but got an X.shape = [1, Nres, 4, 3]. How do I make it into size of the batch?

wujiewang commented 2 months ago

It is simpler than you think, you just need to copy X and C several time and concatenate. something like :

torch.cat( [X] * 10, dim=0 )

prateekbansal97 commented 2 months ago

The solution you gave is working. Thank you so much!