pepe-cli 1.0.0__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.
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: pepe-cli
3
+ Version: 1.0.0
4
+ Summary: Pipeline for Easy Protein Embedding - Extract embeddings and attention matrices from protein sequences
5
+ Home-page: https://github.com/csi-greifflab/pepe-cli
6
+ Author: Jahn Zhong
7
+ Author-email: Jahn Zhong <jahn.zhong@medisin.uio.no>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/csi-greifflab/pepe-cli
10
+ Project-URL: Bug Reports, https://github.com/csi-greifflab/pepe-cli/issues
11
+ Project-URL: Source, https://github.com/csi-greifflab/pepe-cli
12
+ Project-URL: Documentation, https://github.com/csi-greifflab/pepe-cli#readme
13
+ Keywords: protein,embeddings,bioinformatics,machine-learning,nlp,transformers
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: torch>=1.9.0
29
+ Requires-Dist: transformers>=4.20.0
30
+ Requires-Dist: fair-esm
31
+ Requires-Dist: sentencepiece
32
+ Requires-Dist: numpy
33
+ Requires-Dist: protobuf
34
+ Requires-Dist: rjieba
35
+ Requires-Dist: alive_progress
36
+ Dynamic: author
37
+ Dynamic: home-page
38
+ Dynamic: license-file
39
+ Dynamic: requires-python
40
+
41
+ # PEPE
42
+
43
+ PEPE (Pipeline for Easy Protein Embedding) is a tool for extracting embeddings and attention matrices from protein sequences using pre-trained models. This tool supports various configurations for extracting embeddings and attention matrices, including options for handling CDR3 sequences. Currently implemented models are ESM2 from the 2023 paper ["Evolutionary-scale prediction of atomic-level protein structure with a language model"](https://science.org/doi/10.1126/science.ade2574) and AntiBERTa2-CSSP from the 2023 conference paper ["Enhancing Antibody Language Models with Structural Information"](https://www.mlsb.io/papers_2023/Enhancing_Antibody_Language_Models_with_Structural_Information.pdf). PEPE also supports custom PLMs from local files or from Huggingface Hub addresses.
44
+
45
+ ## Quick start
46
+
47
+ 1. Install PEPE \
48
+ From PyPI:
49
+ ```sh
50
+ pip install pepe-cli
51
+ ```
52
+ Or install from the GitHub repository:
53
+ ```sh
54
+ git clone https://github.com/csi-greifflab/pepe-cli
55
+ cd pepe-cli
56
+ pip install .
57
+ ```
58
+ 2. Run the embedding script:\
59
+ Extract mean pooled embeddings from protein amino acid sequences in FASTA file:
60
+ ```sh
61
+ pepe --experiment_name <optional_string> --fasta_path <file_path> --output_path <directory> --model_name <model_name>
62
+ ```
63
+
64
+ ## List of supported models:
65
+ - ESM-family models
66
+ - ESM1:
67
+ - esm1_t34_670M_UR50S
68
+ - esm1_t34_670M_UR50D
69
+ - esm1_t34_670M_UR100
70
+ - esm1_t12_85M_UR50S
71
+ - esm1_t6_43M_UR50S
72
+ - esm1b_t33_650M_UR50S
73
+ - esm1v_t33_650M_UR90S_1
74
+ - esm1v_t33_650M_UR90S_2
75
+ - esm1v_t33_650M_UR90S_3
76
+ - esm1v_t33_650M_UR90S_4
77
+ - esm1v_t33_650M_UR90S_5
78
+ - ESM2:
79
+ - esm2_t6_8M_UR50D
80
+ - esm2_t12_35M_UR50D
81
+ - esm2_t30_150M_UR50D
82
+ - esm2_t33_650M_UR50D
83
+ - esm2_t36_3B_UR50D
84
+ - esm2_t48_15B_UR50D
85
+ - Huggingface Transformer models
86
+ - T5 transformer models
87
+ - Rostlab/prot_t5_xl_half_uniref50-enc
88
+ - Rostlab/ProstT5
89
+ - RoFormer models
90
+ - alchemab/antiberta2-cssp
91
+ - alchemab/antiberta2
92
+ - Custom Hugging Face models
93
+ - Any compatible model from Hugging Face Hub: `username/model-name`
94
+ - Private models with authentication
95
+ - Local Hugging Face models
96
+ - Custom Models
97
+ - Load your own PyTorch models with custom tokenizers
98
+ - Create example with: `python examples/custom_model/create_example_custom_model.py`
99
+
100
+
101
+ ## Arguments
102
+
103
+ ### Required Arguments
104
+ - **`--model_name`** (str): Name of model or link to model. Choose from [List of supported models](../README.md#list-of-supported-models) or use custom models:
105
+ - ESM models: `esm2_t33_650M_UR50D`
106
+ - Hugging Face models: `username/model-name`
107
+ - Custom PyTorch models: `/path/to/model.pt` or `/path/to/model_directory/`
108
+ - Local HF models: `/path/to/local_hf_directory/`
109
+ - **`--fasta_path`** (str): Path to the input FASTA file. If no experiment name is provided, the output files will be named after the input file.
110
+ - **`--output_path`** (str): Directory for output files. Will generate a subdirectory for outputs of each output type.
111
+
112
+ ### Model Configuration
113
+ - **`--tokenizer_from`** (str, optional): Huggingface address of the tokenizer to use. If not provided, will attempt to search for tokenizer packaged with model. If using a custom model, provide the path to the tokenizer directory.
114
+ - **`--disable_special_tokens`** (bool, optional): When True, PEPE disables pre- and appending BOS/CLS and EOS/SEP tokens before embedding. Default is `False`.
115
+ - **`--device`** (str, optional): Device to run the model on. Choose from `cuda` or `cpu`. Default is `cuda`.
116
+
117
+ ### Embedding Configuration
118
+ - **`--layers`** (str, optional): Representation layers to extract from the model. Default is the last layer. Example: `--layers -1 6`.
119
+ - **`--extract_embeddings`** (str, optional): Set the embedding return types. Choose one or more from: `per_token`, `mean_pooled`, `substring_pooled`, `attention_head`, `attention_layer`, `attention_model` and `logits` (experimental). Default is `mean_pooled`.
120
+ - **`--substring_path`** (str, optional): Path to a CSV file with columns "sequence_id" and "substring". Only required when selecting "substring_pooled" option.
121
+ - **`--context`** (int, optional): Only specify when including "substring_pooled" in `--extract_embeddings` option. Number of amino acids to include before and after the substring sequence. Default is `0`.
122
+
123
+ ### Processing Configuration
124
+ - **`--batch_size`** (int, optional): Batch size for loading sequences. Default is `1024`. Decrease if encountering out-of-memory errors.
125
+ - **`--max_length`** (int, optional): Length to which sequences will be padded. Default is length of longest sequence in input file. If shorter than longest sequence, will forcefully default to length of longest sequence.
126
+ - **`--discard_padding`** (bool, optional): Discard padding tokens from per_token embeddings output. Default is `False`.
127
+
128
+ ### Output Configuration
129
+ - **`--experiment_name`** (str, optional): Prefix for names of output files. If not provided, name of input file will be used for prefix.
130
+ - **`--streaming_output`** (bool, optional): PEPE preallocates the required disk space and writes each batch of outputs concurrently. Can pose issues with file systems that do not support memory mapping (such as some distributed file systems.)
131
+ When False, all outputs are stored in RAM and written to disk at once after computation has finished. Default is `True`.
132
+ - **`--precision`** (str, optional): Precision of the output data. Choose from `float16`, `16`, `half`, `float32`, `32`, `full`. Inference during embedding is not affected. Default is `float32`.
133
+ - **`--flatten`** (bool, optional): Flatten 2D output arrays (per_token embeddings or attention weights) to 1D arrays per input sequence. Default is `False`.
134
+
135
+ ### Performance Configuration
136
+ - **`--num_workers`** (int, optional): Number of workers for asynchronous data writing. Only relevant when `--streaming_output` is enabled. Default is `8`.
137
+ - **`--flush_batches_after`** (int, optional): Size (in MB) of outputs to accumulate in RAM per worker before flushing to disk. Default is `128`.
@@ -0,0 +1,18 @@
1
+ pepe/__init__.py,sha256=zgfot0JU9KkNmdM5PZtbBQtmw0OMnvKZCaTEp-cDcEg,1151
2
+ pepe/__main__.py,sha256=2a69vmgpMV-e8jtEcj5CyP786VQ_9Lo-T1MY9Us21yw,425
3
+ pepe/model_selecter.py,sha256=2Z2rV3-M3xXnC_upWCObVMOnpZNKoIZV-pwd-vh8c2U,3845
4
+ pepe/parse_arguments.py,sha256=L4hHxpfV-OMjiWenVGO4BemVcZQQ1I7alTS6b8gov_I,6183
5
+ pepe/utils.py,sha256=35h-cpQoC14JYt1IthXs4qoEiR86Li4mIZ6uJttlK14,35161
6
+ pepe/embedders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ pepe/embedders/base_embedder.py,sha256=agcFYshd-HjJJaAqwm7YWyjo2OJafSVxPXCRS26Mc0c,31962
8
+ pepe/embedders/custom_embedder.py,sha256=9fH4e5YVxN9PCOu6xK9X9pWL0dT4R4rbKCRwQeDh31I,21602
9
+ pepe/embedders/esm_embedder.py,sha256=dlt-jtoi_dEabmvcVZIi58VuP7pq4L17CJ66u3jq-I0,6012
10
+ pepe/embedders/huggingface_embedder.py,sha256=dlOCf1CWMtmo8mYWN6e17RlcojVAANi4APAwuxKKCao,7491
11
+ pepe_cli-1.0.0.dist-info/licenses/LICENSE,sha256=TON5-TiDRcqj_Az-jheUcJW9ZdFp7A-wCklGXX8jEaI,1104
12
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ tests/test_run.py,sha256=66wTAhZkulLayRd9wLEMDsL4jARtQO8PjIu0T57gSLA,983
14
+ pepe_cli-1.0.0.dist-info/METADATA,sha256=qyCqyn3mp8jr19p1_VbXfsUfmBWehrKMGwmsDeWOLeU,7836
15
+ pepe_cli-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ pepe_cli-1.0.0.dist-info/entry_points.txt,sha256=MyspMe6w0Duad1S4seIXPB8YoGt8NQd5FwvuWBIJeiI,74
17
+ pepe_cli-1.0.0.dist-info/top_level.txt,sha256=v_cT66WiSSlqmhvlxTsu8mshTPu7VNk2ivoEaPjKoIk,11
18
+ pepe_cli-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ pepe = pepe.__main__:main
3
+ pepe-cli = pepe.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Greiff Lab – Computational Systems Immunology
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ pepe
2
+ tests
tests/__init__.py ADDED
File without changes
tests/test_run.py ADDED
@@ -0,0 +1,43 @@
1
+ import sys
2
+ import os
3
+ from pepe.__main__ import parse_arguments
4
+ from pepe.model_selecter import select_model
5
+
6
+
7
+ # os.environ["CUDA_VISIBLE_DEVICES"] = ""
8
+ sys.argv = [
9
+ "pepe",
10
+ "--experiment_name",
11
+ "test",
12
+ "--model_name",
13
+ "/home/jahn/embedairr/examples/custom_model/example_protein_model",
14
+ "--fasta_path",
15
+ "src/tests/test_files/test.fasta",
16
+ "--output_path",
17
+ "src/tests/test_files/test_output",
18
+ "--substring_path",
19
+ "src/tests/test_files/test_substring.csv",
20
+ "--extract_embeddings",
21
+ "mean_pooled",
22
+ "per_token",
23
+ "substring_pooling",
24
+ "attention_head",
25
+ "--batch_writing",
26
+ "true",
27
+ "--device",
28
+ "cpu",
29
+ ]
30
+
31
+ args = parse_arguments()
32
+
33
+ # Check if output directory exists and creates it if it's missing
34
+ if not os.path.exists(args.output_path):
35
+ os.makedirs(args.output_path)
36
+
37
+ embedder = select_model(args.model_name)
38
+
39
+ embedder = embedder(args)
40
+ print("Embedder initialized")
41
+
42
+ embedder.run()
43
+ print("All outputs saved.")