PengJiaMa123 commited on
Commit
3f63b5c
·
verified ·
1 Parent(s): c6026a8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +148 -0
README.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RAMER
2
+
3
+ RAMER is a pretrained reaction-aware multimodal AI model that integrates protein sequence, structure, and catalytic reaction information to improve enzyme function annotation, including strong recall at fine-grained EC levels.
4
+
5
+ At large scale, RAMER has been applied to billions of proteins across diverse environments and supports function-driven mining of valuable enzymes by linking sequence/structure signals with catalytic behavior. This repository provides practical scripts and workflows for:
6
+
7
+ - Zero-shot EC prediction (`top1` and `max-separation` strategies)
8
+ - Binary enzyme/non-enzyme classification on top of RAMER embeddings
9
+ - Distributed training reproduction (DDP with `torchrun`)
10
+
11
+ Project assets (`Background_library`, `data`, and `model`) are available on Hugging Face: [PengJiaMa123/RAMER](https://huggingface.co/PengJiaMa123/RAMER).
12
+
13
+ ## Repository Structure
14
+
15
+ - `set1_get_RAMER_embedding.py`: generate RAMER embeddings from FASTA/FAA input
16
+ - `set2_top1_zero_shot.py`: zero-shot EC prediction with top-1 retrieval
17
+ - `set2_max_sep_zero_shot.py`: zero-shot EC prediction with dynamic max-separation selection
18
+ - `eval_ec_csv_with_background_dict.py`: EC evaluation script based on background dictionary labels
19
+ - `binary_enzyme_classifier.py`: enzyme/non-enzyme binary classifier from RAMER embeddings
20
+ - `train.py`: DDP training script
21
+ - `Data2seq/`: sequence/structure/reaction encoders and fusion components
22
+
23
+ ## Environment Setup
24
+
25
+ ```bash
26
+ cd ./RAMER
27
+ conda create -n ramer python=3.10 -y
28
+ conda activate ramer
29
+
30
+ # Install PyTorch according to your CUDA/CPU environment
31
+ # Example (edit based on your machine): pip install torch torchvision torchaudio
32
+
33
+ pip install transformers tqdm sentencepiece protobuf scikit-learn h5py biopython xgboost peft
34
+ ```
35
+
36
+ ## Data and Model Preparation
37
+
38
+ Download project resources from [PengJiaMa123/RAMER](https://huggingface.co/PengJiaMa123/RAMER) and place them under the project root:
39
+
40
+ - `./Background_library`
41
+ - `./data`
42
+ - `./model`
43
+
44
+ ### Training-only note
45
+
46
+ To reproduce training, first unzip:
47
+
48
+ - `./data/gernet_embedding.zip`
49
+
50
+ to get:
51
+
52
+ - `./data/gernet_embedding` (or pass a custom path via `--gearnet_embedding_path`)
53
+
54
+ For inference-only usage, this GearNet directory is not required.
55
+
56
+ ## Inference Pipeline
57
+
58
+ ### 1) Generate RAMER embeddings
59
+
60
+ Input only the file base name. The script resolves:
61
+
62
+ - `./input/<input_name>.fasta` first
63
+ - then `./input/<input_name>.faa`
64
+
65
+ ```bash
66
+ python ./set1_get_RAMER_embedding.py --input_name NEW-392
67
+ ```
68
+
69
+ Output:
70
+
71
+ - `./output/NEW-392.h5`
72
+
73
+ > If needed, you can override defaults such as `--model_path`, `--batch_size`, and `--save_interval`.
74
+
75
+ ### 2) Zero-shot EC prediction (Top-1)
76
+
77
+ ```bash
78
+ python ./set2_top1_zero_shot.py \
79
+ --test_name NEW-392 \
80
+ --batch_size 8000 \
81
+ --background_library_h5 ./Background_library/clean100_set.h5 \
82
+ --background_library_dict ./Background_library/clean100_set_dict.json
83
+ ```
84
+
85
+ Output:
86
+
87
+ - `./output/NEW-392_top1.csv`
88
+
89
+ ### 3) Zero-shot EC prediction (Max-separation)
90
+
91
+ ```bash
92
+ python ./set2_max_sep_zero_shot.py \
93
+ --test_name NEW-392 \
94
+ --batch_size 8000 \
95
+ --background_library_h5 ./Background_library/clean100_set.h5 \
96
+ --background_library_dict ./Background_library/clean100_set_dict.json
97
+ ```
98
+
99
+ Output:
100
+
101
+ - `./output/NEW-392_max-sep.csv`
102
+
103
+ ### Background dictionary choice
104
+
105
+ - Use `clean100_set_dict.json` to reproduce comparison settings aligned with baseline training splits.
106
+ - Use `clean100_set_dict_updated_2025.json` when you want updated EC annotations.
107
+
108
+ ## EC Evaluation
109
+
110
+ Use:
111
+
112
+ - `./eval_ec_csv_with_background_dict.py`
113
+
114
+ Prediction CSVs for RAMER and other methods on `new392` / `ram255` are located in:
115
+
116
+ - `./data/test_data`
117
+
118
+ ## Enzyme / Non-enzyme Classification
119
+
120
+ This task requires RAMER embedding `.h5` files under `./RAMER_embedding`.
121
+
122
+ ```bash
123
+ python ./binary_enzyme_classifier.py --input_name NEW-392
124
+ ```
125
+
126
+ Output:
127
+
128
+ - `./output/NEW-392_enzyme_classifier.csv`
129
+
130
+ CSV columns:
131
+
132
+ - `test_id`
133
+ - `is_enzyme` (`0` or `1`)
134
+ - `enzyme_probability`
135
+
136
+ ## Training Reproduction (DDP)
137
+
138
+ ```bash
139
+ torchrun --nproc_per_node=8 train.py \
140
+ --seq_data ./data/uniprot_20W_struct_seq_reaction_121_without_new392.json \
141
+ --reaction_data ./data/updated_rhea-reaction-smiles.json \
142
+ --gearnet_embedding_path ./data/gernet_embedding \
143
+ --log_file ./training_t_position_loss.log \
144
+ --model_save_dir ./train_model \
145
+ --epochs 50 \
146
+ --batch_size 24
147
+ ```
148
+