# RFDiffusion
https://github.com/RosettaCommons/RFdiffusion.git
## Setup
```bash
git clone https://github.com/RosettaCommons/RFdiffusion.git
cd RFdiffusion
mkdir models && cd models
wget http://files.ipd.uw.edu/pub/RFdiffusion/6f5902ac237024bdd0c176cb93063dc4/Base_ckpt.pt
wget http://files.ipd.uw.edu/pub/RFdiffusion/e29311f6f1bf1af907f9ef9f44b8328b/Complex_base_ckpt.pt
wget http://files.ipd.uw.edu/pub/RFdiffusion/60f09a193fb5e5ccdc4980417708dbab/Complex_Fold_base_ckpt.pt
wget http://files.ipd.uw.edu/pub/RFdiffusion/74f51cfb8b440f50d70878e05361d8f0/InpaintSeq_ckpt.pt
wget http://files.ipd.uw.edu/pub/RFdiffusion/76d00716416567174cdb7ca96e208296/InpaintSeq_Fold_ckpt.pt
wget http://files.ipd.uw.edu/pub/RFdiffusion/5532d2e1f3a4738decd58b19d633b3c3/ActiveSite_ckpt.pt
wget http://files.ipd.uw.edu/pub/RFdiffusion/12fc204edeae5b57713c5ad7dcb97d39/Base_epoch8_ckpt.pt
#Optional:
wget http://files.ipd.uw.edu/pub/RFdiffusion/f572d396fae9206628714fb2ce00f72e/Complex_beta_ckpt.pt
# original structure prediction weights
wget http://files.ipd.uw.edu/pub/RFdiffusion/1befcb9b28e2f778f53d47f18b7597fa/RF_structure_prediction_weights.pt
cd ..
mkdir inputs && cd inputs
wget https://files.rcsb.org/view/5TPN.pdb
# ugly fix for https://github.com/RosettaCommons/RFdiffusion/issues/79
cd ..
mkdir shedules
```
## Building the Docker image and converting to a Singularity container
One needs a computer (preferably one running Linux OS) with docker and Singularity/Apptainer installed (one can use gitpod workspace to install Apptainer). Alternatively, one can build the docker container, push to a repository and the pull with singularity on Rackham.
1. Follow the original instructions to build the docker image https://github.com/RosettaCommons/RFdiffusion#docker
2. Convert to Singularity container
- on the same computer where docker image was build
```bash
sudo singularity build rfdiffusion.sif docker-daemon://rfdiffusion:latest
```
- Via DockerHub (*as example*)
```bash
singularity pull docker://xxxx/rfdiffusion:latest
```
## Run
```bash
cd RFdiffusion
singularity exec --nv \
--env TF_FORCE_UNIFIED_MEMORY=1,XLA_PYTHON_CLIENT_MEM_FRACTION=4.0,OPENMM_CPU_THREADS=10,HYDRA_FULL_ERROR=1 \
-B $PWD/schedules:/usr/local/lib/python3.9/dist-packages/schedules \
../rfdiffusion.sif \
python3.9 /app/RFdiffusion/scripts/run_inference.py \
inference.output_prefix=outputs/motifscaffolding \
inference.model_directory_path=$PWD/models \
inference.input_pdb=$PWD/inputs/5TPN.pdb \
inference.num_designs=3 \
'contigmap.contigs=[10-40/A163-181/10-40]'
```
```
[2023-11-14 11:36:31,738][__main__][INFO] - Found GPU with device_name Quadro K2200. Will run RFdiffusion on Quadro K2200
Reading models from models
[2023-11-14 11:36:31,739][rfdiffusion.inference.model_runners][INFO] - Reading checkpoint from models/Base_ckpt.pt
This is inf_conf.ckpt_path
models/Base_ckpt.pt
Assembling -model, -diffuser and -preprocess configs from checkpoint
USING MODEL CONFIG: self._conf[model][n_extra_block] = 4
USING MODEL CONFIG: self._conf[model][n_main_block] = 32
USING MODEL CONFIG: self._conf[model][n_ref_block] = 4
USING MODEL CONFIG: self._conf[model][d_msa] = 256
USING MODEL CONFIG: self._conf[model][d_msa_full] = 64
USING MODEL CONFIG: self._conf[model][d_pair] = 128
USING MODEL CONFIG: self._conf[model][d_templ] = 64
USING MODEL CONFIG: self._conf[model][n_head_msa] = 8
USING MODEL CONFIG: self._conf[model][n_head_pair] = 4
USING MODEL CONFIG: self._conf[model][n_head_templ] = 4
USING MODEL CONFIG: self._conf[model][d_hidden] = 32
USING MODEL CONFIG: self._conf[model][d_hidden_templ] = 32
USING MODEL CONFIG: self._conf[model][p_drop] = 0.15
USING MODEL CONFIG: self._conf[model][SE3_param_full] = {'num_layers': 1, 'num_channels': 32, 'num_degrees': 2, 'n_heads': 4, 'div': 4, 'l0_in_features': 8, 'l0_out_features': 8, 'l1_in_features': 3, 'l1_out_features': 2, 'num_edge_features': 32}
USING MODEL CONFIG: self._conf[model][SE3_param_topk] = {'num_layers': 1, 'num_channels': 32, 'num_degrees': 2, 'n_heads': 4, 'div': 4, 'l0_in_features': 64, 'l0_out_features': 64, 'l1_in_features': 3, 'l1_out_features': 2, 'num_edge_features': 64}
USING MODEL CONFIG: self._conf[model][freeze_track_motif] = False
USING MODEL CONFIG: self._conf[model][use_motif_timestep] = True
USING MODEL CONFIG: self._conf[diffuser][T] = 50
USING MODEL CONFIG: self._conf[diffuser][b_0] = 0.01
USING MODEL CONFIG: self._conf[diffuser][b_T] = 0.07
USING MODEL CONFIG: self._conf[diffuser][schedule_type] = linear
USING MODEL CONFIG: self._conf[diffuser][so3_type] = igso3
USING MODEL CONFIG: self._conf[diffuser][crd_scale] = 0.25
USING MODEL CONFIG: self._conf[diffuser][so3_schedule_type] = linear
USING MODEL CONFIG: self._conf[diffuser][min_b] = 1.5
USING MODEL CONFIG: self._conf[diffuser][max_b] = 2.5
USING MODEL CONFIG: self._conf[diffuser][min_sigma] = 0.02
USING MODEL CONFIG: self._conf[diffuser][max_sigma] = 1.5
USING MODEL CONFIG: self._conf[preprocess][sidechain_input] = False
USING MODEL CONFIG: self._conf[preprocess][motif_sidechain_input] = True
USING MODEL CONFIG: self._conf[preprocess][d_t1d] = 22
USING MODEL CONFIG: self._conf[preprocess][d_t2d] = 44
USING MODEL CONFIG: self._conf[preprocess][prob_self_cond] = 0.5
USING MODEL CONFIG: self._conf[preprocess][str_self_cond] = True
USING MODEL CONFIG: self._conf[preprocess][predict_previous] = False
[2023-11-14 11:36:52,768][rfdiffusion.inference.model_runners][INFO] - Loading checkpoint.
[2023-11-14 11:36:58,359][rfdiffusion.diffusion][INFO] - Calculating IGSO3.
Successful diffuser __init__
[2023-11-14 11:37:05,446][__main__][INFO] - Making design outputs/motifscaffolding_0
[2023-11-14 11:37:05,685][rfdiffusion.inference.model_runners][INFO] - Using contig: ['10-40/A163-181/10-40']
With this beta schedule (linear schedule, beta_0 = 0.04, beta_T = 0.28), alpha_bar_T = 0.00013696048699785024
[2023-11-14 11:37:05,856][rfdiffusion.inference.model_runners][INFO] - Sequence init: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
/usr/local/lib/python3.9/dist-packages/e3nn/o3/_spherical_harmonics.py:82: UserWarning: FALLBACK path has been taken inside: compileCudaFusionGroup. This is an indication that codegen Failed for some reason.
To debug try disable codegen fallback path via setting the env variable `export PYTORCH_NVFUSER_DISABLE=fallback`
To report the issue, try enable logging via setting the envvariable ` export PYTORCH_JIT_LOG_LEVEL=manager.cpp`
(Triggered internally at ../torch/csrc/jit/codegen/cuda/manager.cpp:237.)
sh = _spherical_harmonics(self._lmax, x[..., 0], x[..., 1], x[..., 2])
[2023-11-14 11:37:28,815][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.32
[2023-11-14 11:37:28,839][rfdiffusion.inference.model_runners][INFO] - Timestep 50, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:32,092][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.30
[2023-11-14 11:37:32,099][rfdiffusion.inference.model_runners][INFO] - Timestep 49, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:34,088][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.31
[2023-11-14 11:37:34,095][rfdiffusion.inference.model_runners][INFO] - Timestep 48, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:36,091][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.31
[2023-11-14 11:37:36,096][rfdiffusion.inference.model_runners][INFO] - Timestep 47, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:38,077][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.30
[2023-11-14 11:37:38,085][rfdiffusion.inference.model_runners][INFO] - Timestep 46, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:40,025][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.27
[2023-11-14 11:37:40,031][rfdiffusion.inference.model_runners][INFO] - Timestep 45, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:41,965][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.27
[2023-11-14 11:37:41,970][rfdiffusion.inference.model_runners][INFO] - Timestep 44, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:43,908][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.26
[2023-11-14 11:37:43,916][rfdiffusion.inference.model_runners][INFO] - Timestep 43, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:45,841][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.26
[2023-11-14 11:37:45,846][rfdiffusion.inference.model_runners][INFO] - Timestep 42, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
[2023-11-14 11:37:47,784][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.25
[2023-11-14 11:37:47,793][rfdiffusion.inference.model_runners][INFO] - Timestep 41, input to next step: ----------------------------------------EVNKIKSALLSTNKAVVSL-----------------------
...
[2023-11-14 11:41:05,372][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.28
[2023-11-14 11:41:05,376][rfdiffusion.inference.model_runners][INFO] - Timestep 3, input to next step: -------------EVNKIKSALLSTNKAVVSL--------------------
[2023-11-14 11:41:06,335][rfdiffusion.inference.utils][INFO] - Sampled motif RMSD: 0.28
[2023-11-14 11:41:06,340][rfdiffusion.inference.model_runners][INFO] - Timestep 2, input to next step: -------------EVNKIKSALLSTNKAVVSL--------------------
[2023-11-14 11:41:08,232][__main__][INFO] - Finished design in 0.83 minutes
```
## Contacts:
- [Pavlin Mitev](https://katalog.uu.se/profile/?id=N3-1425)
- [UPPMAX](https://www.uppmax.uu.se/)
- [AE@UPPMAX - related documentation](/8sqXISVRRquPDSw9o1DizQ)
![](https://live.webb.uu.se/digitalAssets/207/c_207717-l_3-k_bg-city.png)
###### tags: `UPPMAX`