rcsb-embedding-model 0.0.6__py3-none-any.whl → 0.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rcsb-embedding-model might be problematic. Click here for more details.

@@ -1,6 +1,4 @@
1
1
 
2
- from enum import Enum
3
-
4
2
 
5
3
  def arg_devices(devices):
6
4
  if len(devices) == 1:
@@ -5,17 +5,29 @@ import typer
5
5
  from rcsb_embedding_model.cli.args_utils import arg_devices
6
6
  from rcsb_embedding_model.types.api_types import SrcFormat, Accelerator, SrcLocation
7
7
 
8
- app = typer.Typer()
8
+ app = typer.Typer(
9
+ add_completion=False
10
+ )
9
11
 
10
12
 
11
- @app.command(name="residue-embedding")
13
+ @app.command(
14
+ name="residue-embedding",
15
+ help="Calculate residue level embeddings of protein structures using ESM3."
16
+ )
12
17
  def residue_embedding(
13
18
  src_file: Annotated[typer.FileText, typer.Option(
14
19
  exists=True,
15
20
  file_okay=True,
16
21
  dir_okay=False,
17
22
  resolve_path=True,
18
- help='CSV file 3 columns: Structure File | Chain Id (asym_i for cif files) | Output file name.'
23
+ help='CSV file 3 columns: Structure File Path | Chain Id (asym_i for cif files) | Output file name.'
24
+ )],
25
+ output_path: Annotated[typer.FileText, typer.Option(
26
+ exists=True,
27
+ file_okay=False,
28
+ dir_okay=True,
29
+ resolve_path=True,
30
+ help='Output path to store predictions.'
19
31
  )],
20
32
  src_location: Annotated[SrcLocation, typer.Option(
21
33
  help='Source input location.'
@@ -37,14 +49,7 @@ def residue_embedding(
37
49
  )] = Accelerator.auto,
38
50
  devices: Annotated[List[str], typer.Option(
39
51
  help='The devices to use. Can be set to a positive number or "auto". Repeat this argument to indicate multiple indices of devices. "auto" for automatic selection based on the chosen accelerator.'
40
- )] = tuple(['auto']),
41
- output_path: Annotated[typer.FileText, typer.Option(
42
- exists=True,
43
- file_okay=False,
44
- dir_okay=True,
45
- resolve_path=True,
46
- help='Output path to store predictions.'
47
- )] = None
52
+ )] = tuple(['auto'])
48
53
  ):
49
54
  from rcsb_embedding_model.inference.esm_inference import predict
50
55
  predict(
@@ -60,14 +65,27 @@ def residue_embedding(
60
65
  )
61
66
 
62
67
 
63
- @app.command(name="structure-embedding")
68
+ @app.command(
69
+ name="structure-embedding",
70
+ help="Calculate single-chain protein embeddings from structural files. Predictions are stored in a single pandas data-frame file."
71
+ )
64
72
  def structure_embedding(
65
73
  src_file: Annotated[typer.FileText, typer.Option(
66
74
  exists=True,
67
75
  file_okay=True,
68
76
  dir_okay=False,
69
77
  resolve_path=True,
70
- help='CSV file 3 columns: Structure File | Chain Id (asym_i for cif files) | Output file name.'
78
+ help='CSV file 3 columns: Structure File Path | Chain Id (asym_i for cif files) | Output file name.'
79
+ )],
80
+ output_path: Annotated[typer.FileText, typer.Option(
81
+ exists=True,
82
+ file_okay=False,
83
+ dir_okay=True,
84
+ resolve_path=True,
85
+ help='Output path to store predictions.'
86
+ )],
87
+ out_df_id: Annotated[str, typer.Option(
88
+ help='File name to store predicted embeddings.'
71
89
  )],
72
90
  src_location: Annotated[SrcLocation, typer.Option(
73
91
  help='Source input location.'
@@ -89,19 +107,27 @@ def structure_embedding(
89
107
  )] = Accelerator.auto,
90
108
  devices: Annotated[List[str], typer.Option(
91
109
  help='The devices to use. Can be set to a positive number or "auto". Repeat this argument to indicate multiple indices of devices. "auto" for automatic selection based on the chosen accelerator.'
92
- )] = tuple(['auto']),
93
- output_path: Annotated[typer.FileText, typer.Option(
94
- exists=True,
95
- file_okay=False,
96
- dir_okay=True,
97
- resolve_path=True,
98
- help='Output path to store predictions.'
99
- )] = None
110
+ )] = tuple(['auto'])
100
111
  ):
