# Installing ROCKET

### 1. Install OpenFold

We forked OpenFold and cleaned up a few installation details for ROCKET users.

{% hint style="info" %}
Plan for a GPU machine, enough free disk space, and a clean environment before you start.
{% endhint %}

**Note**: The ⁠openfold installation requires approximately 6 GB of free space to download weights. Please ensure you start in a directory with sufficient available space.

**Note**: To ensure a smooth installation and execution of ROCKET, install on a GPU machine that matches the hardware you’ll use in production. In other words, for HPC users, if you plan to run your code on a node with a particular GPU model, request the same GPU model when you install OpenFold. This is important because the installation process performs hardware-specific compilation. We also recommend using GPUs with CUDA Compute Capability 8.0 or higher.

1. Clone our fork of the OpenFold repo, switch to the `pl_upgrades` branch to work with CUDA 12:

   ```bash
   git clone https://github.com/minhuanli/rocket_openfold.git
   cd rocket_openfold
   git checkout pl_upgrades
   ```
2. Create a conda or mamba environment with `environment.yml`. Mamba is recommended because the dependency set is large. If you use Conda instead, replace `mamba` with `conda` in the commands below.

   **Note**: If you work with an HPC cluster with package management like `module`, purge all your modules before this step to avoid conflicts.

   ```bash
   mamba env create -n <env_name_you_like> -f environment.yml
   mamba activate <env_name_you_like>
   ```

   We keep `flash-attn` outside the YAML so you can install a compatible version manually. This OpenFold branch uses PyTorch 2.1. The latest `flash-attn` will not work. The `--no-build-isolation` flag also lets `ninja` speed up compilation.
3. Install a compatible `flash-attn` build:

   ```bash
   pip install flash-attn==2.2.2 --no-build-isolation
   ```
4. Run the setup script:

   ```bash
   ./scripts/install_third_party_dependencies.sh
   ```

   Add the following lines to `<path_to_your_conda_env>/etc/conda/activate.d/env_vars.sh`. Create the file if it does not exist.

   ```bash
   #!/bin/sh

   export LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH
   export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
   ```

   This makes the library path update happen automatically whenever the environment is activated.
5. Download AlphaFold2 weights and set the resource path:

   ```bash
   ./scripts/download_alphafold_params.sh ./openfold/resources
   ```

   **Note:** You can also download OpenFold weights if you want to test them.

   Append the following line to the same `env_vars.sh` file:

   ```bash
   export OPENFOLD_RESOURCES="<ABSOLUTE_PATH_TO_OPENFOLD_FOLDER>/openfold/resources"
   ```

   `<ABSOLUTE_PATH_TO_OPENFOLD_FOLDER>` should be the output of `pwd -P` you get from the OpenFold repo path.

   Deactivate and reactivate your environment. Then confirm the path:

   ```bash
   echo $OPENFOLD_RESOURCES 
   ```
6. Check your OpenFold build with unit tests:

   ```bash
   ./scripts/run_unit_tests.sh
   ```

   Ensure you see no errors:

   ```
   ...
   Time to load evoformer_attn op: 243.8257336616516 seconds
   ............s...s.sss.ss.....sssssssss.sss....ssssss..s.s.s.ss.s......s.s..ss...ss.s.s....s........
   ----------------------------------------------------------------------
   Ran 117 tests in 275.889s

   OK (skipped=41)
   ```

### 2. Install Phenix

Required for automatic preprocessing and post-refinement.

{% hint style="warning" %}
Use an absolute install path for Phenix. It avoids path issues later.
{% endhint %}

[Phenix](https://phenix-online.org/) is required for automatic data preprocessing and for post-refinement when polishing final model geometry. Follow the steps below to install it and **add the path to the system environment variables**:

1. Download the latest Python 3 nightly build from <https://phenix-online.org/download>. Use at least version `2.0-5936`.
2. Run the installer

   ```bash
   bash phenix-installer-2.0rc1-5936-<platform>.sh
   ```

   You will be prompted to type your preferred path of installation, after specifying it, you will see:

   ```
   Phenix will now be installed into this location:
   <phenix_directory>/phenix-2.0-5936
   ```

   **Note**: `<phenix_directory>` must be an absolute path. The installer will create `<phenix_directory>/phenix-2.0-5936` and install there.
3. Append the following line to the same `env_vars.sh` file:

   ```bash
   export PHENIX_ROOT="<phenix_directory>/phenix-2.0-5936"
   ```

   `<phenix_directory>` is the path you chose in the previous step.

   Deactivate and reactivate your environment. Then confirm the path:

   ```bash
   echo $PHENIX_ROOT 
   ```

### 3. Install ROCKET

Move to a separate parent directory, clone ROCKET, then install it with `pip`:

```bash
git clone https://github.com/alisiafadini/ROCKET.git
cd ROCKET
pip install .
```

This also installs dependencies such as `SFcalculator` and `reciprocalspaceship`.

**Note:** If you get errors about incompatibility of `prompt_toolkit`, ignore them.

For editable install mode, run:

```bash
pip install -e .
```

Run `rk.score --help` after installation. If it prints normal help text without errors, the install is ready.

{% hint style="success" %}
Once this works, move on to the X-ray or cryo-EM setup tutorial.
{% endhint %}

[Create an issue](https://github.com/alisiafadini/ROCKET/issues) in our repo


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rocket-9.gitbook.io/rocket-docs/getting-started/installing-rocket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
