Spaces:
Runtime error

plastic0105 commited on
Commit
5633aba
·
verified ·
1 Parent(s): c08a315

Upload mint_repo/README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. mint_repo/README.md +181 -0
mint_repo/README.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1 align="center">
2
+ Learning the language of protein-protein interactions
3
+ </h1>
4
+
5
+ ## 🌿 Overview of MINT
6
+
7
+ MINT (Multimeric INteraction Transformer) is a Protein Language Model (PLM) designed for **contextual and scalable** modeling of interacting protein sequences. Trained on a large, curated set of **96 million protein-protein interactions (PPIs)** from the STRING database, MINT outperforms existing PLMs across diverse tasks and protein types, including:
8
+
9
+ - Binding affinity prediction
10
+ - Mutational effect estimation
11
+ - Complex protein assembly modeling
12
+ - Antibody-antigen interaction modeling
13
+ - T cell receptor–epitope binding prediction
14
+
15
+ 🔬 **Why MINT?**
16
+
17
+ ✅ First PLM to be trained on large-scale PPI data
18
+
19
+ ✅ State-of-the-art performance across multiple PPI tasks
20
+
21
+ ✅ Scalable and adaptable for diverse protein interactions
22
+
23
+ ## 🖥️ Installation
24
+
25
+ 1. Create a new [conda](https://docs.anaconda.com/miniconda/install/) environment from the provided `enviroment.yml` file.
26
+
27
+ ```
28
+ conda env create --name mint --file=environment.yml
29
+ ```
30
+
31
+ 2. Activate the enviroment and install the package from source.
32
+
33
+ ```
34
+ conda activate mint
35
+ pip install -e .
36
+ ```
37
+
38
+ 3. Check if you are able to import the package.
39
+
40
+ ```
41
+ python -c "import mint; print('Success')"
42
+ ```
43
+
44
+ 4. Download the model checkpoint and note the file path where it is stored.
45
+
46
+ ```
47
+ wget https://huggingface.co/varunullanat2012/mint/resolve/main/mint.ckpt
48
+ ```
49
+
50
+ ## 🚀 How to use
51
+
52
+ ### Generating embeddings
53
+
54
+ We suggest generating embeddings from a CSV file containing the interacting sequences like this one [here](./data/protein_sequences.csv). Next, simply execute the following code to get average embeddings over all input sequences.
55
+
56
+ ```
57
+ import torch
58
+ from mint.helpers.extract import load_config, CSVDataset, CollateFn, MINTWrapper
59
+
60
+ cfg = load_config("data/esm2_t33_650M_UR50D.json") # model config
61
+ device = 'cuda:0' # GPU device
62
+ checkpoint_path = '' # Where you stored the model checkpoint
63
+
64
+ dataset = CSVDataset('data/protein_sequences.csv', 'Protein_Sequence_1', 'Protein_Sequence_2')
65
+ loader = torch.utils.data.DataLoader(dataset, batch_size=2, collate_fn=CollateFn(512), shuffle=False)
66
+
67
+ wrapper = MINTWrapper(cfg, checkpoint_path, device=device)
68
+
69
+ chains, chain_ids = next(iter(loader)) # Get the first batch
70
+ chains = chains.to(device)
71
+ chain_ids = chain_ids.to(device)
72
+ embeddings = wrapper(chains, chain_ids) # Generate embeddings
73
+ print(embeddings.shape) # Should be of shape (2, 1280)
74
+ ```
75
+
76
+ However, we **recommend** using the `sep_chains=True` argument in the wrapper class for maximum performance on downstream tasks. This gets the sequence-level embedding for **all sequences**, and returns it concatenated in the same order as the input.
77
+
78
+ ```
79
+ wrapper = MINTWrapper(cfg, checkpoint_path, sep_chains=True, device=device)
80
+
81
+ chains, chain_ids = next(iter(loader)) # Get the first batch
82
+ chains = chains.to(device)
83
+ chain_ids = chain_ids.to(device)
84
+ embeddings = wrapper(chains, chain_ids) # Generate embeddings
85
+ print(embeddings.shape) # Should be of shape (2, 2560)
86
+ ```
87
+
88
+ ### Binary PPI classification
89
+
90
+ We provide code and a [model checkpoint](https://huggingface.co/varunullanat2012/mint/blob/main/bernett_mlp.pth) to predict whether two input sequences interact or not. The downstream model, which is an MLP, is trained using the gold-standard data from [Bernett et al.](./downstream/GeneralPPI/ppi).
91
+
92
+ ```
93
+ import torch
94
+ from mint.helpers.extract import load_config, CSVDataset, CollateFn, MINTWrapper
95
+ from mint.helpers.predict import SimpleMLP
96
+
97
+ cfg = load_config("data/esm2_t33_650M_UR50D.json") # model config
98
+ device = 'cuda:0' # GPU device
99
+ checkpoint_path = 'mint.ckpt' # Where you stored the model checkpoint
100
+ mlp_checkpoint_path = 'bernett_mlp.pth' # Where you stored the Bernett MLP checkpoint
101
+
102
+ dataset = CSVDataset('data/protein_sequences.csv', 'Protein_Sequence_1', 'Protein_Sequence_2')
103
+ loader = torch.utils.data.DataLoader(dataset, batch_size=2, collate_fn=CollateFn(512), shuffle=False)
104
+
105
+ wrapper = MINTWrapper(cfg, checkpoint_path, sep_chains=True, device=device)
106
+
107
+ # Generate embeddings
108
+ chains, chain_ids = next(iter(loader))
109
+ chains = chains.to(device)
110
+ chain_ids = chain_ids.to(device)
111
+ embeddings = wrapper(chains, chain_ids) # Should be of shape (2, 2560)
112
+
113
+ # Predict using trained MLP
114
+ model = SimpleMLP()
115
+ mlp_checkpoint = torch.load(mlp_checkpoint_path)
116
+ model.load_state_dict(mlp_checkpoint)
117
+ model.eval()
118
+ model.to(device)
119
+
120
+ predictions = torch.sigmoid(model(embeddings)) # Should be of shape (2, 1)
121
+ print(predictions) # Probability of interaction (0 is no, 1 is yes)
122
+ ```
123
+
124
+ ### Finetuning
125
+
126
+ To finetune our model on a new supervised dataset, simply set the `freeze_percent` parameter to anything other than 1. Setting it to 0.5 means the last 50% of the model layers can be trained. For example,
127
+
128
+ ```
129
+ import torch
130
+ from mint.helpers.extract import MINTWrapper
131
+
132
+ cfg = load_config("data/esm2_t33_650M_UR50D.json") # model config
133
+ device = 'cuda:0' # GPU device
134
+ checkpoint_path = '' # path where you stored the model checkpoint
135
+
136
+ wrapper = MINTWrapper(cfg, checkpoint_path, freeze_percent=0.5, device=device)
137
+ for name, param in wrapper.model.named_parameters():
138
+ print(f"Parameter: {name}, Trainable: {param.requires_grad}")
139
+ ```
140
+
141
+ ### Pre-training on STRING-DB
142
+
143
+ This section outlines the steps required to pretrain MINT on PPIs from STRING-DB. First, to create the train-validation splits we used, first download `protein.physical.links.v12.0.txt.gz` and `protein.sequences.v12.0.fa.gz` from [STRING-DB](https://stringdb-downloads.org/download/).
144
+
145
+ Then, run the following commands to cluster the sequences using a 50% sequence similarity threshold using [mmseqs](https://github.com/soedinglab/MMseqs2).
146
+
147
+ ```
148
+ mmseqs createdb protein.sequences.v12.0.fa DB100
149
+ mmseqs cluster DB100 clu50 /tmp/mmseqs --min-seq-id 0.50 --remove-tmp-files
150
+ mmseqs createtsv DB100 DB100 clu50 clu50.tsv
151
+ ```
152
+
153
+ Then, run `stringdb.py`, ensuring that the filepaths in that script match the paths where you stored the `protein.sequences.v12.0.fa`, `clu50.tsv` (output of the previous step), and `protein.physical.links.full.v12.0.txt.gz` files.
154
+
155
+ Finally, run the training like this:
156
+
157
+ ```
158
+ python train.py --batch_size 2 --crop_len 512 --model 650M --val_check_interval 320000 --accumulate_grad 32 --run_name 650M_nofreeze_filtered --copy_weights --wandb --dataset_split filtered
159
+ ```
160
+
161
+ ### Examples
162
+
163
+ We provide several examples highlighting the use cases of MINT on various supervised tasks and different protein types in the `downstream` folder.
164
+
165
+ 1. [Predict whether two proteins interact or not](./downstream/GeneralPPI/ppi)
166
+ 2. [Predict the binding affinity of protein complexes](./downstream/GeneralPPI/pdb-bind)
167
+ 3. [Predict whether two proteins interact or not after mutation](./downstream/GeneralPPI/mutational-ppi)
168
+ 4. [Predict the difference in binding affinity in protein complexes upon mutation](./downstream/GeneralPPI/SKEMPI_v2)
169
+
170
+
171
+ ## 📝 Citing
172
+
173
+ ```
174
+ @article{ullanat2026learning,
175
+ title={Learning the language of protein-protein interactions},
176
+ author={Ullanat, Varun and Jing, Bowen and Sledzieski, Samuel and Berger, Bonnie},
177
+ journal={Nature Communications},
178
+ year={2026},
179
+ publisher={Nature Publishing Group UK London}
180
+ }
181
+ ```