101
- pass
112
+ from rcsb_embedding_model.inference.structure_inference import predict
113
+ predict(
114
+ csv_file=src_file,
115
+ src_location=src_location,
116
+ src_format=src_format,
117
+ batch_size=batch_size,
118
+ num_workers=num_workers,
119
+ num_nodes=num_nodes,
120
+ accelerator=accelerator,
121
+ devices=arg_devices(devices),
122
+ out_path=output_path,
123
+ out_df_id=out_df_id
124
+ )
102
125
 
103
126
 
104
- @app.command(name="chain-embedding")
127
+ @app.command(
128
+ name="chain-embedding",
129
+ help="Calculate single-chain protein embeddings from residue level embeddings stored as torch tensor files."
130
+ )
105
131
  def chain_embedding(
106
132
  src_file: Annotated[typer.FileText, typer.Option(
107
133
  exists=True,
@@ -110,6 +136,13 @@ def chain_embedding(
110
136
  resolve_path=True,
111
137
  help='CSV file 2 columns: Residue Embedding Tensor File | Output file name.'
112
138
  )],
139
+ output_path: Annotated[typer.FileText, typer.Option(
140
+ exists=True,
141
+ file_okay=False,
142
+ dir_okay=True,
143
+ resolve_path=True,
144
+ help='Output path to store predictions.'
145
+ )],
113
146
  batch_size: Annotated[int, typer.Option(
114
147
  help='Number of samples processed together in one iteration.'
115
148
  )] = 1,
@@ -124,14 +157,7 @@ def chain_embedding(
124
157
  )] = Accelerator.auto,
125
158
  devices: Annotated[List[str], typer.Option(
126
159
  help='The devices to use. Can be set to a positive number or "auto". Repeat this argument to indicate multiple indices of devices. "auto" for automatic selection based on the chosen accelerator.'
127
- )] = tuple(['auto']),
128
- output_path: Annotated[typer.FileText, typer.Option(
129
- exists=True,
130
- file_okay=False,
131
- dir_okay=True,
132
- resolve_path=True,
133
- help='Output path to store predictions.'
134
- )] = None
160
+ )] = tuple(['auto'])
135
161
  ):
136
162
  from rcsb_embedding_model.inference.chain_inference import predict
