Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Ignore apptainers
*.sif
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ You can find the environment file under `env` folder.

### Apptainer

Run this from this root directory:
```
apptainer build -s --nv ${CONTAINER_PATH} ./env/Apptainer
apptainer build --nv SpatialPPIv2.sif ./env/Apptainer
```

### Docker
Expand All @@ -33,25 +34,12 @@ docker build -t ${IMAGE_NAME} ./env
### Conda

```
conda create -n pytorch221 python=3.11
conda activate pytorch221
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip install numpy pandas seaborn tensorboard
pip install torch_geometric==2.5.1
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.2.0+cu118.html
conda install lightning -c conda-forge
pip install lightning[extra]
pip install matplotlib==3.8.3
pip install biopandas==0.5.1
pip install biopython==1.83
pip install transformers==4.40.2
pip install sentencepiece==0.2.0
pip install torchsummary==1.5.1
pip install scipy==1.12.0
pip install torch_cluster -f https://data.pyg.org/whl/torch-2.2.0+cu118.html
pip install git+https://github.com/yusuf1759/prodigy-cryst.git
pip install pinder[all]
pip install fair-esm
conda env create -f env/environment.yaml
```

or if you have mamba (should be faster)
```
mamba env create -f env/environment.yaml
```

## Inference protein interactions
Expand Down Expand Up @@ -79,6 +67,31 @@ When there is no suitable protein structure file, `fasta` files can be used to m
python inference.py --A demo/D3INY1.fasta --B demo/P62593.fasta
```

### Batch inference: one query protein vs a folder

You can screen one query protein against all supported files in a folder and save interaction probabilities to a CSV file:

```
python inference_batch.py --query demo/P33895.pdb --targets demo --output results.csv
```

Options:

- `--query`: Query protein file (`.pdb`/`.cif` or `.fasta`/`.fa`/`.faa`/`.fna`)
- `--targets`: Folder containing target protein files
- `--output`: Output CSV path. Default is `inference_batch.csv`
- `--chain_query`: Chain ID for query structure files. Default is `first`
- `--chain_targets`: Chain ID for target structure files. Default is `first`
- `--model`: Model for structure inputs (`ProtT5` or `ESM-2+ac`). For FASTA query, `ESM-2+ac` is forced
- `--device`: Either `cuda` or `cpu`

Notes:

- Query and target files must be the same modality:
- FASTA query requires all FASTA targets
- Structure query (`pdb`/`cif`) requires all structure targets
- The output CSV contains columns: `query`, `target`, `probability`, `status`, `error`

### Visualization of inference process

Please check the [notebook](https://github.com/ohuelab/SpatialPPIv2/blob/main/demo/example_visualize.ipynb).
Expand Down
58 changes: 38 additions & 20 deletions env/Apptainer
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
Bootstrap: docker
From: pytorch/pytorch:2.2.1-cuda11.8-cudnn8-devel
From: nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04

%files
env/environment.yaml environment.yaml

%post
apt-get update && apt-get install -y git

pip install -U pip
pip install numpy pandas seaborn tensorboard
pip install torch_geometric==2.5.1
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.2.0+cu118.html
conda install lightning -c conda-forge
pip install lightning[extra]
pip install matplotlib==3.8.3
pip install biopandas==0.5.1
pip install biopython==1.83
pip install transformers==4.40.2
pip install sentencepiece==0.2.0
pip install torchsummary==1.5.1
pip install scipy==1.12.0
pip install torch_cluster -f https://data.pyg.org/whl/torch-2.2.0+cu118.html
pip install git+https://github.com/yusuf1759/prodigy-cryst.git
pip install pinder[all]
pip install fair-esm
set -e
export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
curl \
git
rm -rf /var/lib/apt/lists/*

curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest \
| tar -xvj -C /usr/local/bin --strip-components=1 bin/micromamba

export MAMBA_ROOT_PREFIX=/opt/conda
mkdir -p "${MAMBA_ROOT_PREFIX}"

micromamba create -y -n SpatialPPIv2 -f environment.yaml
micromamba clean -a -y

%environment
export MAMBA_ROOT_PREFIX=/opt/conda
export MAMBA_EXE=/usr/local/bin/micromamba
export CONDA_DEFAULT_ENV=SpatialPPIv2
export PATH=/opt/conda/envs/SpatialPPIv2/bin:/opt/conda/bin:$PATH
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}

%runscript
if [ "$#" -eq 0 ]; then
exec /bin/bash
else
exec micromamba run -n SpatialPPIv2 "$@"
fi
61 changes: 41 additions & 20 deletions env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
FROM pytorch/pytorch:2.2.1-cuda11.8-cudnn8-devel
RUN apt-get update && apt-get install -y git
# Install dependency.
RUN pip install -U pip
RUN pip install numpy pandas seaborn tensorboard
RUN pip install torch_geometric==2.5.1
RUN pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.2.0+cu118.html
RUN conda install lightning -c conda-forge
RUN pip install lightning[extra]
RUN pip install matplotlib==3.8.3
RUN pip install biopandas==0.5.1
RUN pip install biopython==1.83
RUN pip install transformers==4.40.2
RUN pip install sentencepiece==0.2.0
RUN pip install torchsummary==1.5.1
RUN pip install scipy==1.12.0
RUN pip install torch_cluster -f https://data.pyg.org/whl/torch-2.2.0+cu118.html
RUN pip install git+https://github.com/yusuf1759/prodigy-cryst.git
RUN pip install pinder[all]
RUN pip install fair-esm
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV MAMBA_ROOT_PREFIX=/opt/conda
ENV MAMBA_EXE=/usr/local/bin/micromamba
ENV CONDA_DEFAULT_ENV=SpatialPPIv2
ENV CUDA_HOME=/usr/local/cuda
ENV PATH=/opt/conda/envs/SpatialPPIv2/bin:/opt/conda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}

WORKDIR /workspace

RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest \
| tar -xvj -C /usr/local/bin --strip-components=1 bin/micromamba

COPY env/environment.yaml /tmp/environment.yaml

RUN mkdir -p "${MAMBA_ROOT_PREFIX}" \
&& micromamba create -y -n SpatialPPIv2 -f /tmp/environment.yaml \
&& micromamba clean -a -y \
&& rm -f /tmp/environment.yaml

RUN printf '%s\n' \
'#!/usr/bin/env bash' \
'set -e' \
'if [ "$#" -eq 0 ]; then' \
' exec /bin/bash' \
'else' \
' exec micromamba run -n SpatialPPIv2 "$@"' \
'fi' \
> /usr/local/bin/docker-entrypoint.sh \
&& chmod +x /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Loading