RCSB Embedding Model is a PyTorch-based neural network that transforms macromolecular 3D structures into vector embeddings.
Preprint: Multi-scale structural similarity embedding search across entire proteomes.
A web-based implementation using this model for structure similarity search is available at rcsb-embedding-search.
If you are interested in training the model with a new dataset, visit the rcsb-embedding-search repository, which provides scripts and documentation for training.
The embedding model is trained to predict structural similarity by approximating TM-scores using cosine distances between embeddings. It consists of two main components:
- Protein Language Model (PLM): Computes residue-level embeddings from a given 3D structure.
- Residue Embedding Aggregator: A transformer-based neural network that aggregates these residue-level embeddings into a single vector.
Residue-wise embeddings of protein structures are computed using the ESM3 generative protein language model.
The aggregation component consists of six transformer encoder layers, each with a 3,072-neuron feedforward layer and ReLU activations. After processing through these layers, a summation pooling operation is applied, followed by 12 fully connected residual layers that refine the embeddings into a single 1,536-dimensional vector.
This repository provides the Residue Embedding Aggregator model, which processes ESM3 embeddings into a fixed-dimensional vector representation.
Ensure you have the following dependencies installed:
torch
First, compute ESM3 embeddings for the 3D structures using the script examples/esm_embeddings.py
with Biotite.
You can download a pretrained Residue Embedding Aggregator model from Hugging Face and load it as shown below:
import torch
from residue_embedding_aggregator import ResidueEmbeddingAggregator
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
weights = torch.load("rcsb-embedding-model.pt", weights_only=True, map_location=device)
aggregator_model = ResidueEmbeddingAggregator()
aggregator_model.load_state_dict(weights)
aggregator_model.to(device)
aggregator_model.eval()
# Example input (precomputed ESM3 embeddings)
structure_vect = aggregator_model(esm3_embeddings)
For any questions or comments, please open an issue on this repository.
This software is released under the BSD 3-Clause License. See the full license text below.
Copyright (c) 2024, RCSB Protein Data Bank, UC San Diego
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.