137
163
  predict(
@@ -1,5 +1,4 @@
1
1
  import argparse
2
- import os
3
2
 
4
3
  import torch
5
4
  from biotite.structure import chain_iter
@@ -48,11 +47,11 @@ class EsmProtFromCsv(Dataset):
48
47
  return len(self.data)
49
48
 
50
49
  def __getitem__(self, idx):
51
- structure_src = self.data.loc[idx, EsmProtFromCsv.STREAM_ATTR]
50
+ src_structure = self.data.loc[idx, EsmProtFromCsv.STREAM_ATTR]
52
51
  chain_id = self.data.loc[idx, EsmProtFromCsv.CH_ATTR]
53
52
  name = self.data.loc[idx, EsmProtFromCsv.NAME_ATTR]
54
53
  structure = get_structure_from_src(
55
- structure_src if self.src_location == SrcLocation.local else stringio_from_url(structure_src),
54
+ src_structure=src_structure if self.src_location == SrcLocation.local else stringio_from_url(src_structure),
56
55
  src_format=self.src_format,
57
56
  chain_id=chain_id
58
57
  )
@@ -0,0 +1,51 @@
1
+ from torch.utils.data import DataLoader
2
+ from lightning import Trainer
3
+ from typer import FileText
4
+
5
+ from rcsb_embedding_model.dataset.esm_prot_from_csv import EsmProtFromCsv
6
+ from rcsb_embedding_model.modules.esm_module import EsmModule
7
+ from rcsb_embedding_model.types.api_types import SrcFormat, Accelerator, Devices, OptionalPath, SrcLocation
8
+ from rcsb_embedding_model.writer.batch_writer import DataFrameStorage
9
+
10
+
11
+ def predict(
12
+ csv_file: FileText,
13
+ src_location: SrcLocation = SrcLocation.local,
14
+ src_format: SrcFormat = SrcFormat.mmcif,
15
+ batch_size: int = 1,
16
+ num_workers: int = 0,
17
+ num_nodes: int = 1,
18
+ accelerator: Accelerator = Accelerator.auto,
19
+ devices: Devices = 'auto',
20
+ out_path: OptionalPath = None,
21
+ out_df_id: str = None
22
+ ):
23
+
24
+ inference_set = EsmProtFromCsv(
25
+ csv_file=csv_file,
26
+ src_location=src_location,
27
+ src_format=src_format
28
+ )
29
+
30
+ inference_dataloader = DataLoader(
31
+ dataset=inference_set,
32
+ batch_size=batch_size,
33
+ num_workers=num_workers,
34
+ collate_fn=lambda _: _
35
+ )
36
+
37
+ module = EsmModule()
38
+ inference_writer = DataFrameStorage(out_path, out_df_id) if out_path is not None and out_df_id is not None else None
39
+ trainer = Trainer(
40
+ callbacks=[inference_writer] if inference_writer is not None else None,
41
+ num_nodes=num_nodes,
42
+ accelerator=accelerator,
43
+ devices=devices
44
+ )
45
+
46
+ prediction = trainer.predict(
47
+ module,
48
+ inference_dataloader
49
+ )
50
+
51
+ return prediction
@@ -0,0 +1,27 @@
1
+ from esm.sdk.api import SamplingConfig
2
+ from lightning import LightningModule
3
+
4
+ from rcsb_embedding_model.utils.data import collate_seq_embeddings
5
+ from rcsb_embedding_model.utils.model import get_residue_model, get_aggregator_model
6
+
7
+
8
+ class StructureModule(LightningModule):
9
+
10
+ def __init__(
11
+ self
12
+ ):
13
+ super().__init__()
14
+ self.esm3 = get_residue_model(self.device)
15
+ self.aggregator = get_aggregator_model(device=self.device)
16
+
17
+ def predict_step(self, prot_batch, batch_idx):
18
+ prot_embeddings = []
19
+ prot_names = []
20
+ for esm_prot, name in prot_batch:
21
+ embeddings = self.esm3.forward_and_sample(
22
+ self.esm3.encode(esm_prot), SamplingConfig(return_per_residue_embeddings=True)
23
+ ).per_residue_embedding
24
+ prot_embeddings.append(embeddings)
25
+ prot_names.append(name)
26
+ res_batch_embedding, res_batch_mask = collate_seq_embeddings(prot_embeddings)
27
+ return self.aggregator(res_batch_embedding, res_batch_mask), tuple(prot_names)
@@ -2,7 +2,6 @@ import torch
2
2
  from biotite.structure import get_residues, chain_iter, filter_amino_acids
3
3
  from esm.sdk.api import ESMProtein, SamplingConfig
4
4
  from esm.utils.structure.protein_chain import ProteinChain
5
- from huggingface_hub import hf_hub_download
6
5
 
7
6
  from rcsb_embedding_model.types.api_types import StreamSrc, SrcFormat
8
7
  from rcsb_embedding_model.utils.model import get_aggregator_model, get_residue_model
@@ -42,23 +41,23 @@ class RcsbStructureEmbedding:
42
41
 
43
42
  def structure_embedding(
44
43
  self,
45
- structure_src: StreamSrc,
44
+ src_structure: StreamSrc,
46
45
  src_format: SrcFormat = SrcFormat.mmcif,
47
46
  chain_id: str = None,
48
47
  assembly_id: str = None
49
48
  ):
50
- res_embedding = self.residue_embedding(structure_src, src_format, chain_id, assembly_id)
49
+ res_embedding = self.residue_embedding(src_structure, src_format, chain_id, assembly_id)
51
50
  return self.aggregator_embedding(res_embedding)
52
51
 
53
52
  def residue_embedding(
54
53
  self,
55
- structure_src: StreamSrc,
54
+ src_structure: StreamSrc,
56
55
  src_format: SrcFormat = SrcFormat.mmcif,
57
56
  chain_id: str = None,
58
57
  assembly_id: str = None
59
58
  ):
60
59
  self.__check_residue_embedding()
61
- structure = get_structure_from_src(structure_src, src_format, chain_id, assembly_id)
60
+ structure = get_structure_from_src(src_structure, src_format, chain_id, assembly_id)
62
61
  embedding_ch = []
63
62
  for atom_ch in chain_iter(structure):
64
63
  atom_res = atom_ch[filter_amino_acids(atom_ch)]
@@ -4,19 +4,19 @@ from biotite.structure.io.pdbx import CIFFile, get_structure, get_assembly, Bina
4
4
 
5
5
 
6
6
  def get_structure_from_src(
7
- structure_src,
7
+ src_structure,
8
8
  src_format="mmcif",
9
9
  chain_id=None,
10
10
  assembly_id=None
11
11
  ):
12
12
  if src_format == "pdb":
13
- pdb_file = PDBFile.read(structure_src)
13
+ pdb_file = PDBFile.read(src_structure)
14
14
  structure = __get_pdb_structure(pdb_file, assembly_id)
15
15
  elif src_format == "mmcif":
16
- cif_file = CIFFile.read(structure_src)
16
+ cif_file = CIFFile.read(src_structure)
17
17
  structure = __get_structure(cif_file, assembly_id)
18
18
  elif src_format == "binarycif":
19
- cif_file = BinaryCIFFile.read(structure_src)
19
+ cif_file = BinaryCIFFile.read(src_structure)
20
20
  structure = __get_structure(cif_file, assembly_id)
21
21
  else:
22
22
  raise RuntimeError(f"Unknown file format {src_format}")
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: rcsb-embedding-model
3
+ Version: 0.0.7
4
+ Summary: Protein Embedding Model for Structure Search
5
+ Project-URL: Homepage, https://github.com/rcsb/rcsb-embedding-model
6
+ Project-URL: Issues, https://github.com/rcsb/rcsb-embedding-model/issues
7
+ Author-email: Joan Segura <joan.segura@rcsb.org>
8
+ License-Expression: BSD-3-Clause
9
+ License-File: LICENSE.md
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: esm>=3.2.0
14
+ Requires-Dist: lightning>=2.5.0
15
+ Requires-Dist: torch>=2.2.0
16
+ Requires-Dist: typer>=0.15.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ # RCSB Embedding Model
20
+
21
+ **Version** 0.0.7
22
+
23
+
24
+ ## Overview
25
+
26
+ RCSB Embedding Model is a neural network architecture designed to encode macromolecular 3D structures into fixed-length vector embeddings for efficient large-scale structure similarity search.
27
+
28
+ Preprint: [Multi-scale structural similarity embedding search across entire proteomes](https://www.biorxiv.org/content/10.1101/2025.02.28.640875v1).
29
+
30
+ A web-based implementation using this model for structure similarity search is available at [rcsb-embedding-search](http://embedding-search.rcsb.org).
31
+
32
+ If you are interested in training the model with a new dataset, visit the [rcsb-embedding-search repository](https://github.com/bioinsilico/rcsb-embedding-search), which provides scripts and documentation for training.
33
+
34
+
35
+ ## Features
36
+
37
+ - **Residue-level embeddings** computed using the ESM3 protein language model
38
+ - **Structure-level embeddings** aggregated via a transformer-based aggregator network
39
+ - **Command-line interface** implemented with Typer for high-throughput inference workflows
40
+ - **Python API** for interactive embedding computation and integration into analysis pipelines
41
+ - **High-performance inference** leveraging PyTorch Lightning, with multi-node and multi-GPU support
42
+
43
+ ---
44
+
45
+ ## Installation
46
+
47
+ pip install rcsb-embedding-model
48
+
49
+ **Requirements:**
50
+
51
+ - Python ≥ 3.10
52
+ - ESM ≥ 3.2.0
53
+ - PyTorch ≥ 2.2.0
54
+ - Lightning ≥ 2.5.0
55
+ - Typer ≥ 0.15.0
56
+
57
+ ---
58
+
59
+ ## Quick Start
60
+
61
+ ### CLI
62
+
63
+ # 1. Compute residue embeddings: Calculate residue level embeddings of protein structures using ESM3.
64
+ inference residue-embedding --src-file data/structures.csv --output-path results/residue_embeddings --src-format mmcif --batch-size 8 --devices auto
65
+
66
+ # 2. Compute structure embeddings: Calculate single-chain protein embeddings from structural files. Predictions are stored in a single pandas data-frame file.
67
+ inference structure-embedding --src-file results/residue_embeddings.csv --output-path results/structure_embeddings --out-df-id embeddings.pkl --batch-size 4 --devices 0 --devives 1
68
+
69
+ # 3. Compute chain embeddings: Calculate single-chain protein embeddings from residue level embeddings stored as torch tensor files.
70
+ inference chain-embedding --src-file results/residue_embeddings.csv --output-path results/chain_embeddings --batch-size 4
71
+
72
+ ### Python API
73
+
74
+ from rcsb_embedding_model import RcsbStructureEmbedding
75
+
76
+ model = RcsbStructureEmbedding()
77
+
78
+ # Compute per-residue embeddings
79
+ res_emb = model.residue_embedding(
80
+ src_structure="examples/1abc.cif",
81
+ src_format="mmcif",
82
+ chain_id="A"
83
+ )
84
+
85
+ # Aggregate to structure-level embedding
86
+ struct_emb = model.aggregator_embedding(res_emb)
87
+
88
+ See the examples directory for complete scripts.
89
+
90
+ ---
91
+
92
+ ## Model Architecture
93
+
94
+ The embedding model is trained to predict structural similarity by approximating TM-scores using cosine distances between embeddings. It consists of two main components:
95
+
96
+ - **Protein Language Model (PLM)**: Computes residue-level embeddings from a given 3D structure.
97
+ - **Residue Embedding Aggregator**: A transformer-based neural network that aggregates these residue-level embeddings into a single vector.
98
+
99
+ ![Embedding model architecture](assets/embedding-model-architecture.png)
100
+
101
+ ### **Protein Language Model (PLM)**
102
+ Residue-wise embeddings of protein structures are computed using the [ESM3](https://www.evolutionaryscale.ai/) generative protein language model.
103
+
104
+ ### **Residue Embedding Aggregator**
105
+ 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.
106
+
107
+ ---
108
+
109
+ ## Development
110
+
111
+ git clone https://github.com/rcsb/rcsb-embedding-model.git
112
+ cd rcsb-embedding-model
113
+ pip install -e .
114
+ pytest
115
+
116
+ ---
117
+
118
+ ## Citation
119
+
120
+ Segura, J., Bittrich, S., et al. (2024). *Multi-scale structural similarity embedding search across entire proteomes*. bioRxiv. (Preprint: https://www.biorxiv.org/content/10.1101/2024.03.07.XXXXX)
121
+
122
+ ---
123
+
124
+ ## License
125
+
126
+ This project is licensed under the BSD 3-Clause License. See [LICENSE.md](LICENSE.md) for details.
@@ -1,22 +1,24 @@
1
1
  rcsb_embedding_model/__init__.py,sha256=r3gLdeBIXkQEQA_K6QcRPO-TtYuAQSutk6pXRUE_nas,120
2
- rcsb_embedding_model/rcsb_structure_embedding.py,sha256=ZvR_1aNZc_gDtz-ljOfJ7mswXzTGl4hcDAAj59ZGiVw,4477
3
- rcsb_embedding_model/cli/args_utils.py,sha256=rv3rANhjvI9BYvlJUSPsa3B6qp-MjdF4iNwv2YmzFl4,188
4
- rcsb_embedding_model/cli/inference.py,sha256=TpJXKWJkYdUbc0_SI_U3jPk94HcpoQcEXzFmif2DFQo,5706
5
- rcsb_embedding_model/dataset/esm_prot_from_csv.py,sha256=f3R0G7RiwJiCtispq5hFjljDOndPCGsZ5f_hdi9S7iw,2718
2
+ rcsb_embedding_model/rcsb_structure_embedding.py,sha256=qGUEdRPjYbsFWThsQa_ZVaSJ7nURnfRBLBqJlLbcY0I,4433
3
+ rcsb_embedding_model/cli/args_utils.py,sha256=7nP2q8pL5dWK_U7opxtWmoFcYVwasky6elHk-dASFaI,165
4
+ rcsb_embedding_model/cli/inference.py,sha256=sx8cGiq_japc0mKFarK1aVkGfK-FhTeZdn_Ng0ijezE,6590
5
+ rcsb_embedding_model/dataset/esm_prot_from_csv.py,sha256=1XMiYyJXfodXZGSrU07uyoYbdKR9-KvNfb1xNqab_W8,2722
6
6
  rcsb_embedding_model/dataset/residue_embedding_from_csv.py,sha256=0-5L64tyER-RpT166pC71qxOpUdVZbcuBQONPcAIuno,862
7
7
  rcsb_embedding_model/inference/chain_inference.py,sha256=SgXDa-TkDcvlkQxqEwDt81RdE7NmgiaJD8uaROgMbl8,1506
8
8
  rcsb_embedding_model/inference/esm_inference.py,sha256=pX-_RhzAIvL0Zdg9wjScLBP6Y1sq4RLNio4-vdR5MLU,1498
9
+ rcsb_embedding_model/inference/structure_inference.py,sha256=qPzAGWyzFWqeKV9yoPSw4LrEB9XgKTJnRQysSBhfg14,1564
9
10
  rcsb_embedding_model/model/layers.py,sha256=lhKaWC4gTS_T5lHOP0mgnnP8nKTPEOm4MrjhESA4hE8,743
10
11
  rcsb_embedding_model/model/residue_embedding_aggregator.py,sha256=k3UW63Ax8DtjCMdD3O5xNxtyAu28l2n3-Ab6nS0atm0,1967
11
12
  rcsb_embedding_model/modules/chain_module.py,sha256=sDSPXJmWuU2C3lt1NorlbUVWZvRSLzumPdFQk01h3VI,403
12
13
  rcsb_embedding_model/modules/esm_module.py,sha256=CTHGOATXiarqZsBsZ8oxGJBj20A73186Slpr0EzMJsE,770
14
+ rcsb_embedding_model/modules/structure_module.py,sha256=dEtDNdWo1j2sSDa0JiOHQfEfQzIWqSLEKpvOX0GrXZ4,1048
13
15
  rcsb_embedding_model/types/api_types.py,sha256=x7274MyjkRXn8B-W-PY5PK9g0CP1pT_clZbrAuFuHPA,626
14
16
  rcsb_embedding_model/utils/data.py,sha256=LGw3wvq_LCcqSovHZacOqxEczn12SZk2i51WK9xkk0k,1877
15
17
  rcsb_embedding_model/utils/model.py,sha256=rpZa-gfm3cEtbBd7UXMHrZv3x6f0AC8TJT3gtrSxr5I,852
16
- rcsb_embedding_model/utils/structure_parser.py,sha256=yb_ul7Ci5uBubBSfctrXfq5GqdC7RYyox5U0jWBdKAI,1492
18
+ rcsb_embedding_model/utils/structure_parser.py,sha256=0lcjCuQMCh0lb3OMj76rqf7kACzJgOwdk3EZ7-ZOQfI,1492
17
19
  rcsb_embedding_model/writer/batch_writer.py,sha256=ekgzFZyoKpcnZ3IDP9hfOWBpuHxUQ31P35ViDAi-Edw,2843
18
- rcsb_embedding_model-0.0.6.dist-info/METADATA,sha256=_Xvyci0hVEaoSWpMJIBhKhAaIy5JWx3IVFqjQ_V8KIc,5442
19
- rcsb_embedding_model-0.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
- rcsb_embedding_model-0.0.6.dist-info/entry_points.txt,sha256=MK11jTIEmaV-x4CkPX5IymDaVs7Ky_f2xxU8BJVZ_9Q,69
21
- rcsb_embedding_model-0.0.6.dist-info/licenses/LICENSE.md,sha256=oUaHiKgfBkChth_Sm67WemEvatO1U0Go8LHjaskXY0w,1522
22
- rcsb_embedding_model-0.0.6.dist-info/RECORD,,
20
+ rcsb_embedding_model-0.0.7.dist-info/METADATA,sha256=mfl1YYB48Um5FdZZkHOwzzMPRvsw_HlFHeqXsCGWs0Q,4959
21
+ rcsb_embedding_model-0.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ rcsb_embedding_model-0.0.7.dist-info/entry_points.txt,sha256=MK11jTIEmaV-x4CkPX5IymDaVs7Ky_f2xxU8BJVZ_9Q,69
23
+ rcsb_embedding_model-0.0.7.dist-info/licenses/LICENSE.md,sha256=oUaHiKgfBkChth_Sm67WemEvatO1U0Go8LHjaskXY0w,1522
24
+ rcsb_embedding_model-0.0.7.dist-info/RECORD,,
@@ -1,117 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: rcsb-embedding-model
3
- Version: 0.0.6
4
- Summary: Protein Embedding Model for Structure Search
5
- Project-URL: Homepage, https://github.com/rcsb/rcsb-embedding-model
6
- Project-URL: Issues, https://github.com/rcsb/rcsb-embedding-model/issues
7
- Author-email: Joan Segura <joan.segura@rcsb.org>
8
- License-Expression: BSD-3-Clause
9
- License-File: LICENSE.md
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.10
13
- Requires-Dist: esm>=3.2.0
14
- Requires-Dist: lightning>=2.5.0
15
- Requires-Dist: torch>=2.2.0
16
- Requires-Dist: typer>=0.15.0
17
- Description-Content-Type: text/markdown
18
-
19
- # RCSB Embedding Model: A Deep Learning Approach for 3D Structure Embeddings
20
-
21
- ## Overview
22
- RCSB Embedding Model is a PyTorch-based neural network that transforms macromolecular 3D structures into vector embeddings.
23
-
24
- Preprint: [Multi-scale structural similarity embedding search across entire proteomes](https://www.biorxiv.org/content/10.1101/2025.02.28.640875v1).
25
-
26
- A web-based implementation using this model for structure similarity search is available at [rcsb-embedding-search](http://embedding-search.rcsb.org).
27
-
28
- If you are interested in training the model with a new dataset, visit the [rcsb-embedding-search repository](https://github.com/bioinsilico/rcsb-embedding-search), which provides scripts and documentation for training.
29
-
30
- ---
31
-
32
- ## Embedding Model
33
- The embedding model is trained to predict structural similarity by approximating TM-scores using cosine distances between embeddings. It consists of two main components:
34
-
35
- - **Protein Language Model (PLM)**: Computes residue-level embeddings from a given 3D structure.
36
- - **Residue Embedding Aggregator**: A transformer-based neural network that aggregates these residue-level embeddings into a single vector.
37
-
38
- ![Embedding model architecture](assets/embedding-model-architecture.png)
39
-
40
- ### **Protein Language Model (PLM)**
41
- Residue-wise embeddings of protein structures are computed using the [ESM3](https://www.evolutionaryscale.ai/) generative protein language model.
42
-
43
- ### **Residue Embedding Aggregator**
44
- 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.
45
-
46
- ---
47
-
48
- ## How to Use the Model
49
- This repository provides the tools to compute embeddings for 3D macromolecular structure data.
50
-
51
- ### **Installation**
52
- `pip install rcsb-embedding-model`
53
-
54
- ### **Requirements**
55
- Ensure you have the following dependencies installed:
56
- - `python >= 3.10`
57
- - `esm`
58
- - `torch`
59
-
60
- ### **Generating Residue Embeddings**
61
- ESM3 embeddings for the 3D structures can be calculated as:
62
-
63
- ```python
64
- from rcsb_embedding_model import RcsbStructureEmbedding
65
-
66
- mmcif_file = "<path_to_file>/<name>.cif"
67
- model = RcsbStructureEmbedding()
68
- res_embedding = model.residue_embedding(
69
- structure_src=mmcif_file,
70
- format="mmcif",
71
- chain_id='A'
72
- )
73
- ```
74
-
75
- ### **Generating Protein Structure Embeddings**
76
- Protein 3D structure embedding can be calculated as:
77
-
78
- ```python
79
- from rcsb_embedding_model import RcsbStructureEmbedding
80
-
81
- mmcif_file = "<path_to_file>/<name>.cif"
82
- model = RcsbStructureEmbedding()
83
- res_embedding = model.residue_embedding(
84
- structure_src=mmcif_file,
85
- format="mmcif",
86
- chain_id='A'
87
- )
88
- structure_embedding = model.aggregator_embedding(
89
- res_embedding
90
- )
91
- ```
92
-
93
- ### **Pretrained Model**
94
- You can download a pretrained Residue Embedding Aggregator model from [Hugging Face](https://huggingface.co/jseguramora/rcsb-embedding-model/resolve/main/rcsb-embedding-model.pt).
95
-
96
- ---
97
-
98
- ## Questions & Issues
99
- For any questions or comments, please open an issue on this repository.
100
-
101
- ---
102
-
103
- ## License
104
- This software is released under the BSD 3-Clause License. See the full license text below.
105
-
106
- ### BSD 3-Clause License
107
-
108
- Copyright (c) 2024, RCSB Protein Data Bank, UC San Diego
109
-
110
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
111
-
112
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
113
- 2. 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.
114
- 3. 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.
115
-
116
- 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.
117
-