WARNING This code is work-in-progress!
pip -q install git+https://github.com/sokrypton/[email protected]
from colabdesign.mpnn import mk_mpnn_model
mpnn_model = mk_mpnn_model()
mpnn_model.prep_inputs(pdb_filename="tmp.pdb")
samples = mpnn_model.sample_parallel()
mpnn_model.sample()
- sample one sequencempnn_model.sample(temperature=0.1)
- control sampling temperaturempnn_model.sample(decoding_order=np.array([0,1,2,3,4,5]))
specify the order of autoregressive samplingmpnn_model.sample(decoding_order=np.array([[0,3],[1,4],[2,5]]))
- specify order of "tied" autoregressive samplingmpnn_model.sample_parallel(batch=128)
- sample 128 sequences in parallel (all options above apply)mpnn_model.score(seq="QWERTY")
- score one sequencempnn_model.get_unconditional_logits()
- get P(sequence | structure)
mpnn_model.prep_inputs(pdb_filename="tmp.pdb", fix_pos="1-10")
mpnn_model.prep_inputs(pdb_filename="tmp.pdb", fix_pos="1-10", inverse=True)
mpnn_model.prep_inputs(pdb_filename="tmp.pdb", chain="A,B", fix_pos="A1-10,B5-20")
mpnn_model.prep_inputs(pdb_filename="tmp.pdb", chain="A,B", fix_pos="A")
mpnn_model.prep_inputs(pdb_filename="tmp.pdb", rm_aa="C")
You can modify the bias matrix directly! The bias matrix is a (length, 21) matrix. Using large negative/positive values in the bias matrix is how we prevent certain amino acids from being sampled (rm_aa) and fix certain positions (fix_pos). For reference, the alphabet used: ARNDCQEGHILKMFPSTWYV
.
For example, to add alanine bias to the first position, do:
from colabdesign.mpnn.model import aa_order
mpnn_model.prep_inputs(pdb_filename="tmp.pdb")
mpnn_model._inputs["bias"][0,aa_order["A"]] = 1.0
For example, if you want to add a hydrophilic bias to all positions, you can do:
for k in "DEHKNQRSTWY":
mpnn_model._inputs["bias"][:,aa_order[k]] += 1.39
mpnn_model.prep_inputs(pdb_filename="tmp.pdb", chain="A,B,C", homooligomeric=True)
mkdir params
curl -fsSL https://storage.googleapis.com/alphafold/alphafold_params_2022-03-02.tar | tar x -C params
from colabdesign.af import mk_af_model
af_model = mk_af_model()
af_model.prep_inputs(pdb_filename="tmp.pdb")
for n,S in enumerate(samples["S"]):
af_model.predict(seq=S.argmax(-1))
af_model.save_current_pdb(f"{n}.pdb")
- Shihao Feng @JeffSHF
- Sergey Ovchinnikov @sokrypton
- Simon Kozlov @sim0nsays
- Justas Dauparas @dauparas - original pytorch code