Skip to content

Commit

Permalink
merge branch new_encoders; fix conflcit
Browse files Browse the repository at this point in the history
  • Loading branch information
shahskova committed Feb 19, 2024
2 parents 4b5995e + 4a7ab4c commit 7d653d4
Show file tree
Hide file tree
Showing 47 changed files with 384,529 additions and 2,806 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
epitopes_comparison/models/*
glycosylation_prediction/models/*
epitopes_prediction/models/*
epitopes_prediction/dataset_generation/PDB_blast_db/*
saprot_utils/__pycache__/*
75 changes: 23 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,36 @@
# SEMA
SEMA (Spatial Epitope Modelling with Artificial intelligence) is a tool for conformational B-cell eptiope prediction from the primary protein sequence or tertiary structure. SEMA involves the use of sequence-based (SEMA-1D) and structure-based (SEMA-3D) approaches. SEMA-1D model is based on an ensemble of [Esm-1v](https://github.com/facebookresearch/esm) transformer deep neural network protein language models. SEMA-3D model is based on an ensemble of inverse folding models, [Esm-IF1](https://github.com/facebookresearch/esm). Both models were fine-tuned to predict the antigen interaction propensity of the amino acid (AA) residue with Fab regions of immunoglobulins. SEMA provides an interpretable score indicating the log-scaled expected number of contacts with antibody residues.
# SEMA 2.0
SEMA (Spatial Epitope Modelling with Artificial intelligence) is a set of research tools for sequence- and structure-based conformational B-cell eptiope prediction, accurate identification of N-glycosylation sites, and a distinctive module for comparing the structures of antigen B-cell epitopes enhancing our ability to analyze and understand its immunogenic properties.

SEMA is also availble via [web-interface](http://sema.airi.net/).

## Instalation
This script creates new environment `sema_env`
```
./setup.sh
```
## Models
### Conformational B-cell eptiope prediction models:
Involves the use of sequence-based (SEMA-1D) and structure-based (SEMA-3D) approaches. SEMA-1D model is based on an ensemble of [ESM2](https://github.com/facebookresearch/esm) transformer deep neural network protein language models. SEMA-3D model is based on an ensemble of inverse folding models, [SaProt](https://github.com/westlake-repl/SaProt). Both models were fine-tuned to predict the antigen interaction propensity of the amino acid (AA) residue with Fab regions of immunoglobulins. SEMA provides an interpretable score indicating the log-scaled expected number of contacts with antibody residues. \
Code, datset and additional README is stored at `./epitopes_prediction/` folder

### Disclaimer:
This code is provided under MIT License

## Data
The entire data set with contact number per residue can be downloaded from the [link](https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/dataset.csv.tar.gz).<br /> Dataset contains following columns:

* **pdb_id** &#8212; identificator in the [PDB database](https://www.rcsb.org)
* **resi_pos** &#8212; the residue position in the PDB structure
* **resi_name** &#8212; amino acid 3-letter name
* **res_aa** &#8212; amino acid symbol
* **anigen_chain** &#8212; name of the anigen chain in the PDB structure
* **fab_chains** &#8212; names of the antibody chains in the PDB structure
* **contact_number_R1=i_R2=j** &#8212; contact number values calcualted as the number of antibody residues in contact with any atom of antigen residues within the distance radius R1. Residues between R1 and R2 have a zero contact number. Residues, which located outside R2 distance radius, have a '-100' value.
### N-glycosylation sites prediction model:
The N-glycosylation prediction model (SEMA_PTM) was obtained by adding a fully-connected linear layer on the top layer of the ESM-2 pre-trained model. \
Code, datset with additional README is stored at `./glycosylation_prediction/` folder

You can generate your own dataset with different R1 and R2 using scripts in the *dataset_generation* directory.
### Epitope comparison model
The model is trained to identify local structural similarities within proteins, based on the non-linear transformation of multiplication of the embeddings of PLM with geometric modalities. \
Code, datset and additional README is stored at `./epitopes_comparison/` folder

The directory *data* contains example of training and test sets and example of pdb-file for SEMA-3D inference.
## Notes

## Environment creation
Python 3.8 is required.
```pip3 install virtualenv
virtualenv sema_env
source sema_env/bin/activate
pip install -r requirements.txt
```
### Foldseek
We used [SaProt](https://github.com/westlake-repl/SaProt) as base model for SEMA-3D and epitope comparison model. This model utilizes 3Di tokens, prodused by [Foldseek](https://github.com/steineggerlab/foldseek). To create 3Di tokens we used `foldseek_util.py` script from [SaProt](https://github.com/westlake-repl/SaProt?tab=readme-ov-file#convert-protein-structure-into-structure-aware-sequence) and foldseek binary file. These files are stored at `./saprot_utils` folder

## Training the models
For trainig the model you can use Jupyter Notebooks [SEMA-1D_finetuning](https://github.com/AIRI-Institute/SEMAi/blob/main/SEMA_1D/SEMA-1D_finetuning.ipynb) or [SEMA-3D_finetuning](https://github.com/AIRI-Institute/SEMAi/blob/main/SEMA_3D/SEMA-3D_finetuning.ipynb).

In case you will be training SEMA-3D model, you will need to download additional data:<br/>
[pickle-file](https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/pdb_structures.pkl) with a dataset of teritic structures or an [original set](https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/pdb_structures.tar.gz) of processed pdb-files.
### Disclaimer:
This code is provided under MIT License:

## Inference
Prepare your model weights or download ours:<br />
1. Create direcrory *models*: `mkdir models`.
2. Go into the directory: `cd models`
4. Download weights for SEMA-1D:
```
wget -O sema_1d_ft_cn_atom_r1_8.0_r2_16.0_0.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_1d_ft_cn_atom_r1_8.0_r2_16.0_0.pth
wget -O sema_1d_ft_cn_atom_r1_8.0_r2_16.0_1.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_1d_ft_cn_atom_r1_8.0_r2_16.0_1.pth
wget -O sema_1d_ft_cn_atom_r1_8.0_r2_16.0_2.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_1d_ft_cn_atom_r1_8.0_r2_16.0_2.pth
wget -O sema_1d_ft_cn_atom_r1_8.0_r2_16.0_3.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_1d_ft_cn_atom_r1_8.0_r2_16.0_3.pth
wget -O sema_1d_ft_cn_atom_r1_8.0_r2_16.0_4.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_1d_ft_cn_atom_r1_8.0_r2_16.0_4.pth
```

or SEMA-3D:
```
wget -O sema_3d_cn_atom_r1_8.0_r2_18.0_0.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_3d_cn_atom_r1_8.0_r2_18.0_0.pt
wget -O sema_3d_cn_atom_r1_8.0_r2_18.0_1.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_3d_cn_atom_r1_8.0_r2_18.0_1.pt
wget -O sema_3d_cn_atom_r1_8.0_r2_18.0_2.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_3d_cn_atom_r1_8.0_r2_18.0_2.pt
wget -O sema_3d_cn_atom_r1_8.0_r2_18.0_3.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_3d_cn_atom_r1_8.0_r2_18.0_3.pt
wget -O sema_3d_cn_atom_r1_8.0_r2_18.0_4.pth https://bioinformatics-kardymon.obs.ru-moscow-1.hc.sbercloud.ru/SEMA_weights/sema_3d_cn_atom_r1_8.0_r2_18.0_4.pt
```

The MIT License (MIT) Copyright (c) 2016 AYLIEN Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Next, run inference using Jupyter Notebooks [SEMA-1D_inference](https://github.com/AIRI-Institute/SEMAi/blob/main/SEMA_1D/SEMA-1D_inference.ipynb) or [SEMA-3D_inference](https://github.com/AIRI-Institute/SEMAi/blob/main/SEMA_3D/SEMA-3D_inference.ipynb).



287 changes: 0 additions & 287 deletions SEMA_1D/SEMA-1D_inference.ipynb

This file was deleted.

Loading

0 comments on commit 7d653d4

Please sign in to comment.